예제 #1
0
async def async_setup_platform(hass,
                               config,
                               async_add_entities,
                               discovery_info=None):
    """Set up home assistant scene entries."""
    # from aiopvapi.hub import Hub
    from aiopvapi.helpers.aiorequest import AioRequest
    from aiopvapi.scenes import Scenes
    from aiopvapi.rooms import Rooms
    from aiopvapi.resources.scene import Scene as PvScene

    hub_address = config.get(HUB_ADDRESS)
    websession = async_get_clientsession(hass)

    pv_request = AioRequest(hub_address, loop=hass.loop, websession=websession)

    _scenes = await Scenes(pv_request).get_resources()
    _rooms = await Rooms(pv_request).get_resources()

    if not _scenes or not _rooms:
        _LOGGER.error("Unable to initialize PowerView hub: %s", hub_address)
        return
    pvscenes = (PowerViewScene(hass, PvScene(_raw_scene, pv_request), _rooms)
                for _raw_scene in _scenes[SCENE_DATA])
    async_add_entities(pvscenes)
예제 #2
0
파일: scene.py 프로젝트: dadaloop82/core
async def async_setup_entry(hass, entry, async_add_entities):
    """Set up powerview scene entries."""

    pv_data = hass.data[DOMAIN][entry.entry_id]
    room_data = pv_data[PV_ROOM_DATA]
    scene_data = pv_data[PV_SCENE_DATA]
    pv_request = pv_data[PV_API]
    coordinator = pv_data[COORDINATOR]
    device_info = pv_data[DEVICE_INFO]

    pvscenes = (PowerViewScene(PvScene(raw_scene, pv_request), room_data,
                               coordinator, device_info)
                for scene_id, raw_scene in scene_data.items())
    async_add_entities(pvscenes)
예제 #3
0
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry,
                            async_add_entities: AddEntitiesCallback) -> None:
    """Set up powerview scene entries."""

    pv_entry: PowerviewEntryData = hass.data[DOMAIN][entry.entry_id]

    pvscenes = []
    for raw_scene in pv_entry.scene_data.values():
        scene = PvScene(raw_scene, pv_entry.api)
        room_name = pv_entry.room_data.get(scene.room_id,
                                           {}).get(ROOM_NAME_UNICODE, "")
        pvscenes.append(
            PowerViewScene(pv_entry.coordinator, pv_entry.device_info,
                           room_name, scene))
    async_add_entities(pvscenes)
예제 #4
0
async def async_setup_entry(hass, entry, async_add_entities):
    """Set up powerview scene entries."""

    pv_data = hass.data[DOMAIN][entry.entry_id]
    room_data = pv_data[PV_ROOM_DATA]
    scene_data = pv_data[PV_SCENE_DATA]
    pv_request = pv_data[PV_API]
    coordinator = pv_data[COORDINATOR]
    device_info = pv_data[DEVICE_INFO]

    pvscenes = []
    for raw_scene in scene_data.values():
        scene = PvScene(raw_scene, pv_request)
        room_name = room_data.get(scene.room_id, {}).get(ROOM_NAME_UNICODE, "")
        pvscenes.append(PowerViewScene(coordinator, device_info, room_name, scene))
    async_add_entities(pvscenes)