async def async_setup(hass, hass_config): """Create an Intergas InComfort/Intouch system.""" incomfort_data = hass.data[DOMAIN] = {} credentials = dict(hass_config[DOMAIN]) hostname = credentials.pop(CONF_HOST) try: client = incomfort_data['client'] = InComfortGateway( hostname, **credentials, session=async_get_clientsession(hass) ) heater = incomfort_data['heater'] = list(await client.heaters)[0] await heater.update() except AssertionError: # assert response.status == HTTP_OK _LOGGER.warning( "Setup failed, check your configuration.", exc_info=True) return False for platform in ['water_heater', 'climate']: hass.async_create_task(async_load_platform( hass, platform, DOMAIN, {}, hass_config)) return True
async def async_setup(hass, hass_config): """Create an Intergas InComfort/Intouch system.""" incomfort_data = hass.data[DOMAIN] = {} credentials = dict(hass_config[DOMAIN]) hostname = credentials.pop(CONF_HOST) client = incomfort_data["client"] = InComfortGateway( hostname, **credentials, session=async_get_clientsession(hass) ) try: heaters = incomfort_data["heaters"] = list(await client.heaters) except ClientResponseError as err: _LOGGER.warning("Setup failed, check your configuration, message is: %s", err) return False for heater in heaters: await heater.update() for platform in ["water_heater", "binary_sensor", "sensor", "climate"]: hass.async_create_task( async_load_platform(hass, platform, DOMAIN, {}, hass_config) ) return True