So I’ve got my system set up and I’ve been messing with it for a few days solid. I’ve figured out how to use a command_line platform in sensors to generate a CPU temperature sensor. When the cat /sys/devices/virtual/thermal/thermal_zone0/temp happens the result is usually around 49 (which is in Celsius). I defined the sensor like this:
- platform: command_line
name: CPU Thermal Zone 0
alias: cpu_thermal_zone_0
command: "cat /sys/devices/virtual/thermal/thermal_zone0/temp"
value_template: '{{ value | int }}'
I fully expected to see this show up in my display as 49°C but it doesn’t, it shows up as a bare number. I want to have °C appended, so I tried:
Using:
unit_of_measurement: 'Metric'
unit_of_measurement: Metric
unit_of_measurement: '°C'
unit_of_measurement: °C
All the above options (after restarting hass.io) yield a value converted to Fahrenheit dimension and is displayed with °F units! I’m not performing any deliberate conversions on it… what gives?
If I use these:
unit_of_measurement: 'Celsius'
unit_of_measurement: Celsius
It results in the bare number from the file with the word “Celsius” after it, like 49 Celsius. Not quite what I’m after either. How can I get this thing to not do a conversion and append the proper units? I’m struggling here and this seems like it should be pretty straight forward.
Hi Coolie1101, I didn’t see that section of the docs. I was very hopeful. I tried it but it still gives me “°F”, and now the value reported is neither the value from the “cat” command nor the Fahrenheit conversion…
Shouldn’t there be a hierarchy in the selection of units and the global Metric/Imperial selection should be the least significant? I would expect to be able to force the units at the entity definition or customization to be able to override the global selection. Is that not possible?
It’s represented in °C from the command line but it’s converted to °F, likely because of the configuration.yaml’s Imperial setting. I just thought that the global should be override-able.
Same surprise here.
I expected to use ‘unit_of_measurement’ to describe how the value should be presented in the UI, but instead it turns out to mean how the value is to be interpreted, and then the UI just presents it using the global setting for locale. Not what I expected, or wanted.
I display the outdoor temperature in Fahrenheit (because my locality references it that way), but I wanted to display CPU temperature in Celsius (because the sane part of the world refers to it in that manner). But the UI (unexpectedly) did the C-to-F math on the number and displayed it in Fahrenheit, removing my ability to display a Celsius temperature alongside a Fahrenheit one.
Perhaps the line in the docs could be clarified about what that parameter is going to do.