diff --git a/custom_components/zaptec/binary_sensor.py b/custom_components/zaptec/binary_sensor.py index 249dc7d..e9a9e90 100644 --- a/custom_components/zaptec/binary_sensor.py +++ b/custom_components/zaptec/binary_sensor.py @@ -34,11 +34,14 @@ def _update_from_zaptec(self) -> None: self._attr_available = True -class ZaptecBinarySensorWithAttrs(ZaptecBinarySensor): - """Zaptec binary sensor with additional attributes.""" +class ZaptecActiveBinarySensor(ZaptecBinarySensor): + """Zaptec 'active' binary sensor for the main charger/installation device. + + Uses the bare Zaptec object id as the unique id (without the entity key + suffix) to preserve the historical entity identity. + """ def _post_init(self) -> None: - self._attr_extra_state_attributes = self.zaptec_obj.asdict() self._attr_unique_id = self.zaptec_obj.id @@ -55,7 +58,7 @@ class ZapBinarySensorEntityDescription(ZaptecEntityDescription, BinarySensorEnti entity_category=const.EntityCategory.DIAGNOSTIC, icon="mdi:cloud", has_entity_name=False, - cls=ZaptecBinarySensorWithAttrs, + cls=ZaptecActiveBinarySensor, ), ZapBinarySensorEntityDescription( # The Zaptec API is not consistent with the naming of the usage of @@ -77,7 +80,7 @@ class ZapBinarySensorEntityDescription(ZaptecEntityDescription, BinarySensorEnti entity_category=const.EntityCategory.DIAGNOSTIC, icon="mdi:cloud", has_entity_name=False, - cls=ZaptecBinarySensorWithAttrs, + cls=ZaptecActiveBinarySensor, ), ZapBinarySensorEntityDescription( key="is_online", diff --git a/custom_components/zaptec/manager.py b/custom_components/zaptec/manager.py index 79b9fc0..1a2c379 100644 --- a/custom_components/zaptec/manager.py +++ b/custom_components/zaptec/manager.py @@ -173,7 +173,9 @@ def create_entities_from_zaptec( ) elif isinstance(obj, Charger): - info = DeviceInfo() + # Expose the Zaptec device id as the device serial number, matching + # what the Zaptec app shows as the charger serial. + info = DeviceInfo(serial_number=obj.get("DeviceId")) if obj.installation: info["via_device"] = (DOMAIN, obj.installation.id)