mirror of https://github.com/home-assistant/core
Use pydeconz interface controls for lock, scene, siren and switch platforms (#73748)
This commit is contained in:
parent
cf9cab900e
commit
27209574d2
|
@ -62,8 +62,26 @@ class DeconzLock(DeconzDevice, LockEntity):
|
|||
|
||||
async def async_lock(self, **kwargs: Any) -> None:
|
||||
"""Lock the lock."""
|
||||
await self._device.lock()
|
||||
if isinstance(self._device, DoorLock):
|
||||
await self.gateway.api.sensors.door_lock.set_config(
|
||||
id=self._device.resource_id,
|
||||
lock=True,
|
||||
)
|
||||
else:
|
||||
await self.gateway.api.lights.locks.set_state(
|
||||
id=self._device.resource_id,
|
||||
lock=True,
|
||||
)
|
||||
|
||||
async def async_unlock(self, **kwargs: Any) -> None:
|
||||
"""Unlock the lock."""
|
||||
await self._device.unlock()
|
||||
if isinstance(self._device, DoorLock):
|
||||
await self.gateway.api.sensors.door_lock.set_config(
|
||||
id=self._device.resource_id,
|
||||
lock=False,
|
||||
)
|
||||
else:
|
||||
await self.gateway.api.lights.locks.set_state(
|
||||
id=self._device.resource_id,
|
||||
lock=False,
|
||||
)
|
||||
|
|
|
@ -43,4 +43,7 @@ class DeconzScene(DeconzSceneMixin, Scene):
|
|||
|
||||
async def async_activate(self, **kwargs: Any) -> None:
|
||||
"""Activate the scene."""
|
||||
await self._device.recall()
|
||||
await self.gateway.api.scenes.recall(
|
||||
self._device.group_id,
|
||||
self._device.id,
|
||||
)
|
||||
|
|
|
@ -59,11 +59,17 @@ class DeconzSiren(DeconzDevice, SirenEntity):
|
|||
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn on siren."""
|
||||
data = {}
|
||||
if (duration := kwargs.get(ATTR_DURATION)) is not None:
|
||||
data["duration"] = duration * 10
|
||||
await self._device.turn_on(**data)
|
||||
duration *= 10
|
||||
await self.gateway.api.lights.sirens.set_state(
|
||||
id=self._device.resource_id,
|
||||
on=True,
|
||||
duration=duration,
|
||||
)
|
||||
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn off siren."""
|
||||
await self._device.turn_off()
|
||||
await self.gateway.api.lights.sirens.set_state(
|
||||
id=self._device.resource_id,
|
||||
on=False,
|
||||
)
|
||||
|
|
|
@ -56,8 +56,14 @@ class DeconzPowerPlug(DeconzDevice, SwitchEntity):
|
|||
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn on switch."""
|
||||
await self._device.set_state(on=True)
|
||||
await self.gateway.api.lights.lights.set_state(
|
||||
id=self._device.resource_id,
|
||||
on=True,
|
||||
)
|
||||
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn off switch."""
|
||||
await self._device.set_state(on=False)
|
||||
await self.gateway.api.lights.lights.set_state(
|
||||
id=self._device.resource_id,
|
||||
on=False,
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue