Beispiel #1
0
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
    """Set up Soma from a config entry."""
    hass.data[DOMAIN] = {}
    hass.data[DOMAIN][API] = SomaApi(entry.data[HOST], entry.data[PORT])
    devices = await hass.async_add_executor_job(hass.data[DOMAIN][API].list_devices)
    hass.data[DOMAIN][DEVICES] = devices["shades"]

    await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

    return True
Beispiel #2
0
async def async_setup_entry(opp: OpenPeerPower, entry: ConfigEntry):
    """Set up Soma from a config entry."""
    opp.data[DOMAIN] = {}
    opp.data[DOMAIN][API] = SomaApi(entry.data[HOST], entry.data[PORT])
    devices = await opp.async_add_executor_job(opp.data[DOMAIN][API].list_devices)
    opp.data[DOMAIN][DEVICES] = devices["shades"]

    opp.config_entries.async_setup_platforms(entry, PLATFORMS)

    return True
Beispiel #3
0
async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
    """Set up Soma from a config entry."""
    hass.data[DOMAIN] = {}
    hass.data[DOMAIN][API] = SomaApi(entry.data[HOST], entry.data[PORT])
    devices = await hass.async_add_executor_job(
        hass.data[DOMAIN][API].list_devices)
    hass.data[DOMAIN][DEVICES] = devices["shades"]

    for platform in PLATFORMS:
        hass.async_create_task(
            hass.config_entries.async_forward_entry_setup(entry, platform))

    return True
Beispiel #4
0
 async def async_step_creation(self, user_input=None):
     """Finish config flow."""
     api = SomaApi(user_input["host"], user_input["port"])
     try:
         await self.hass.async_add_executor_job(api.list_devices)
         _LOGGER.info("Successfully set up Soma Connect")
         return self.async_create_entry(
             title="Soma Connect",
             data={
                 "host": user_input["host"],
                 "port": user_input["port"]
             },
         )
     except RequestException:
         _LOGGER.error("Connection to SOMA Connect failed")
         return self.async_abort(reason="connection_error")
Beispiel #5
0
 async def async_step_creation(self, user_input=None):
     """Finish config flow."""
     api = SomaApi(user_input["host"], user_input["port"])
     try:
         result = await self.opp.async_add_executor_job(api.list_devices)
         _LOGGER.info("Successfully set up Soma Connect")
         if result["result"] == "success":
             return self.async_create_entry(
                 title="Soma Connect",
                 data={
                     "host": user_input["host"],
                     "port": user_input["port"]
                 },
             )
         _LOGGER.error("Connection to SOMA Connect failed (result:%s)",
                       result["result"])
         return self.async_abort(reason="result_error")
     except RequestException:
         _LOGGER.error(
             "Connection to SOMA Connect failed with RequestException")
         return self.async_abort(reason="connection_error")
     except KeyError:
         _LOGGER.error("Connection to SOMA Connect failed with KeyError")
         return self.async_abort(reason="connection_error")