I am trying to get a Command Line Switch to work. My ultimate goal is to trigger a shell script via SSH on another server to do something.
I can use sensor to read something (e.g. uptime) from a server via SSH, so i got that going - had cost me already quite some time.
Now I am trying to get a button/switch working, but it won’t work right.
After a lot of back and forth without really understanding what I am doing, I got this
command_line:
- switch:
name: OnOffSwitch
unique_id: switch.cli.OnOff
command_on: "echo 1 > /config/servercontrol.status"
command_off: "echo 0 > /config/servercontrol.status"
command_state: "cat /config/servercontrol.status"
value_template: '{{ value == "1" }}'
I could toggle the switch once and then it stopped working somehow.
My two (first) questions would be:
-
Should this work in general or am I missing something? (Apart from the icon)
-
Can someone explain the value_template to me? I read the documentation, but i still don’t understand how it works. Does it result to “ON/TRUE” when the condition (in my example value==1) evalutes TRUE? Or what is the logic?
Thank you!