-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated dependency to new PyMyGekko lib.
Added mygekko actions as scenes.
- Loading branch information
Showing
11 changed files
with
117 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"""Scene platform for MyGekko.""" | ||
from typing import Any | ||
|
||
from homeassistant.components.scene import Scene | ||
from homeassistant.core import callback | ||
from PyMyGekko.resources.Actions import Action | ||
from PyMyGekko.resources.Actions import ActionState | ||
|
||
from .const import DOMAIN | ||
from .const import SCENE | ||
from .entity import MyGekkoEntity | ||
|
||
|
||
async def async_setup_entry(hass, entry, async_add_devices): | ||
"""Setup scene platform.""" | ||
coordinator = hass.data[DOMAIN][entry.entry_id] | ||
actions = coordinator.api.get_actions() | ||
if actions is not None: | ||
async_add_devices(MyGekkoScene(coordinator, action) for action in actions) | ||
|
||
|
||
class MyGekkoScene(MyGekkoEntity, Scene): | ||
"""mygekko Scene class.""" | ||
|
||
def __init__(self, coordinator, action: Action): | ||
super().__init__(coordinator, action, SCENE) | ||
self._action = action | ||
|
||
@callback | ||
def _handle_coordinator_update(self) -> None: | ||
"""Handle updated data from the coordinator.""" | ||
self.async_write_ha_state() | ||
|
||
async def activate(self, **kwargs: Any) -> None: | ||
await self._action.set_state(ActionState.ON) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
-r requirements_dev.txt | ||
pytest-asyncio | ||
pytest-homeassistant-custom-component==0.13.76 | ||
PyMyGekko==0.0.5rc4 | ||
PyMyGekko==0.0.5rc5 |