Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up home assistant scene entries."""
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)