Occasionally I look through my homeassistant.log file to determine if there is any error or warning that I can fix. Usually a notation to update my configuration.
Now I am noticing a “Please update your configuration” warning. (It’s not new, I just hadn’t noticed it before now).:
2023-01-05 18:47:36.551 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.freezer_temperature_c (<class 'homeassistant.components.esphome.sensor.EsphomeSensor'>) is using native unit of measurement 'C' which is not a valid unit for the device class ('temperature') it is using; Please update your configuration if your entity is manually configured, otherwise create a bug report...
In esphome, this works except for the warning in the log file:
Deciphering the warning and reading the platform notes, I gather that the DS18b20 outputs centigrade, so the “unit_of_measurement: C” is not needed. I commented this line and now the state of sensor.freezer_temperature_C is fahrenheit?
I forgot that, but it doesn’t change the value, just what is displayed.
Maybe this should be a different thread…
I’ve seen other posts about not being able to control the units, but I hadn’t paid much attention to them because all of my temperature sensors are showing Fahrenheit on my Lovelace cards. I set up a simple test on my desktop, a Wemos D1 Mini and a Dallas DS18b20 sensor.
[D][dallas.sensor:143]: 'Temperature': Got Temperature=6.7°C
[22:41:19][D][sensor:126]: 'Temperature': Sending state 6.68750 °C with 1 decimals of accuracy
So the Dallas is sending temperature in °C.
I added: unit_of_measurement: ‘°C’ and the ESPHome logs said:
[D][dallas.sensor:143]: 'Temperature': Got Temperature=6.6°C
[22:39:18][D][sensor:126]: 'Temperature': Sending state 6.56250 °C with 1 decimals of accuracy
It matters not if I have unit_of_measurement: ‘°C’ or unit_of_measurement: ‘°F’, or no unit_of_measurement, the ESPHome Logs say the same.
But in a Lovelace card, it gets converted to Fahrenheit no matter what Unit I put into the card GUI.
type: entity
entity: sensor.temperature
name: Temperature
unit: ºC