CPU Temperature of VM host

Hello!

I’m trying to get the CPU Temperature of my VM Host in Home Assistant.
This command I came up with works perfectly when executing within the HA Terminal:
ssh -o LogLevel=QUIET [email protected] -i /config/.ssh/id_rsa -t "sensors | grep -i package | grep -o 'Package id 0: +[^;][^;]' | grep -o '[0-9][0-9]'"
however when I add it to the config like this it’s not working anymore:

sensor:
  - platform: command_line
    name: CPUTemp
    command : "ssh -o LogLevel=QUIET [email protected] -i /config/.ssh/id_rsa -t \"sensors | grep -i package | grep -o 'Package id 0:  +[^;][^;]' | grep -o '[0-9][0-9]' \" "

Would you consider using something like Glances on the host, and then using the integration to get the values? This will give you CPU temps plus much more. Alternatively, if your host is running Proxmox, there’s a HACS integration that provides this plus more.

1 Like

I’m using this to get the CPU temperature from my VM host (Proxmox):

command_line:
  - sensor:
      name: temperature_cpu
      command: 'ssh -i /config/.ssh/id_rsa -o StrictHostKeyChecking=no -q [email protected] cat /sys/class/thermal/thermal_zone0/temp'
      value_template: "{{ value | int / 1000 }}"
      unit_of_measurement: "°C"
      scan_interval: 600
1 Like

Thanks for your script. When I add that to my “/homeassistant/configuration.yaml” and restart nothing happens, I don’t get any messages in “System/Logs” but also no sensor :frowning:

command_line:
  - sensor:
      name: temperature_cpu
      command: 'ssh -i /config/.ssh/id_rsa -o StrictHostKeyChecking=no -q [email protected] cat /sys/class/thermal/thermal_zone0/temp'
      value_template: "{{ value | multiply(0.001) | round(1) }}"
      unit_of_measurement: "°C"
      scan_interval: 300

Again, runing the comand in the HASOS Terminal works like expected…

Update: Restarting 10x somehow resolved it - many thanks!

1 Like

i measure and report utilisation and temperature of my virtual server via smtp.

sensor:
  - platform: snmp
    version: '2c'  
    community: *passwd*  
    host: 192.168.6.4
    baseoid:  .1.3.6.1.4.1.24681.1.3.1.0           # integer
    name: host_cpu_load
    unique_id: ea9adc57b8de4c0486fd 
    unit_of_measurement: '%'

  - platform: snmp
    version: '2c'  
    community: *passwd*
    host: 192.168.6.4
    baseoid:  .1.3.6.1.4.1.24681.1.3.5.0           # integer
    name: host_cpu_temperature
    unique_id: ea9adc57b8de4c0486fe 
    unit_of_measurement: '°C'