I can’t get the command_state in the command line switch to work.
switch:
platform: command_line
switches:
test:
command_on: './test.sh on'
command_off: './test.sh off'
command_state: './test.sh state' #will return 0 if on and 1 if off
The command_on and command_off both work as expected but not the command_state. I’ve tried hard coding return values but it doesn’t matter, and the logs says nothing.
I’ve tried both “echo 0” and “exit 0” in my bash script without success.
Run your script from the command line (SSH) to make sure it works and you’re getting the expected output. Also make sure to run the script as the user hass/homeassistant, as that is exactly what Home Assistant will do.
Check the home-assistant.log file in your .homeassistant folder for errors.
Search your system’s syslog file for related messsages with a command like cat /var/log/syslog | grep test.sh or cat /var/log/syslog | grep switch.test or …
Been playing around with just about everything, so I’m not sure exactly what did what
If not using value_template it works with 0 and 1, and if using value_template the script works when using “echo 1” instead of “exit 1” and {{ value == “1” }} instead of {{ return_ value == “1” }}.