File tree Expand file tree Collapse file tree
custom_components/victron_mqtt Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -87,10 +87,11 @@ def __init__(
8787 installation_id ,
8888 )
8989 self ._attr_device_class = METRIC_TYPE_TO_DEVICE_CLASS .get (metric .metric_type )
90- if self ._attr_device_class is not None :
91- self ._attr_native_unit_of_measurement = metric .unit_of_measurement
92- elif metric .metric_type == MetricType .DYNAMIC :
93- # Dynamic units come from user-configured MQTT topics (e.g.
90+ if self ._attr_device_class is not None or metric .metric_type == MetricType .DYNAMIC :
91+ # We need to set the _attr_native_unit_of_measurement in two cases:
92+ # 1. When there known device class which support multiple units. In this case
93+ # we publish what we have and HA will allow convertion to other supported units.
94+ # 2. Dynamic units come from user-configured MQTT topics (e.g.
9495 # SwitchableOutput Settings/Unit) and have no translation file
9596 # entry, so we must set the unit programmatically.
9697 self ._attr_native_unit_of_measurement = metric .unit_of_measurement
You can’t perform that action at this time.
0 commit comments