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?
Thanks for the suggestions. I went to a command line switch as as soon as I configured the GPIO pin as a “switch” to control via mqtt, the votage dropped to about 1.5 volts from 3 volts… So the leds that it is powering dimmed to about half. As soon as I removed the switch the pin goes high again to 3v - and bright lights… Command line switch was a work around to mqtt not working.
As show below, as soon as I enable this device the voltage drops:
This seems to work, but the switch when the state_command is enabled doesn’t work. As soon as I comment out this line it “works” but HA doesn’t know the state. ideally I would use MQTT. But as I said, the voltage drops and the lights dim- am I configuring the esp8266 incorrectly?!