Skip to content

Commit

Permalink
Merge pull request #65 from peribeir/peribeir/issue64
Browse files Browse the repository at this point in the history
Add support for activate and deactivate scenes
  • Loading branch information
peribeir authored Sep 29, 2024
2 parents ab7cb24 + a382300 commit 3871ccb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
18 changes: 18 additions & 0 deletions homepilot/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,24 @@ async def async_execute_scene(self, sid: int):
) as response:
return await response.json()

async def async_activate_scene(self, sid: int):
await self.authenticate()
async with aiohttp.ClientSession(cookie_jar=self.cookie_jar) as session:
async with session.post(
f"http://{self._host}{self._base_path}/scenes/{sid}/actions",
json={ "request_type": "SWITCHSCENE", "trigger_event": "SCENE_MODE_CMD", "value": True }
) as response:
return await response.json()

async def async_deactivate_scene(self, sid: int):
await self.authenticate()
async with aiohttp.ClientSession(cookie_jar=self.cookie_jar) as session:
async with session.post(
f"http://{self._host}{self._base_path}/scenes/{sid}/actions",
json={ "request_type": "EXECUTESCENE", "trigger_event": "SCENE_MODE_CMD", "value": False }
) as response:
return await response.json()

@property
def host(self):
return self._host
Expand Down
6 changes: 6 additions & 0 deletions homepilot/scenes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ def __init__(
async def async_execute_scene(self) -> None:
await self._api.async_execute_scene(self._sid)

async def async_activate_scene(self) -> None:
await self._api.async_activate_scene(self._sid)

async def async_deactivate_scene(self) -> None:
await self._api.async_deactivate_scene(self._sid)

@property
def name(self):
return self._name
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="pyrademacher",
version="0.14.1",
version="0.14.2",
author="Pedro Ribeiro",
author_email="[email protected]",
description="Control devices connected to your Rademacher Homepilot "
Expand Down

0 comments on commit 3871ccb

Please sign in to comment.