I am trying to convert a F temperature sensor value to a new C temperature sensor. I have the following code that I am trying, but it only sets the sensor value to the F temperature comes from the original sensor.
If I take the template string to the template developer, it converts the F value to the correct C value. For some reason the sensor code does not put the correct value in the new sensor.
Yes, it’s really weird.
I’ve restarted many times without any change.
no other references to my sensor “octoprint_bed_temp_celsius” anywhere that I can find
No errors in config check or in the log…
All I want to do is report the temperature in Celsius instead of the Fahrenheit value received from the “sensor.octoprint_actual_bed_temp” - not really to complicated I didn’t think…
Tried several other ideas but nothing works. It seems that Octoprint’s output is Celsius and since I have unit_system: imperial, Hassio automatically converts it to Fahrenheit and assigns a “Unit of measurement= °F” to the sensor. If I change the unit_system to metric, the proper °C value is brought in to HA, but I have many other sensors that are imperial that get converted automatically to metric, and I don’t want that.
I have tried to change the Unit of measure to °C, but HA wont change it to °C.
Like I stated earlier, I can get a template to convert correctly in the template editor, but in my configuration, it doesn’t do the math, it just assigns the value from the source sensor and assigns a unit of measurement of °F.
I am having the same issues. I am in the United States so we typically use F for our unit of measurement. How ever I use C for my 3d printer in Octoprint and would like it to display in C if possible. Was wondering if you figured this out.
Since you are able to get a set of “default” sensors with the Octoprint integration, you just need to put in your customize.yaml file the following (make sure on the single quote around the C). It does the conversion for you. I couldn’t believe how easy it was once I found the correct format.
sensor.octoprint_actual_tool0_temp:
unit_of_measurement: 'C'
friendly_name: Nozzle Temperature
icon: mdi:thermometer
Sorry a total noob. but do I just create a file in Configurator and name it customize.yaml? Also do I have to add anything to my configuration.yaml to get the value of the sensor that is placed in the customize.yaml.
I just wanted to thank you guys because I have been going around pulling my hair out for months with this exact same issue until I dug deep enough in the Google results to find this thread.
I kept finding people either making template sensors or claiming that Home Assistant could convert it on its own and having no luck no matter how many places I specified the unit of measurement.
The thing that finally fixed it for me was the realization that Home Assistant requires you to specify the unit of measurement as ‘C’ and not ‘°C’. I’m not sure why they don’t think Celcius is measured in degrees, but everything started working as soon as I got the unit typed correctly.
I had the same problem, when I wanted to display temperatures in F for my wife and in C for me. My system is set to F, so I created template sensors to convert temperatures to C, however, in the frontend they were still displayed as F.
It took me a while to figure out that when HA is set to one unit system and it finds values in the other system, it automatically converts them. My solution was to define unit_of_measurement as C (without the degree sign) instead of °C. That way HA doesn’t recognize them as temperature and doesn’t convert them back.
Thanks for this! I came here searching for temperature conversion override for exactly the same reason: wanting to look at equipment temps for my Prusa i3 in degrees C, while everything in my ‘normal’ life is degrees F.
While overriding it to a generic ‘C’ for units instead of a temperature value gets it to display correctly, I definitely think it’s a very useful feature to be able to opt out of autoconversion for a particular sensor rather than having to hack it like this. I voted for the feature request and if you agree, you might want do so as well.
I don’t see anything wrong with what you have . Not sure why it is not working for you. I just checked mine and it still the same as what I put in the post above. Mine still works just fine.
Did you restart after adding it to your customize.yaml?