I have been trying for some time to build a binary sensor that will show me the status of a remote SSH command. Maybe it’s because I just don’t understand it or I’m too stupid.
What I want is actually quite simple but apparently not so easy to implement.
In openHAB I used the “EXEC Binding” which created a switch that showed me with “ON” the command was running and changed to “OFF” if the command was executed.
I need the same or a similar procedure again to run my automated server updates.
Here’s my code:
# Update Sensors
- platform: command_line
command: ssh -i /config/.ssh/id_rsa -o 'StrictHostKeyChecking=no' [email protected] 'sudo apt update && sudo apt upgrade -y'
command_timeout: 0
device_class: running
name: TVH Update
icon: mdi:update
payload_on: Running
payload_off: Sleep
If then I execute the command in the terminal, the sensor should start or not?