update powerview scene component to latest api. (#19717)
This commit is contained in:
parent
c7700ad11c
commit
a1cb4018a1
2 changed files with 12 additions and 11 deletions
|
@ -8,14 +8,14 @@ import logging
|
|||
|
||||
import voluptuous as vol
|
||||
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.components.scene import Scene, DOMAIN
|
||||
from homeassistant.const import CONF_PLATFORM
|
||||
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
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
REQUIREMENTS = ['aiopvapi==1.5.4']
|
||||
REQUIREMENTS = ['aiopvapi==1.6.14']
|
||||
|
||||
ENTITY_ID_FORMAT = DOMAIN + '.{}'
|
||||
HUB_ADDRESS = 'address'
|
||||
|
@ -25,6 +25,7 @@ PLATFORM_SCHEMA = vol.Schema({
|
|||
vol.Required(HUB_ADDRESS): cv.string,
|
||||
})
|
||||
|
||||
|
||||
SCENE_DATA = 'sceneData'
|
||||
ROOM_DATA = 'roomData'
|
||||
SCENE_NAME = 'name'
|
||||
|
@ -39,6 +40,7 @@ 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
|
||||
|
@ -46,18 +48,17 @@ async def async_setup_platform(hass, config, async_add_entities,
|
|||
hub_address = config.get(HUB_ADDRESS)
|
||||
websession = async_get_clientsession(hass)
|
||||
|
||||
_scenes = await Scenes(
|
||||
hub_address, hass.loop, websession).get_resources()
|
||||
_rooms = await Rooms(
|
||||
hub_address, hass.loop, websession).get_resources()
|
||||
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, hub_address, hass.loop,
|
||||
websession), _rooms)
|
||||
PvScene(_raw_scene, pv_request), _rooms)
|
||||
for _raw_scene in _scenes[SCENE_DATA])
|
||||
async_add_entities(pvscenes)
|
||||
|
||||
|
@ -96,6 +97,6 @@ class PowerViewScene(Scene):
|
|||
"""Icon to use in the frontend."""
|
||||
return 'mdi:blinds'
|
||||
|
||||
def async_activate(self):
|
||||
async def async_activate(self):
|
||||
"""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
|
||||
|
||||
# homeassistant.components.scene.hunterdouglas_powerview
|
||||
aiopvapi==1.5.4
|
||||
aiopvapi==1.6.14
|
||||
|
||||
# homeassistant.components.unifi
|
||||
aiounifi==3
|
||||
|
|
Loading…
Add table
Reference in a new issue