I use the command line switch for my tasmota.
Switch:
platform: command_line
switches:
BEDSWITCHBACKUP:
command_on: "/usr/bin/curl -X POST http://10.0.0.10/cm?cmnd=Power%20Toggle"
command_off: "/usr/bin/curl -X POST http://10.0.0.10/cm?cmnd=Power%20Toggle"
command_state: "/usr/bin/curl -X GET http://10.0.0.10/cm?cmnd=Power"
value_template: '{{ value == "1" }}'
friendly_name: BEDSWITCHBACKUP
The on and off commands work, but the command_state always reverts to OFF after toggling, I want it to assume the state of the switch (i.e blue for ON and gray for OFF ), which is either on or off, Toggle changes the state.
Using “http://10.0.0.10/cm?cmnd=Power” directly on the URL line will display { “POWER” : “ON” } of {“POWER” : “OFF”} depending on whether the switch is on or off. It seems command_state interprets them the same way.
How do I convert { “POWER” : “ON” } and {“POWER” : “OFF”} outputs into 1 and 0, which command_state in HA will understand and flag the switch appropriately, I have tried commenting out the value_template but the results are similar retaining the ON status after toggling .