Pass aiohttp clientsession to tedee integration (#107089)

* pass aiohttpsession

* Update homeassistant/components/tedee/config_flow.py

Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com>

* Update homeassistant/components/tedee/__init__.py

Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com>

* move to coordinator

---------

Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com>
This commit is contained in:
Josef Zweck 2024-01-04 21:42:38 +01:00 committed by GitHub
parent fd3a546cd8
commit 34e6fa3328
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 4 deletions

View File

@ -13,6 +13,7 @@ import voluptuous as vol
from homeassistant.config_entries import ConfigEntry, ConfigFlow
from homeassistant.const import CONF_HOST
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import CONF_LOCAL_ACCESS_TOKEN, DOMAIN, NAME
@ -34,7 +35,11 @@ class TedeeConfigFlow(ConfigFlow, domain=DOMAIN):
else:
host = user_input[CONF_HOST]
local_access_token = user_input[CONF_LOCAL_ACCESS_TOKEN]
tedee_client = TedeeClient(local_token=local_access_token, local_ip=host)
tedee_client = TedeeClient(
local_token=local_access_token,
local_ip=host,
session=async_get_clientsession(self.hass),
)
try:
local_bridge = await tedee_client.get_local_bridge()
except (TedeeAuthException, TedeeLocalAuthException):

View File

@ -17,6 +17,7 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_HOST
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from .const import CONF_LOCAL_ACCESS_TOKEN, DOMAIN
@ -45,6 +46,7 @@ class TedeeApiCoordinator(DataUpdateCoordinator[dict[int, TedeeLock]]):
self.tedee_client = TedeeClient(
local_token=self.config_entry.data[CONF_LOCAL_ACCESS_TOKEN],
local_ip=self.config_entry.data[CONF_HOST],
session=async_get_clientsession(hass),
)
self._next_get_locks = time.time()

View File

@ -6,5 +6,5 @@
"dependencies": ["http"],
"documentation": "https://www.home-assistant.io/integrations/tedee",
"iot_class": "local_push",
"requirements": ["pytedee-async==0.2.1"]
"requirements": ["pytedee-async==0.2.6"]
}

View File

@ -2135,7 +2135,7 @@ pytankerkoenig==0.0.6
pytautulli==23.1.1
# homeassistant.components.tedee
pytedee-async==0.2.1
pytedee-async==0.2.6
# homeassistant.components.tfiac
pytfiac==0.4

View File

@ -1635,7 +1635,7 @@ pytankerkoenig==0.0.6
pytautulli==23.1.1
# homeassistant.components.tedee
pytedee-async==0.2.1
pytedee-async==0.2.6
# homeassistant.components.motionmount
python-MotionMount==0.3.1