Hi,
I’m having problems getting the state of a pin on my ESP8266. I am using the command line switch component to successfully turn it on and off, no issues.
However I don’t know how to return the state of the switch/ pin…
I have got this far:
curl -k http://192.168.1.230/control?cmd=status,gpio,0
(my light is connected to GPIO - 0)
The command returs:
{
“log”: “”,
“plugin”: 1,
“pin”: 0,
“mode”: “output”,
“state”: 1
}
Or when the switch is off: “state”: 0
What I don’t know how to do is abstract the 1 or 0 which I presume is what HA needs returned for the state?
YAML file is like this:
switch:
- platform: command_line
switches:
eva_smiggle:
command_on: /home/john/smiggleon.sh
command_off: /home/john/smiggleoff.sh
command_state: /home/john/smigglestate.sh
value_template: '{{ value == "1" }}'
Any help much appreciated!
John