Esempio n. 1
0
    async def get_hap(
        self,
        hass: HomeAssistant,
        hapid: str | None,
        authtoken: str | None,
        name: str | None,
    ) -> AsyncHome:
        """Create a HomematicIP access point object."""
        home = AsyncHome(hass.loop, async_get_clientsession(hass))

        home.name = name
        # Use the title of the config entry as title for the home.
        home.label = self.config_entry.title
        home.modelType = "HomematicIP Cloud Home"

        home.set_auth_token(authtoken)
        try:
            await home.init(hapid)
            await home.get_current_state()
        except HmipConnectionError as err:
            raise HmipcConnectionError from err
        home.on_update(self.async_update)
        home.on_create(self.async_create_entity)
        hass.loop.create_task(self.async_connect())

        return home
Esempio n. 2
0
async def fake_async_home(fake_cloud, event_loop):
    home = AsyncHome(event_loop)
    with no_ssl_verification():
        lookup_url = "{}/getHost".format(fake_cloud.url)
        #    home.download_configuration = fake_home_download_configuration
        home._connection = AsyncConnection(event_loop)
        home._fake_cloud = fake_cloud
        home.set_auth_token(
            "8A45BAA53BE37E3FCA58E9976EFA4C497DAFE55DB997DB9FD685236E5E63ED7DE"
        )
        await home._connection.init(accesspoint_id="3014F711A000000BAD0C0DED",
                                    lookup_url=lookup_url)
        await home.get_current_state()
    yield home
async def no_ssl_fake_async_home(fake_cloud, event_loop):
    home = AsyncHome(event_loop)
    home._connection._websession.post = partial(
        home._connection._websession.post, ssl=False)

    lookup_url = "{}/getHost".format(fake_cloud.url)
    home._fake_cloud = fake_cloud
    home.set_auth_token(
        "8A45BAA53BE37E3FCA58E9976EFA4C497DAFE55DB997DB9FD685236E5E63ED7DE")
    await home._connection.init(accesspoint_id="3014F711A000000BAD0C0DED",
                                lookup_url=lookup_url)
    await home.get_current_state()

    yield home

    await home._connection._websession.close()
Esempio n. 4
0
    async def get_hap(self, hass: HomeAssistant, hapid: str, authtoken: str,
                      name: str) -> AsyncHome:
        """Create a HomematicIP access point object."""
        home = AsyncHome(hass.loop, async_get_clientsession(hass))

        home.name = name
        home.label = 'Access Point'
        home.modelType = 'HmIP-HAP'

        home.set_auth_token(authtoken)
        try:
            await home.init(hapid)
            await home.get_current_state()
        except HmipConnectionError:
            raise HmipcConnectionError
        home.on_update(self.async_update)
        hass.loop.create_task(self.async_connect())

        return home
Esempio n. 5
0
    async def get_hap(self, hass, hapid, authtoken, name):
        """Create a HomematicIP access point object."""
        from homematicip.aio.home import AsyncHome
        from homematicip.base.base_connection import HmipConnectionError

        home = AsyncHome(hass.loop, async_get_clientsession(hass))

        home.name = name
        home.label = 'Access Point'
        home.modelType = 'HmIP-HAP'

        home.set_auth_token(authtoken)
        try:
            await home.init(hapid)
            await home.get_current_state()
        except HmipConnectionError:
            raise HmipcConnectionError
        home.on_update(self.async_update)
        hass.loop.create_task(self.async_connect())

        return home
Esempio n. 6
0
async def get_home(loop):
    home = AsyncHome(loop)
    home.set_auth_token(config.AUTH_TOKEN)
    await home.init(config.ACCESS_POINT)
    return home