Skip to content

Commit

Permalink
Pass aiohttp clientsession to tedee integration (#107089)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
zweckj and autinerd authored Jan 4, 2024
1 parent fd3a546 commit 34e6fa3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
7 changes: 6 additions & 1 deletion homeassistant/components/tedee/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
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

Expand All @@ -34,7 +35,11 @@ async def async_step_user(
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):
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/tedee/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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
Expand Down Expand Up @@ -45,6 +46,7 @@ def __init__(self, hass: HomeAssistant) -> None:
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()
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/tedee/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 34e6fa3

Please sign in to comment.