I have a Pi3 with HA OS, and a Pi0 with a temperature sensor.
On the Pi0 I created a python script which prints the sensor numeric reading only.
On HA OS I created SSH keys with ssh-keygen
, then copied the content of ~/.ssh/id_rsa.pub in ~/.ssh/authorized_keys on the Pi0.
I verified I can SSH into the Pi0 from the HA OS command line, without password prompt.
I also verified I can execute correctly the python script on the Pi0 from HA OS, with the command:
ssh pi@PI_IP -p PI_SSH_PORT 'python3 /home/pi/Scripts/SCRIPT_NAME.py'
However, if I set this command line sensor on HA OS configuration.yaml:
sensor:
- platform: command_line
name: sensor_name
command: "ssh pi@PI_IP -p PI_SSH_PORT 'python3 /home/pi/Scripts/SCRIPT_NAME.py'"
unit_of_measurement: "°C"
I get a simple error message in the log:
2021-11-08 00:14:07 ERROR (SyncWorker_7) [homeassistant.components.command_line] Command failed: ssh pi@PI_IP -p PI_SSH_PORT 'python3 /home/pi/Scripts/SCRIPT_NAME.py'
Am I missing something?
Thanks