Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pydeconz interface controls for lock, scene, siren and switch platforms #73748

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 20 additions & 2 deletions homeassistant/components/deconz/lock.py
Expand Up @@ -62,8 +62,26 @@ def is_locked(self) -> bool:

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,
)
5 changes: 4 additions & 1 deletion homeassistant/components/deconz/scene.py
Expand Up @@ -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,
)
14 changes: 10 additions & 4 deletions homeassistant/components/deconz/siren.py
Expand Up @@ -59,11 +59,17 @@ def is_on(self) -> bool:

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,
)
10 changes: 8 additions & 2 deletions homeassistant/components/deconz/switch.py
Expand Up @@ -56,8 +56,14 @@ def is_on(self) -> bool:

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,
)