I’m trying to set up a command_line
sensor for monitoring the hardrive temperature on the host of HASS.io .
I’m running Hass.Io on a Intel NUC running Debian.
- platform: command_line
name: HDD Temp
command: "smartclt -A /dev/sdb | grep Temperature_Celcius | awk '{print $10}'"
unit_of_measurement: "°C"
But it’s not working at all.
How does command_line sensor and shell_command work when HassIO runs in this way?
I’m thinking that I maybe need to ssh from the hassio container to the host operating system and then run the command?
Any ideas?
1 Like
I’m using shell scripts via cron to publish values to mqtt on local or remote hosts.
In HA i show the values with the MQTT Sensor
lolouk44
(lolouk44)
July 19, 2018, 12:29pm
3
What does your log say?
I’m not familiar with smartctl command. Any chance it requires su privileges?
Alternatively I’ve personally taken the same approach as @VDRainer
When I run the smartctl command from debian host I have to use sudo yes.
I could try to disable the sudo password and see if “sudo smartctl …” works.
Otherwise I think I will try @VDRainer and yours solution with cron and MQTT, sounds neat.
Not luck with using sudo
and disabling sudo password on the host.
I guess I have to go with cronjob+mqtt solution.
But I still would like to understand how to get command_line sensor to work on HassIO!
I managed to get it working at last!
Basicly I set up an ssh connection from the home assistant docker container to the host system. Followed this guide, https://megamorphf.github.io/homeassistant/hyperion/ssh/hassio/2018/01/22/controlling-anything-via-ssh.html , except for the first part as I’m running on a NUC through debian and already have access to the operating system.
This is final configuration:
- platform: command_line
name: HDD1 Temperatur
command: "ssh -i /config/ssh/id_rsa -o StrictHostKeyChecking=no [email protected] sudo smartctl -A /dev/sdb | grep Temperature_Celsius | awk '{print $10}'"
unit_of_measurement: "°C"
Works as a charm!
3 Likes
myca5a
(Myca5a)
May 27, 2020, 1:53pm
7
Trisk3lion:
smartctl
Hello,
Can you help me ?
I will wish to obtain the temperature from another raspberry.
- platform: command_line
name: Température_Raspberry
scan_interval: 300
command: ssh -i /config/.ssh/id_rsa -o StrictHostKeyChecking=no -q [email protected] sensors
unit_of_measurement: '°C'
Not working
However in the terminal on my HA :
ssh -i /config/.ssh/id_rsa -o StrictHostKeyChecking=no -q [email protected] sensors
works !
Best regards
Trisk3lion:
command_line
Does it help if you put the command in double quotes (“…”) or single (‘…’)?
- platform: command_line
name: Température_Raspberry
scan_interval: 300
command: "ssh -i /config/.ssh/id_rsa -o StrictHostKeyChecking=no -q [email protected] sensors"
unit_of_measurement: '°C'
myca5a
(Myca5a)
May 27, 2020, 2:23pm
9
The same.
I don’t understand, but in the raspberry logs (/var/log/auth.log)
Failed password
In my HA logs : Command failed