Statistic for CPU Temperature?

I have configured several Pi servers in my house to send their CPU temperature and other data to Home Assistant. I then added a statistics graph in Home Assistant dashboard to show the CPU temperatures over the last day. All good. But I want to add the CPU temperature of the Home Assistant Raspberry Pi. This is not available as a “Statistic”. The documentation states that is because the provider has not configured their sensor correctly and I should open a ticket with them, but I believe that the Home Assistant CPU temperature will be from Home Assistant

Is there something that I can do locally to track the temperature of the CPU on the Pi that is running Home Assistant, in a statistics graph on a dashboard in Home Assistant?

Thank you for your help.

Use customize to add the following to your CPU temperature sensor:

sensor.cpu_temperature:
  device_class: temperature
  state_class: measurement

Then open an issue here stating that the sensors do not have the appropriate device classes:

Don’t ask for them to be added, that’s a feature request and will be closed. Write it up as an issue with the systemmonitor integration.

Thank you for your help. II went into Developer Tools > States, found the cpu_temperature, edited it to add the state_class and device_class, and saved that change.

It appears that HA does not like that, as it always reverted back within 60 seconds. Is there another way to set this that will make it stick?

I will put in that change request today

Thank you

Nope. That is not how you do it, those changes are not permanent. Look at the manual customize section in the link I posted.

I just looked at my configuration.yaml. I now remember that the cpu_temperature was added manually by me a few months ago. The snippet below is what I had added.

sensor:
  - platform: command_line
    name: cpu_temperature
    command: "cat /sys/class/thermal/thermal_zone0/temp"
    unit_of_measurement: "°C"
    value_template: "{{ value | multiply(0.001) | round(1) }}"

But adding the device_class and state_class as below results in a fail when testing if the config is OK for restart. I will see if I can find some logs.

sensor:
  - platform: command_line
    name: cpu_temperature
    command: "cat /sys/class/thermal/thermal_zone0/temp"
    device_class: temperature
    state_class: measurement
    unit_of_measurement: "°C"
    value_template: "{{ value | multiply(0.001) | round(1) }}"

You can’t just add any option to an integration configuration. Look at the docs:

Those options are not there.

For the last time: you must use manual customize as per the link.