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.
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) }}’
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!
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.
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.
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.
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: "