Skip to content

Commit

Permalink
Merge branch 'master' into peribeir/issue99
Browse files Browse the repository at this point in the history
  • Loading branch information
peribeir authored Nov 28, 2023
2 parents 8e7a3f5 + c06fbbc commit 7ec6c89
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
2 changes: 1 addition & 1 deletion custom_components/rademacher/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

# List of platforms to support. There should be a matching .py file for each,
# eg <cover.py> and <sensor.py>
PLATFORMS = ["cover", "button", "switch", "sensor", "binary_sensor", "climate", "light", "number", "update"]
PLATFORMS = ["cover", "button", "switch", "sensor", "binary_sensor", "climate", "light", "number", "update", "scene"]

_LOGGER = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion custom_components/rademacher/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/peribeir/homeassistant-rademacher/issues",
"requirements": ["pyrademacher==0.13.1"],
"version": "2.0.1"
"version": "2.1.0"
}
53 changes: 53 additions & 0 deletions custom_components/rademacher/scene.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""Platform for Rademacher Bridge"""
import asyncio
import logging
from typing import Any

from homeassistant.helpers.entity import EntityCategory

from homeassistant.components.scene import Scene
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator

from homepilot.manager import HomePilotManager
from homepilot.scenes import HomePilotScene

from .const import DOMAIN
from .entity import HomePilotEntity

_LOGGER = logging.getLogger(__name__)


async def async_setup_entry(hass, config_entry, async_add_entities):
"""Setup of entities for switch platform"""
entry = hass.data[DOMAIN][config_entry.entry_id]
manager: HomePilotManager = entry[0]
new_entities = []
for sid in manager.scenes:
scene: HomePilotScene = manager.scenes[sid]
_LOGGER.info("Found Scene for ID: %s", sid)
new_entities.append(HomePilotSceneEntity(sid, scene))
# If we have any new devices, add them
if new_entities:
async_add_entities(new_entities)


class HomePilotSceneEntity(Scene):
"""This class represents Cover Ventilation Position"""
_sid: str
_scene: HomePilotScene

def __init__(
self, sid: str, scene: HomePilotScene
) -> None:
self._sid = sid
self._scene = scene
self._attr_unique_id = f"scene_{sid}"
self._attr_name = f"Homepilot - {scene.name}"

@property
def available(self):
return True

async def async_activate(self, **kwargs: Any) -> None:
"""Activate scene. Try to get entities into requested state."""
await self._scene.async_execute_scene()

0 comments on commit 7ec6c89

Please sign in to comment.