CPU temperature via SSH only read once after restart

Hi,
I’m running HA in Proxmox in the following version:

  • Core 2024.10.1
  • Supervisor 2024.09.1
  • Operating System 13.1
  • Frontend 20241002.2

I’ve followed this guide to read the CPU temperature from my Proxmox machine:
https://community.home-assistant.io/t/how-to-monitor-proxmox-cpu-temp/245050

The implementation in my configuration.yaml looks like the following:

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

When I execte the comamnd in the HA terminal, I’m getting a correct return value:

As far as I got from the documentation of the command_line, the value will be refreshed every 1 minute.
Unfortunately, mine is only reloaded, when I restart HA.

After a lot of testing and searching, I’ve no idea, what is the issue here.

Has anyone an idea what is wrong with my configuration?

Hi, welcome to the forum!

Have a look at this, it might be much more easier to achieve what you want: System monitor - Home Assistant

scan_interval: 100

You could add in a scan interval.

https://www.home-assistant.io/integrations/command_line/#execution

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

Try this.

Thanks for the welcome :slight_smile:

As my HA is running in Proxmox, the integration does not work for the cpu temperature:

Thanks for the proposal.
I’ve tested the code, but it does not work.
I tried it with the scan intervall.

Can I see anywhere if there are any errors occurring?

I’ve installed the add-on " Terminal & SSH" and used this for the execution of the command.
Have I been testing the right way?

Below my configuration.yaml
Might there anything interfere with the command_line?

# Loads default set of integrations. Do not remove.
# default_config:

backup:
assist_pipeline:
#bluetooth:
config:
conversation:
counter:
#dhcp:
#energy:
hardware:
history:
#homeassistant_alerts:
#cloud:
#image_upload:
input_boolean:
input_button:
input_datetime:
input_number:
input_select:
input_text:
#logbook:
logger:
#map:
media_source:
#mobile_app:
#my:
#network:
#person:
schedule:
#ssdp:
#stream:
#sun:
system_health:
#tag:
timer:
usb:
#webhook:
zeroconf:
zone:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes
  extra_module_url:
    - /config/www/community/lovelace-card-mod/card-mod.js

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

influxdb:
  host: a0d7b954-influxdb
  port: 8086
  database: homeassistant
  username: grafana
  password: xxxpwxxx
  max_retries: 3
  default_measurement: state
  exclude:
    domains:
      - automation
      - button
      - camera
      - input_number
      - media_player
      - number
      - person
      - script
      - select
      - switch
      - update
      - vacuum
      - zone

  ignore_attributes:
    - device_class
    - state_class
    - icon

sensor:
  - platform: influxdb
    host: a0d7b954-influxdb
    port: 8086
    username: grafana
    password: xxxpwxxx
    queries:
      - name: InfluxDb Database Size
        unit_of_measurement: MB
        value_template: "{{ (value | float / 1024 /1024) | round(1) }}"
        group_function: sum
        measurement: '"monitor"."shard"'
        database: _internal
        where: "time > now() - 10s"
        field: diskBytes

No there’s no problem there.

The problem is that when you test the command in the terminal you are executing the command in the terminal docker container. When using the command in Home Assistant you are executing the command in the homeassistant container.

If you run this in the terminal before testing your command

docker exec -it homeassistant bash

then it will be executing in the homeassistant container. (type exit to leave the container after testing your command).

Is there any reason you are not using the System Monitor integration to measure this temperature?

It would be much easier:

I’m running HA on Proxmox too.

The disk & memory data are from the container.
CPU usage is definitely from my host.

I’ve tried again to us System Monitor. But the Processor temperature ist not available:
Bildschirmfoto_2024-10-09_21-40-25

Is there any possibility, that I can refresh the command_line sensor with a fixed rate via an automation?

Apparently this is because of using HAOS whereas I’m using HA Core.

Why did you choose HA core instead of HA OS?

Containers were a hot item and a way to have many virtual machines so I used the RPi way of setup.
Also, my system was limited on RAM so I went for Core and as a challenge to learn new stuff.
When I started with HA, HAOS was not at the level as it is now.
Now, I also have VM with HAOS as a test but I keep using Core for now and we’ll see.

A few tips:

  • one of the valued community members @tteck has created a lot of useful scripts for Proxmox with various ways to install HA
  • it’s quite easy to use a backup from HA to start with another setup
  • use the backup function of Proxmox extensively to secure your HA setup, it’s one of the BIG advantages. Additionally, move these backups to another location/system

Rather than re-installing HA, there’s a helper script for proxmox that installs glances.

Proxmox VE Helper-Scripts (search for glances).

Then use the glances integration in home assistant.

This is how I get the cpu, memory and temp from my proxmox camera NVR.

2 Likes

Thank you for this tip Tom!
Learned something new and TBC my tip on (re)installing was not meant as a solution.

1 Like

Thank you very much! I got this working with Glances…

1 Like