Exemplo n.º 1
0
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
    """Set up BSB-Lan from a config entry."""

    session = async_get_clientsession(hass)
    bsblan = BSBLan(
        entry.data[CONF_HOST],
        passkey=entry.data[CONF_PASSKEY],
        port=entry.data[CONF_PORT],
        username=entry.data.get(CONF_USERNAME),
        password=entry.data.get(CONF_PASSWORD),
        session=session,
    )

    try:
        await bsblan.info()
    except BSBLanConnectionError as exception:
        raise ConfigEntryNotReady from exception

    hass.data.setdefault(DOMAIN, {})
    hass.data[DOMAIN][entry.entry_id] = {DATA_BSBLAN_CLIENT: bsblan}

    hass.async_create_task(
        hass.config_entries.async_forward_entry_setup(entry, CLIMATE_DOMAIN))

    return True
Exemplo n.º 2
0
 async def _get_bsblan_info(self, host: str, passkey: Optional[str],
                            port: int) -> Info:
     """Get device information from an BSBLan device."""
     session = async_get_clientsession(self.hass)
     _LOGGER.debug("request bsblan.info:")
     bsblan = BSBLan(host, passkey=passkey, port=port, session=session)
     return await bsblan.info()
Exemplo n.º 3
0
 async def _get_bsblan_info(
     self,
     host: str,
     username: str | None,
     password: str | None,
     passkey: str | None,
     port: int,
 ) -> Info:
     """Get device information from an BSBLan device."""
     session = async_get_clientsession(self.opp)
     _LOGGER.debug("request bsblan.info:")
     bsblan = BSBLan(
         host,
         username=username,
         password=password,
         passkey=passkey,
         port=port,
         session=session,
     )
     return await bsblan.info()
Exemplo n.º 4
0
async def async_setup_entry(opp: OpenPeerPower, entry: ConfigEntry) -> bool:
    """Set up BSB-Lan from a config entry."""

    session = async_get_clientsession(opp)
    bsblan = BSBLan(
        entry.data[CONF_HOST],
        passkey=entry.data[CONF_PASSKEY],
        port=entry.data[CONF_PORT],
        username=entry.data.get(CONF_USERNAME),
        password=entry.data.get(CONF_PASSWORD),
        session=session,
    )

    try:
        await bsblan.info()
    except BSBLanConnectionError as exception:
        raise ConfigEntryNotReady from exception

    opp.data.setdefault(DOMAIN, {})
    opp.data[DOMAIN][entry.entry_id] = {DATA_BSBLAN_CLIENT: bsblan}

    opp.config_entries.async_setup_platforms(entry, PLATFORMS)

    return True