Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions custom_components/zaptec/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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
Expand All @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion custom_components/zaptec/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Loading