Configuration Template. How To convert F to C on temperature?

@mike0xt @ehbush You guys are making this harder than it needs to be. Just change the unit_of_measurement to anything but ºF or ºC. Those unit of measurements cause it to translate.

You mean like this? Temperature unit is not a parameter for platform: systemmonitor. It’s coded to use system configuration units.

  - platform: systemmonitor
    resources:
      - type: disk_use_percent
      - type: processor_use
      - type: memory_use_percent
      - type: swap_use_percent
      - type: processor_temperature
        unit_of_measurement: 'K'    #This will not work for this module.
      - type: last_boot

My workaround for the inflexibility of temperature units in systemmontor platform is to use the command_line platform pulling from /sys/class/thermal as many have done. My temperature sensors move around every boot, and the command I posted earlier did not work (Command failed). I think the problem is the use of the curly brackets { } and/or the single quotes ’ ’ in yaml. I didn’t know how to escape them in that particular string. What finally worked for me was to use /bin/bash and use the cut command:

command: /bin/bash -c "paste <(cat /sys/class/thermal/thermal_zone*/type) <(cat /sys/class/thermal/thermal_zone*/temp) | grep TCPU | cut -c6-10"

This tabulates out the sensor names and temperatures in my /sys/class/thermal/ and picks out just the sensor that is named “TCPU” on my system to finally read out the value.

This is no longer working for me. I tried ºC and ºF and C and F and nothing. The octoprint web page shows everything in C and on HA I have everything in F. But for 3d printing C is used, so I want to display this to ºC. I don’t care how the value is internally stored, because I’m not doing anything with it.

Yep. Broken. I filed a bug report on Lovelace (thinking that it was a lovelace issue) but I may file one or see if one has been filed on core.
I run Home Assistant OS, core-2021.11.5. If I add

sensor.octoprint_tool_0_temperature:
  unit_of_measurement: '°C'

to customize.yaml and reload core, the displayed is some whacky number. In Farenheit, it should be ~464 farenheit. But with that unit of measurement change, its showing as 866.8 °F. BTW, it does not matter if I use single quotes or not.

Hey mfratto, fellow imperial user with the same issue, trying to get C out of a sensor for my 3d printers.

We are having the opposite issue here.

As our system is set to imperial, we are getting the sensor temps in F.

HOWEVER, if we set unit_of_measurement: ‘°F’ we get nothing as our system is already in F.

And of course when we go unit_of_measurement: ‘°C’ our system is taking the reading from the sensor and converting that to C.

For example right now my sensor is at 51F and is showing 124 when the config is set.

image

Keep in mind the F in the graph can be changed in the UI, it is just showing system norms.

It appears for us we are going to need something along the lines of the more complicated route showed above.

@Dangck @alpharesearch we’re discussing the same issue over here as the issue seems to be due to the 2021.9.0 upgrade.

I see @mfratto opened an issue on GH for this, but no one has touched it since opening other than a comment to create template sensors which I really don’t think is good solution…

I wonder if someone tried to end the confusion by recognizing C as °C and F as °F. I would try using something like Cel, *C, *F or Far as the units of measurement if I wanted to avoid automatic conversion. I have used templates in the past to convert temperatures manually. The trick is to make sure HA doesn’t recognize the unit of measurement you set and it won’t convert it.

Perhaps at some future point there will be an option in a template or a card that allows you to specify when you want to to display a different unit of measure from your default.

1 Like

Everything is moving that direction… sounds like we might need this as a month of WTH if it ever shows back up.

1 Like

Thank you!!! Just tried a bunch of conversions for an Accurite sensor, no luck. This is simple and works perfectly!

1 Like