Hddtemp command line sensor

i am trying to monitor my hd temps with home assistant but when i do this with a command line sensor i am getting an error. i can run this command in the command line and it works but not when i use home assistant sensor. any ideas?

- platform: command_line
  name: HDB Temperature
  command: "hddtemp -n /dev/sdb"
  unit_of_measurement: "°C"

2017-07-13 17:47:23 ERROR (Thread-22) [homeassistant.components.sensor.command_line] Command failed: hddtemp -n /dev/sdb

Try putting the full path to hddtemp.

I tried

/usr/sbin/hddtemp -n /dev/sdb

but this also failed.

does it have to do with permissions?

you may have to do …

sudo visudo

and add …

homeassistant ALL=NOPASSWD: ALL

So I did this and it still didn’t fix my issue. I am running homeassistant as mgranger so I am not sure ifor this matters but I tried switching this to mgranger and it still didn’t fix the issue so I am still stuck.

Hmmm OK, you can try …

homeassistant ALL=ALL: ALL

and/or put …

‘sudo /usr/sbin/hddtemp -n /dev/sdb’

and see if that works?

BTW you haven’t said what version you are running or what platform? I’m assuming 48.1, AIO installer and RPI3. Also I can’t run it from the command line without sudo, so I’m assuming you are running as root?

I tried homeassistant ALL=ALL:ALL but it had an error and wouldn’t let me save it. I did try using the sudo /usr/sbin/hddtemp -n/ dev/sdb but it still didn’t work

I am on 48.1 and used

$ pip3 install homeassistant
$ hass --open-ui

It is installed on ubuntu

Hmmm … I would put the command in a .sh file such as readtemp.sh …

#!/bin/bash
echo "Home Assistant running HDDTemp"
sudo /usr/sbin/hddtemp -n /dev/sdb

chmod the file so that’s it’s executable by everyone 777
and run it as a shell command instead of a switch command in HA.

Hmm that won’t work either :frowning:
However shouldn’t it be …

sensor:
  - platform: command_line
    name: HD Temperature
    command: "/usr/sbin/hddtemp -n /dev/sda"
    unit_of_measurement: "°C"

Hmm unless you have it in a separate senor.yaml?

I can’t test it as my hdd is not SMART enabled.

I think it is a permissions problem as I have to do sudo on the command to make it run on my hdd, although it then fails as its not a SMART drive.

I do have a separate sensor.yaml file.

How to get this working on Debian supervised??