2019-02-13 20:21:14 +00:00
|
|
|
"""Support for Fibaro scenes."""
|
2022-01-03 16:17:44 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2020-04-21 01:07:50 +00:00
|
|
|
from typing import Any
|
2018-12-03 13:57:55 +00:00
|
|
|
|
2019-03-21 05:56:46 +00:00
|
|
|
from homeassistant.components.scene import Scene
|
2022-03-26 19:50:50 +00:00
|
|
|
from homeassistant.config_entries import ConfigEntry
|
2022-04-26 18:08:41 +00:00
|
|
|
from homeassistant.const import Platform
|
2022-01-03 16:17:44 +00:00
|
|
|
from homeassistant.core import HomeAssistant
|
2022-06-30 21:57:35 +00:00
|
|
|
from homeassistant.helpers.entity import DeviceInfo
|
2022-01-03 16:17:44 +00:00
|
|
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
2019-03-21 05:56:46 +00:00
|
|
|
|
|
|
|
from . import FIBARO_DEVICES, FibaroDevice
|
2022-03-26 19:50:50 +00:00
|
|
|
from .const import DOMAIN
|
2018-12-03 13:57:55 +00:00
|
|
|
|
|
|
|
|
2022-03-26 19:50:50 +00:00
|
|
|
async def async_setup_entry(
|
2022-01-03 16:17:44 +00:00
|
|
|
hass: HomeAssistant,
|
2022-03-26 19:50:50 +00:00
|
|
|
entry: ConfigEntry,
|
2022-01-03 16:17:44 +00:00
|
|
|
async_add_entities: AddEntitiesCallback,
|
|
|
|
) -> None:
|
2018-12-03 13:57:55 +00:00
|
|
|
"""Perform the setup for Fibaro scenes."""
|
|
|
|
async_add_entities(
|
2022-03-26 19:50:50 +00:00
|
|
|
[
|
|
|
|
FibaroScene(scene)
|
2022-04-26 18:08:41 +00:00
|
|
|
for scene in hass.data[DOMAIN][entry.entry_id][FIBARO_DEVICES][
|
|
|
|
Platform.SCENE
|
|
|
|
]
|
2022-03-26 19:50:50 +00:00
|
|
|
],
|
|
|
|
True,
|
2019-07-31 19:25:30 +00:00
|
|
|
)
|
2018-12-03 13:57:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
class FibaroScene(FibaroDevice, Scene):
|
|
|
|
"""Representation of a Fibaro scene entity."""
|
|
|
|
|
2022-06-30 21:57:35 +00:00
|
|
|
def __init__(self, fibaro_device: Any) -> None:
|
|
|
|
"""Initialize the Fibaro scene."""
|
|
|
|
super().__init__(fibaro_device)
|
|
|
|
|
|
|
|
# All scenes are shown on hub device
|
|
|
|
self._attr_device_info = DeviceInfo(
|
|
|
|
identifiers={(DOMAIN, self.controller.hub_serial)}
|
|
|
|
)
|
|
|
|
|
2020-04-21 01:07:50 +00:00
|
|
|
def activate(self, **kwargs: Any) -> None:
|
2018-12-03 13:57:55 +00:00
|
|
|
"""Activate the scene."""
|
|
|
|
self.fibaro_device.start()
|