I’m using a DIY software to send MQTT Discovery for some of my temperature sensors. Initially, I used
"unit_of_meas":"C"
which “seemed” to work without issue until HA began Warning about “C” being not a valid entry, which if I remember correctly, at some point changed to Errors:
Logger: homeassistant.helpers.event
Source: helpers/event.py:355
First occurred: March 12, 2025 at 11:32:00 PM (81 occurrences)
Last logged: 3:37:49 PM
Error while dispatching event for sensor.homevisionxl_zigbee_tempgeneral to <Job track state_changed event ['sensor.homevisionxl_zigbee_tempgeneral'] HassJobType.Callback <bound method HomeAccessory.async_update_event_state_callback of <accessory display_name='TempGeneral' services=['AccessoryInformation', 'BatteryService', 'TemperatureSensor']>>>
Error while dispatching event for sensor.homevisionxl_zigbee_outside_temp to <Job track state_changed event ['sensor.homevisionxl_zigbee_outside_temp'] HassJobType.Callback <bound method HomeAccessory.async_update_event_state_callback of <accessory display_name='Outside Temp' services=['AccessoryInformation', 'BatteryService', 'TemperatureSensor']>>>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 355, in _async_dispatch_entity_id_event
hass.async_run_hass_job(job, event)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 940, in async_run_hass_job
hassjob.target(*args)
~~~~~~~~~~~~~~^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/homekit/accessories.py", line 514, in async_update_event_state_callback
self.async_update_state_callback(new_state)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/homekit/accessories.py", line 538, in async_update_state_callback
self.async_update_state(new_state)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/homekit/type_sensors.py", line 138, in async_update_state
temperature = temperature_to_homekit(temperature, unit)
File "/usr/src/homeassistant/homeassistant/components/homekit/util.py", line 442, in temperature_to_homekit
return TemperatureConverter.convert(temperature, unit, UnitOfTemperature.CELSIUS)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/util/unit_conversion.py", line 99, in convert
return cls.converter_factory(from_unit, to_unit)(value)
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/util/unit_conversion.py", line 547, in converter_factory
return cls._converter_factory(from_unit, to_unit)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/util/unit_conversion.py", line 602, in _converter_factory
raise HomeAssistantError(
UNIT_NOT_RECOGNIZED_TEMPLATE.format(from_unit, cls.UNIT_CLASS)
)
homeassistant.exceptions.HomeAssistantError: C is not a recognized temperature unit.
In order to clean up the Warnings/Errors, I tried changing it to
"unit_of_meas":"°C"
but get this complaint:
Logger: homeassistant.components.mqtt.client
Source: components/mqtt/client.py:1145
integration: MQTT (documentation, issues)
First occurred: 2:49:44 PM (1 occurrences)
Last logged: 2:49:44 PM
Can't decode payload b'{"uniq_id":"HVXLb1d0d912ed315aad_ZI_TempGeneral","name":"TempGeneral","qos":1,"dev":{"ids":["HVXLb1d0d912ed315aad_Zigbee"],"name":"HomeVisionXL Zigbee","mdl":"ZbBridge","mf":"Tasmota"},"~":"tele/tasmota_zbBridge/TempGeneral/ZbReceived","stat_t":"~","val_tpl":"{{ value_json.Temperature }}","unit_of_meas":"\xb0C","dev_cla":"temperature"}' on homeassistant/sensor/HVXLb1d0d912ed315aad_ZI_TempGeneral/config with encoding utf-8 (for <Job None HassJobType.Callback <function async_start.<locals>.async_discovery_message_received at 0x51952438>>)
Tried the following as well:
"unit_of_meas":"\xb0 C"
"unit_of_meas":"\0xba C"
without success.
I’m not sure how to code this in a way acceptable to HA MQTT.
BTW, I’m pretty sure that the “°C” is sent properly to the MQTT broker as my DIY software can act as a MQTT monitor and it receives the “°C” correctly, so it should be getting to HA with the proper coding.
Also, the devices work fine - seems like discovery defaults to “°C” if it doesn’t get something it likes, so this is really just trying to be clean with what I do here.