How to show the Raspberry Pi CPU temperature?


#41

System monitor shows the cpu temperature for RPi? I don’t see it under configuration variables.


#42

No system monitor does not include CPU temperature. Use this 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) }}'

And for the GPU:

- platform: command_line
  name: GPU Temperature
  command: "/opt/vc/bin/vcgencmd measure_temp"
  unit_of_measurement: "°C"
  value_template: '{{ value | replace("temp=", "") | replace("''C", "") }}'

#43

On my system (Raspbian Release 9.6, Kernel version: 4.14) I do not have this command…


#44

Any time I use the degree symbol in my yaml, like:

unit_of_measurement: “°C”

I get an error:

Error loading /config/configuration.yaml: ‘utf-8’ codec can’t decode byte 0xb0 in position 2830: invalid start byte

It works fine if I leave that line out.


#45

Try using different quotes. Single quotes work, also note the difference between your double quotes and the ones below.

unit_of_measurement: '°C'

unit_of_measurement: "°C"


#46

I tried both kinds of quotes, no difference. The double quotes only looked wrong here in the forum because I quoted the line instead of using a code block like I should have.

I also verified that I’m using ASCII character decimal 176, xB0.

If I delete just that one character, the config checks OK. If I re-add it, I get the error again. I’ve already moved on, not worth worrying about. I used legit’s method of displaying in F, which works fine.


#47

Use notepad++ and make sure the format of the file is UTF8… Sometimes it changes to western or something like that…


#48

Bingo!! Changed it to UTF8 and no more errors. Thanks!!!


#49

Yeah that error is a bastard to track down.


#50

Any reason you don’t do this within the customise section in GUI?


#51

Do what specifically?


#52

To set a unit of measurement:


#53

It works for HassOS.