sensor.py: native_unit_of_measurement not set when coordinator data is None at startup #317
Replies: 1 comment
|
this is fixed in v2.3.0 |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Version: 2.2.0
HA Version: (2026.5)
Problem:
After HA restart, all observation sensors (temperature, dewpoint, pressure, wind speed, etc.)
lose their unit_of_measurement. HA then reports "units changed" errors in Repairs for all affected entities.
Root cause:
In
sensor.py__init__, the unit is only set whenself._sensor_data is not None:At startup, the coordinator has not yet loaded data, so
_sensor_datais alwaysNoneand the unit is never set. After data loads via
_handle_coordinator_update,the value updates but the unit is still missing.
Fix:
Remove the outer
if self._sensor_data is not Noneguard —unit_fndoes not dependon sensor data at all. Text sensors are already handled by the inner
if unit is not Nonecheck.All reactions