diff --git a/homeassistant/components/scene/hunterdouglas_powerview.py b/homeassistant/components/scene/hunterdouglas_powerview.py index 8c1ffa17e90..7676deb1a9c 100644 --- a/homeassistant/components/scene/hunterdouglas_powerview.py +++ b/homeassistant/components/scene/hunterdouglas_powerview.py @@ -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() diff --git a/requirements_all.txt b/requirements_all.txt index 4e924cd9e29..588ae10062f 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -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