Status,g,<gpio>

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
TommoT1
Normal user
Posts: 15
Joined: 17 Aug 2018, 11:46

Status,g,<gpio>

#1 Post by TommoT1 » 26 Jul 2023, 13:42

Hi there, I´m unable to find a solution in this Forum nor the web......

According to the commandref "Status,g,<gpio>" gives you the status of the respetive GPIO.
Unfortunately it is a whole bunch of text, e.g.
{
"log": "",
"plugin": 1,
"pin": 12,
"mode": "output",
"state": 0
}
I only need the "1" or "0" to decide further actions....
My DeviceList is full with 12 devices so I cannot configure it there to get a simple 1 or 0.
Is there any formatting possible that I can use it in the rules?

For example like this:

if (status,g,12) = 1
event,do_something
else
event,do_somethingelse
endif


Thanks for your help!

Micha_he
Normal user
Posts: 372
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: Status,g,<gpio>

#2 Post by Micha_he » 26 Jul 2023, 14:09

"Status,g,..." I've never seen in EspEasy.

Edit: Ok, I've found it, it's a command. I think, it didn't work in if-clauses.

But

Code: Select all

if [Plugin#GPIO#Pinstate#12]=1
should work.

TommoT1
Normal user
Posts: 15
Joined: 17 Aug 2018, 11:46

Re: Status,g,<gpio>

#3 Post by TommoT1 » 26 Jul 2023, 19:48

Thanks! It does :)
Does it also work this way with MCPGPIO or PCFGPIO pins?

User avatar
Ath
Normal user
Posts: 3522
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Status,g,<gpio>

#4 Post by Ath » 26 Jul 2023, 20:05

TommoT1 wrote: 26 Jul 2023, 19:48 Does it also work this way with MCPGPIO or PCFGPIO pins?
Yes, see the documentation
/Ton (PayPal.me)

TommoT1
Normal user
Posts: 15
Joined: 17 Aug 2018, 11:46

Re: Status,g,<gpio>

#5 Post by TommoT1 » 26 Jul 2023, 20:27

Hi ath,
unfortunately the link you posted brings me to the documentation page were I also found
"status,g,<gpiopin>" which does not work in an "if" statement as described....
So I assume "Status,MCP,<MCPGPIO>" will also provide more return info than needed in an if statement
Regards

User avatar
Ath
Normal user
Posts: 3522
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Status,g,<gpio>

#6 Post by Ath » 26 Jul 2023, 21:27

Ah, yes, then you will find this page more useful ;)
/Ton (PayPal.me)

TommoT1
Normal user
Posts: 15
Joined: 17 Aug 2018, 11:46

Re: Status,g,<gpio>

#7 Post by TommoT1 » 26 Jul 2023, 21:38

Oh yes! That's great! Thank's for sharing!

TD-er
Core team member
Posts: 8756
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Status,g,<gpio>

#8 Post by TD-er » 26 Jul 2023, 22:54

A command does not return a value which you try to use in the if statement.

It isn't a programming language :)

Stuff wrapped between [] or %% will be replaced by some value before the rules line is being processed.
A command isn't one of these and will simply be executed but doesn't return a value after execution.

TommoT1
Normal user
Posts: 15
Joined: 17 Aug 2018, 11:46

Re: Status,g,<gpio>

#9 Post by TommoT1 » 27 Jul 2023, 12:20

Thank's for explaining!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 35 guests