diff --git a/custom_components/victron/const.py b/custom_components/victron/const.py index dbe13c5..4bdf32f 100644 --- a/custom_components/victron/const.py +++ b/custom_components/victron/const.py @@ -725,7 +725,7 @@ class microgrid_error(Enum): 230, UINT16, 1, entityType=ButtonWriteType() ), "vebus_microgrid_error": RegisterInfo( - 231, UINT16, TextReadEntityType(microgrid_error) + 231, UINT16, entityType=TextReadEntityType(microgrid_error) ), } diff --git a/custom_components/victron/sensor.py b/custom_components/victron/sensor.py index 73c1944..5d1098a 100644 --- a/custom_components/victron/sensor.py +++ b/custom_components/victron/sensor.py @@ -36,6 +36,7 @@ ReadEntityType, TextReadEntityType, register_info_dict, + UINT16_MAX, ) from .coordinator import victronEnergyDeviceUpdateCoordinator @@ -181,7 +182,9 @@ def _handle_coordinator_update(self) -> None: if self.entity_type is not None and isinstance( self.entity_type, TextReadEntityType ): - if data in {item.value for item in self.entity_type.decodeEnum}: + if data in (UINT16_MAX, float(UINT16_MAX)): + self._attr_native_value = None + elif data in {item.value for item in self.entity_type.decodeEnum}: self._attr_native_value = self.entity_type.decodeEnum( data ).name.split("_DUPLICATE")[0]