Use shorthand attributes for Elmax (#99277)
This commit is contained in:
parent
7d70b42e4a
commit
a4818c5f54
3 changed files with 11 additions and 33 deletions
|
@ -60,12 +60,9 @@ async def async_setup_entry(
|
|||
class ElmaxSensor(ElmaxEntity, BinarySensorEntity):
|
||||
"""Elmax Sensor entity implementation."""
|
||||
|
||||
_attr_device_class = BinarySensorDeviceClass.DOOR
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
"""Return true if the binary sensor is on."""
|
||||
return self.coordinator.get_zone_state(self._device.endpoint_id).opened
|
||||
|
||||
@property
|
||||
def device_class(self) -> BinarySensorDeviceClass:
|
||||
"""Return the class of this device, from component DEVICE_CLASSES."""
|
||||
return BinarySensorDeviceClass.DOOR
|
||||
|
|
|
@ -157,35 +157,16 @@ class ElmaxEntity(CoordinatorEntity[ElmaxCoordinator]):
|
|||
super().__init__(coordinator=coordinator)
|
||||
self._panel = panel
|
||||
self._device = elmax_device
|
||||
self._panel_version = panel_version
|
||||
self._client = coordinator.http_client
|
||||
|
||||
@property
|
||||
def panel_id(self) -> str:
|
||||
"""Retrieve the panel id."""
|
||||
return self._panel.hash
|
||||
|
||||
@property
|
||||
def unique_id(self) -> str | None:
|
||||
"""Provide a unique id for this entity."""
|
||||
return self._device.endpoint_id
|
||||
|
||||
@property
|
||||
def name(self) -> str | None:
|
||||
"""Return the entity name."""
|
||||
return self._device.name
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device specific attributes."""
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self._panel.hash)},
|
||||
name=self._panel.get_name_by_user(
|
||||
self.coordinator.http_client.get_authenticated_username()
|
||||
self._attr_unique_id = elmax_device.endpoint_id
|
||||
self._attr_name = elmax_device.name
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, panel.hash)},
|
||||
name=panel.get_name_by_user(
|
||||
coordinator.http_client.get_authenticated_username()
|
||||
),
|
||||
manufacturer="Elmax",
|
||||
model=self._panel_version,
|
||||
sw_version=self._panel_version,
|
||||
model=panel_version,
|
||||
sw_version=panel_version,
|
||||
)
|
||||
|
||||
@property
|
||||
|
|
|
@ -68,7 +68,7 @@ class ElmaxSwitch(ElmaxEntity, SwitchEntity):
|
|||
return self.coordinator.get_actuator_state(self._device.endpoint_id).opened
|
||||
|
||||
async def _wait_for_state_change(self) -> bool:
|
||||
"""Refresh data and wait until the state state changes."""
|
||||
"""Refresh data and wait until the state changes."""
|
||||
old_state = self.coordinator.get_actuator_state(self._device.endpoint_id).opened
|
||||
|
||||
# Wait a bit at first to let Elmax cloud assimilate the new state.
|
||||
|
|
Loading…
Add table
Reference in a new issue