Use shared clientsession for sense (#46419)
This commit is contained in:
parent
e3ae3cfb83
commit
6f4df7e52e
6 changed files with 15 additions and 6 deletions
|
@ -2,7 +2,7 @@
|
|||
"domain": "emulated_kasa",
|
||||
"name": "Emulated Kasa",
|
||||
"documentation": "https://www.home-assistant.io/integrations/emulated_kasa",
|
||||
"requirements": ["sense_energy==0.8.1"],
|
||||
"requirements": ["sense_energy==0.9.0"],
|
||||
"codeowners": ["@kbickar"],
|
||||
"quality_scale": "internal"
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
|||
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, CONF_TIMEOUT
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
from homeassistant.helpers.event import async_track_time_interval
|
||||
|
@ -96,7 +97,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||
password = entry_data[CONF_PASSWORD]
|
||||
timeout = entry_data[CONF_TIMEOUT]
|
||||
|
||||
gateway = ASyncSenseable(api_timeout=timeout, wss_timeout=timeout)
|
||||
client_session = async_get_clientsession(hass)
|
||||
|
||||
gateway = ASyncSenseable(
|
||||
api_timeout=timeout, wss_timeout=timeout, client_session=client_session
|
||||
)
|
||||
gateway.rate_limit = ACTIVE_UPDATE_RATE
|
||||
|
||||
try:
|
||||
|
|
|
@ -6,6 +6,7 @@ import voluptuous as vol
|
|||
|
||||
from homeassistant import config_entries, core
|
||||
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, CONF_TIMEOUT
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
||||
from .const import ACTIVE_UPDATE_RATE, DEFAULT_TIMEOUT, SENSE_TIMEOUT_EXCEPTIONS
|
||||
from .const import DOMAIN # pylint:disable=unused-import; pylint:disable=unused-import
|
||||
|
@ -27,8 +28,11 @@ async def validate_input(hass: core.HomeAssistant, data):
|
|||
Data has the keys from DATA_SCHEMA with values provided by the user.
|
||||
"""
|
||||
timeout = data[CONF_TIMEOUT]
|
||||
client_session = async_get_clientsession(hass)
|
||||
|
||||
gateway = ASyncSenseable(api_timeout=timeout, wss_timeout=timeout)
|
||||
gateway = ASyncSenseable(
|
||||
api_timeout=timeout, wss_timeout=timeout, client_session=client_session
|
||||
)
|
||||
gateway.rate_limit = ACTIVE_UPDATE_RATE
|
||||
await gateway.authenticate(data[CONF_EMAIL], data[CONF_PASSWORD])
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"domain": "sense",
|
||||
"name": "Sense",
|
||||
"documentation": "https://www.home-assistant.io/integrations/sense",
|
||||
"requirements": ["sense_energy==0.8.1"],
|
||||
"requirements": ["sense_energy==0.9.0"],
|
||||
"codeowners": ["@kbickar"],
|
||||
"config_flow": true,
|
||||
"dhcp": [{"hostname":"sense-*","macaddress":"009D6B*"}, {"hostname":"sense-*","macaddress":"DCEFCA*"}]
|
||||
|
|
|
@ -2010,7 +2010,7 @@ sense-hat==2.2.0
|
|||
|
||||
# homeassistant.components.emulated_kasa
|
||||
# homeassistant.components.sense
|
||||
sense_energy==0.8.1
|
||||
sense_energy==0.9.0
|
||||
|
||||
# homeassistant.components.sentry
|
||||
sentry-sdk==0.20.1
|
||||
|
|
|
@ -1026,7 +1026,7 @@ scapy==2.4.4
|
|||
|
||||
# homeassistant.components.emulated_kasa
|
||||
# homeassistant.components.sense
|
||||
sense_energy==0.8.1
|
||||
sense_energy==0.9.0
|
||||
|
||||
# homeassistant.components.sentry
|
||||
sentry-sdk==0.20.1
|
||||
|
|
Loading…
Add table
Reference in a new issue