CPU Temperature for quad core CPU

I am using Raspberry Pi 3 and testing another solution. I am moving to fitPC with Quad Core CPU.

On my Raspberry Pi, I use the following to monitor the CPU Temperature:

  - platform: command_line
    name: CPU Temperature
    command: "cat /sys/class/thermal/thermal_zone0/temp"
    # If errors occur, remove degree symbol below
    unit_of_measurement: "°F"
    value_template: '{{ (value | multiply(0.001) * 1.8 + 32) | round(1) }}'

The problem with my new fitPC is that there is no /sys/class/thermal/thermal_zone0/temp.
I have this:

user@HomeAssistant:~$ ls /sys/class/thermal/
cooling_device0  cooling_device1  cooling_device2  cooling_device3
user@HomeAssistant:~$

How can I measure and display the temperature for the quad core CPU? Anyone knows? The system thinks there are four CPUs, so maybe it will be four different temp sensors display?

Just make multiple entries … so just make four entries under “sensor:” like this:

  - platform: command_line
    name: Cooling Device 0
    command: "cat /sys/class/thermal/cooling_device0/temp"
    unit_of_measurement: "°F"
    value_template: '{{ (value | multiply(0.001) * 1.8 + 32) | round(1) }}'

just replace cooling_device0 with cooling_device1 then 2 and so on… just make sure to give each one a unique name.

Good suggestion, thank you but there is no temp file under any of cooling_device*:

user@HomeAssistant:~$ ls /sys/class/thermal/cooling_device0
cur_state  device  max_state  power  subsystem  type  uevent
user@HomeAssistant:~$ ls /sys/class/thermal/cooling_device1
cur_state  device  max_state  power  subsystem  type  uevent
user@HomeAssistant:~$ ls /sys/class/thermal/cooling_device2
cur_state  device  max_state  power  subsystem  type  uevent
user@HomeAssistant:~$ ls /sys/class/thermal/cooling_device3
cur_state  device  max_state  power  subsystem  type  uevent
user@HomeAssistant:~$

You’re going to have to explore a little - what about current_state… just try them out to see what’s there

You don’t say whether you installed HA on the base system or using the docker version.

Note that some of those sensors could be for the GPU and other devices, not just the CPU. You can find out which one by: cat /sys/class/thermal/cooling_deviceX/type

But after that, I don’t know… However, if you are using HA on a base system, then you could install lm_sensors (apt-get install lm_sensors), then from command line run: sensors -f

Note that it may return something like acpitz-virtual-0, that’s probably your CPU. Then you could filter out the results using a shell script and save it to a text file to read in. If you are continually monitoring the temp, then you can turn your shell script into a cron job.

Also, if using the docker version, you may not see “sensors” from it, you will need to run a command line to include it into the docker, which I never done.

All four show “Processor” type.

I installed Python Virtual Env.

I think you should be abe to access sensors from your venv, so go ahead and install lm_sensors:

sudo apt-get install lm_sensors
sudo sensors-detect
sensors -f

Then install ssh add-on and then ssh (or putty.exe) into your hass from another computer and type in:

sensors -f

That will tell you if it is accessible.

Then see if the following locations will tell your temps, I believe that is where “sensors” is reading the infomation…:

/sys/class/hwmon/hwmon*/device/temp*

Thank you.

I think I just found it. It looks like it is here: /sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon1/temp1_input

Not sure what is that pci0000:00 and 0000:00:18.3 folders, but looks like it shows me the temperature and it changes periodically.

Do you know what those folders are?

If you did sensors -f, at least one should show up as CPU, etc. In my case, it comes up as acpitz-virtual-0 (while others refer to the GPU, etc) and I have /sys/devices/virtual/hwmon/hwmon0/temp1_input. Note that “virtual” is common, so it is the CPU temp.

As far as the others, I’m not sure, but could be hard drives and other devices that have sensors.

If you want to monitor the temps as they change, from the command line type in
watch -d sensors -f
then compare with results with your HA command_line sensor.

I tried and got this:

user@HomeAssistant:~$ sudo apt-get install lm_sensors
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package lm_sensors
user@HomeAssistant:~$ 

Got it, it is lm-sensors

I installed it and when I run

It shows the same temp as I see in my file.

It did not create temp under

/sys/class/hwmon/hwmon*/device/

If you want to use the same path as before, you can just create a link to /sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon1/temp1_input with the same name you expected, make the destination direcory first, i.e.:

mkdir -p /sys/class/thermal/thermal_zone0
ln -s '/sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon1/temp1_input' /sys/class/thermal/thermal_zone0/temp

See:
https://www.cyberciti.biz/faq/creating-soft-link-or-symbolic-link/
https://www.cyberciti.biz/faq/howto-linux-get-sensors-information/

Interesting. After making some changes and rebooting this device a few times, I noticed that it does not show the temperature anymore. When I check, the location changed.

It was:
/sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon1/temp1_input
and now it is:
/sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon0/temp1_input

The folder name changed from hwmon1 to hwmon0. I guess this path will not work for me if I have to double check and change it in configuration file every time I restart my device.

Anything else I can do?