I’m trying to use a command line to determine the status of a process/service running on another computer.
I have mythtv backened running on a seperate server running linux.
I am running HA OS on an Intel Nuc.
When I run this command from Terminal (using Terminal & SSH official add-on) it works
"ssh -i /config/.ssh/id_rsa -o UserKnownHostsFile=/config/.ssh/known_hosts [email protected] systemctl show mythtvbackend | awk -F= '/^SubState=/ {print $2}'"
However when I run the same command from my mythtv_backend.yaml file in the command_line folder I am not getting the same results as I get from running in Terminal.
When run in terminal I get the result of “running” but from the .yaml file the result is “dead”
I’ve tried as a Binary Sensor and I get “off” as the result, which also is incorrect as the process/service is indeed running.
Here is my setup.
I have a command_line folder which contains my command line yaml files.
The command_line folder is referenced in my configuration.yaml file with:
command_line: !include_dir_merge_list command_line/
I know this is working as I created a cpu_temp.yaml file and used the sample sensor config shown in the Command Line docs to be sure I had things setup correctly.
My sensor configs are as follows:
Sensor:
- sensor:
name: "MythTV Backend Status"
command: "ssh -i /config/.ssh/id_rsa -o UserKnownHostsFile=/config/.ssh/known_hosts [email protected] systemctl show mythtvbackend | awk -F= '/^SubState=/ {print $2}'"
scan_interval: 60
Binary Sensor:
- binary_sensor:
name: "MythTV Backend"
command: "ssh -i /config/.ssh/id_rsa -o UserKnownHostsFile=/config/.ssh/known_hosts [email protected] systemctl show mythtvbackend | awk -F= '/^SubState=/ {print $2}'"
scan_interval: 60
payload_on: "running"
payload_off: "dead"