You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
variable is using native unit of measurement 'None' which is not a valid unit for the device class ('power') #184
Why do I get error with " is using native unit of measurement 'None' which is not a valid unit for the device class ('power'); expected one of ['MW', 'mW', 'W', 'GW', 'kW', 'TW']" ?
There seems to be something wrong in sensor... :( like when unit_of_measurement was defined as user attribute and not system attribute. The value is correct.
after restart i get these messages in log:
2026-08-20 21:12:41.626 WARNING (MainThread) [custom_components.variable] [YAML] Creating New Sensor Variable: variable_test_del_15m
2026-08-20 21:12:41.628 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.variable_test_del_15m (<class 'custom_components.variable.sensor.Variable'>) is using native unit of measurement 'None' which is not a valid unit for the device class ('power') it is using; expected one of ['MW', 'mW', 'W', 'GW', 'kW', 'TW']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/wibias/hass-variables/issues
YAML sensors already promoted device_class and state_class from attributes to native sensor properties. unit_of_measurement was left as a custom extra attribute instead, so Home Assistant compared device class power against native unit None and logged that warning. The States view still looked correct because kW was present as that extra attribute.
#186 maps unit_of_measurement onto the native unit (including after restart when older restore data still had native unit None).
If you grant issue-comment access, or want this posted on the PR instead, I can post it from here.
Activity
Wibias commentedon Aug 22, 2026
Thanks for the clear report and the YAML example.
YAML sensors already promoted device_class and state_class from attributes to native sensor properties. unit_of_measurement was left as a custom extra attribute instead, so Home Assistant compared device class power against native unit None and logged that warning. The States view still looked correct because kW was present as that extra attribute.
#186 maps unit_of_measurement onto the native unit (including after restart when older restore data still had native unit None).
If you grant issue-comment access, or want this posted on the PR instead, I can post it from here.
GiZMoSK1221 commentedon Aug 26, 2026
Hi Wibias, thanks for the repair, now I have no warnings after restart.
Sorry for late answer, it's holiday time :)