Hi!
I am playing around with a switch that executes commands via ssh:
switch:
- platform: command_line
switches:
pellet_stove:
command_state: "/usr/bin/ssh -i /config/sshkeys '[email protected]' '/var/www/html/ofensteuerung/scripts/sendData.sh RD90005F'"
command_on: "/usr/bin/ssh -i /config/sshkeys '[email protected]' '/var/www/html/ofensteuerung/scripts/sendData.sh RF00405C'"
command_off: "/usr/bin/ssh -i /config/sshkeys '[email protected]' '/var/www/html/ofensteuerung/scripts/sendData.sh RF000058'"
Those commands work for turning on and off, but i down know how to parse the return of the command_state in a value_template. I would present you some examples, maybe you can help me.
The command:
bash-5.1# ssh '[email protected]' '/var/www/html/ofensteuerung/scripts/sendData.sh RD90005F'
2010023&
bash-5.1#
Most of the return doesn’t matter but the first shown digit (here “2”) shows the state:
0 > off
1 > on
2 > on
4 > on
8 > off
But we have to be careful! The full return is actually more. The normal output does not show these characters, but they are sent back:
bash-5.1# ssh '[email protected]' '/var/www/html/ofensteuerung/scripts/sendData.sh RD90005F' > text.txt
bash-5.1# cat -t text.txt
^[02010023&^M
bash-5.1#
So i essentially need to check, if the third returned character is 1,2,4 for on or 0, 8 for off. Any idea?
Best regards
Pascal