Page 1 of 1

Status,g,<gpio>

Posted: 26 Jul 2023, 13:42
by TommoT1
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!

Re: Status,g,<gpio>

Posted: 26 Jul 2023, 14:09
by Micha_he
"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.

Re: Status,g,<gpio>

Posted: 26 Jul 2023, 19:48
by TommoT1
Thanks! It does :)
Does it also work this way with MCPGPIO or PCFGPIO pins?

Re: Status,g,<gpio>

Posted: 26 Jul 2023, 20:05
by Ath
TommoT1 wrote: 26 Jul 2023, 19:48 Does it also work this way with MCPGPIO or PCFGPIO pins?
Yes, see the documentation

Re: Status,g,<gpio>

Posted: 26 Jul 2023, 20:27
by TommoT1
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

Re: Status,g,<gpio>

Posted: 26 Jul 2023, 21:27
by Ath
Ah, yes, then you will find this page more useful ;)

Re: Status,g,<gpio>

Posted: 26 Jul 2023, 21:38
by TommoT1
Oh yes! That's great! Thank's for sharing!

Re: Status,g,<gpio>

Posted: 26 Jul 2023, 22:54
by TD-er
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.

Re: Status,g,<gpio>

Posted: 27 Jul 2023, 12:20
by TommoT1
Thank's for explaining!