Command line CPU Temperature

I’m using ‘command_line’ platform to check the temperature of my CPU (Core i3-7100).
I found out, it’s not really moving anywhere, even if the CPU is running on 98% for long period.
It’s stucked at 27.8 Celsius.
Here is the last 16 hours. No chance it didn’t change a tiny bit…

I’ve checked the temperature in command line using lm-sensors.
04
Noticed the machine has Virtual device temperatures. Might be because of the virtualenv I installed HA to.
These 75 Celsius degrees seems much more realistic to me.

I’m using this configuration:

  • platform: command_line
    name: CPU Temperature
    command: ‘cat /sys/class/thermal/thermal_zone0/temp’
    unit_of_measurement: ‘°C’
    value_template: ‘{{ value | multiply(0.001) }}’

Do you guys have any advice?

The default scan_interval for a command_line sensor is 60 seconds. So, in theory, the temperature should be updated every 60 seconds.

Try setting it to 30 seconds and see if it makes any difference.


EDIT

On second thought, what is the output of cat /sys/class/thermal/thermal_zone0/temp? Is it a numeric value, like 75, or a long string of text, or worse, multiple long lines of text?

The sensor needs to receive a numeric value, otherwise this template will fail:
{{ value | multiply(0.001) }}

Imagine it gets something like +75°C and then tries to multiply that by 0.001. Won’t work!

no point on changing scan_interval. it’s 27,8 for 16 hours, as I mentioned.

cat /sys/class/thermal/thermal_zone0/temp was this:
09

OK.

If you’re getting one good reading (27.8), then it’s odd that it fails to get other, different, good readings … unless cat /sys/class/thermal/thermal_zone0/temp was always reporting the same value! I realize that seems improbable but it should be tested and confirmed. Load the CPU and take random readings to confirm the command reports changing values.

If it does indeed report changing values then we’re back to a possible glitch with scan_interval.

here is another scan, I made with lm-sensors.

27.8 Celsius again, for temp1 as I mentioned, it might be connected to the Adapter: Virtual device. Because Adapter ISA adapter is showing different values as it showed yesterday.
Not the scan_interval is the problem, but the source it’s getting the temperature from.

After reading the following thread, it would appear there are 101 ways of getting the temperature … and not all are successful.

Mine does exactly same with it cpu still haven’t figured it out to work

using cat /sys/class/thermal/thermal_zone0/temp on my RPI3 and it works fine, updates around once per minute i think

Can you show me how lm-sensors look for you?

I think I figured it out. ran cat /sys/class/thermal/thermal_zone*/temp, and I found it shows me the real adapter, I was trying to read, the whole time.

I believe the “Virtual device” adapter is a fake CPU temperature, and it never changes.
Pushed my CPU to 100% process again, and it didn’t change, but ISA adapter did.

Assuming in the original command we were reading zone0, and zone* showed me several values, I started experimenting, till I found zone2 is the value I want to see.

And voile:

Pretty sure I made that precise suggestion in a previous post. Yet that one wasn’t solution-worthy?

got mine working using

cat /sys/class/thermal/thermal_zone2/temp

I have added the following to the config file but hassio did’nt recongize it. It can’t find the binary sensor. What is the problem?

binary_sensor:
  - platform: command_line
    name: CPU Temperature
    command: ‘cat /sys/class/thermal/thermal_zone1/temp’
    unit_of_measurement: ‘°C’
    value_template: ‘{{ value | multiply(0.001) }}’

Replace all the quotes with standard quotes.

Currently, your example is using this kind of quote:

You should replace all of them with a standard single-quote:
'
or with a standard double-quote:
"

thank you so much it works now like a charm!!!

Can you please send me the HTPC configuration?