mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 06:37:52 +00:00
update powerview scene component to latest api. (#19717)
This commit is contained in:
parent
c7700ad11c
commit
a1cb4018a1
@ -8,14 +8,14 @@ import logging
|
|||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.components.scene import Scene, DOMAIN
|
from homeassistant.components.scene import Scene, DOMAIN
|
||||||
from homeassistant.const import CONF_PLATFORM
|
from homeassistant.const import CONF_PLATFORM
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
import homeassistant.helpers.config_validation as cv
|
|
||||||
from homeassistant.helpers.entity import async_generate_entity_id
|
from homeassistant.helpers.entity import async_generate_entity_id
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
REQUIREMENTS = ['aiopvapi==1.5.4']
|
REQUIREMENTS = ['aiopvapi==1.6.14']
|
||||||
|
|
||||||
ENTITY_ID_FORMAT = DOMAIN + '.{}'
|
ENTITY_ID_FORMAT = DOMAIN + '.{}'
|
||||||
HUB_ADDRESS = 'address'
|
HUB_ADDRESS = 'address'
|
||||||
@ -25,6 +25,7 @@ PLATFORM_SCHEMA = vol.Schema({
|
|||||||
vol.Required(HUB_ADDRESS): cv.string,
|
vol.Required(HUB_ADDRESS): cv.string,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
SCENE_DATA = 'sceneData'
|
SCENE_DATA = 'sceneData'
|
||||||
ROOM_DATA = 'roomData'
|
ROOM_DATA = 'roomData'
|
||||||
SCENE_NAME = 'name'
|
SCENE_NAME = 'name'
|
||||||
@ -39,6 +40,7 @@ async def async_setup_platform(hass, config, async_add_entities,
|
|||||||
discovery_info=None):
|
discovery_info=None):
|
||||||
"""Set up home assistant scene entries."""
|
"""Set up home assistant scene entries."""
|
||||||
# from aiopvapi.hub import Hub
|
# from aiopvapi.hub import Hub
|
||||||
|
from aiopvapi.helpers.aiorequest import AioRequest
|
||||||
from aiopvapi.scenes import Scenes
|
from aiopvapi.scenes import Scenes
|
||||||
from aiopvapi.rooms import Rooms
|
from aiopvapi.rooms import Rooms
|
||||||
from aiopvapi.resources.scene import Scene as PvScene
|
from aiopvapi.resources.scene import Scene as PvScene
|
||||||
@ -46,18 +48,17 @@ async def async_setup_platform(hass, config, async_add_entities,
|
|||||||
hub_address = config.get(HUB_ADDRESS)
|
hub_address = config.get(HUB_ADDRESS)
|
||||||
websession = async_get_clientsession(hass)
|
websession = async_get_clientsession(hass)
|
||||||
|
|
||||||
_scenes = await Scenes(
|
pv_request = AioRequest(hub_address, loop=hass.loop, websession=websession)
|
||||||
hub_address, hass.loop, websession).get_resources()
|
|
||||||
_rooms = await Rooms(
|
_scenes = await Scenes(pv_request).get_resources()
|
||||||
hub_address, hass.loop, websession).get_resources()
|
_rooms = await Rooms(pv_request).get_resources()
|
||||||
|
|
||||||
if not _scenes or not _rooms:
|
if not _scenes or not _rooms:
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
"Unable to initialize PowerView hub: %s", hub_address)
|
"Unable to initialize PowerView hub: %s", hub_address)
|
||||||
return
|
return
|
||||||
pvscenes = (PowerViewScene(hass,
|
pvscenes = (PowerViewScene(hass,
|
||||||
PvScene(_raw_scene, hub_address, hass.loop,
|
PvScene(_raw_scene, pv_request), _rooms)
|
||||||
websession), _rooms)
|
|
||||||
for _raw_scene in _scenes[SCENE_DATA])
|
for _raw_scene in _scenes[SCENE_DATA])
|
||||||
async_add_entities(pvscenes)
|
async_add_entities(pvscenes)
|
||||||
|
|
||||||
@ -96,6 +97,6 @@ class PowerViewScene(Scene):
|
|||||||
"""Icon to use in the frontend."""
|
"""Icon to use in the frontend."""
|
||||||
return 'mdi:blinds'
|
return 'mdi:blinds'
|
||||||
|
|
||||||
def async_activate(self):
|
async def async_activate(self):
|
||||||
"""Activate scene. Try to get entities into requested state."""
|
"""Activate scene. Try to get entities into requested state."""
|
||||||
yield from self._scene.activate()
|
await self._scene.activate()
|
||||||
|
@ -124,7 +124,7 @@ aiolifx==0.6.7
|
|||||||
aiolifx_effects==0.2.1
|
aiolifx_effects==0.2.1
|
||||||
|
|
||||||
# homeassistant.components.scene.hunterdouglas_powerview
|
# homeassistant.components.scene.hunterdouglas_powerview
|
||||||
aiopvapi==1.5.4
|
aiopvapi==1.6.14
|
||||||
|
|
||||||
# homeassistant.components.unifi
|
# homeassistant.components.unifi
|
||||||
aiounifi==3
|
aiounifi==3
|
||||||
|
Loading…
x
Reference in New Issue
Block a user