mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Bump BSBLan to 0.6.2 (#123594)
* chore: Update bsblan library to version 0.6.1 * add dataclass BSBLANConfig remove session as bsblan has it's own session * Update temperature unit handling in BSBLANClimate * chore: Remove unused constant in bsblan/const.py * chore: Update python-bsblan library to version 0.6.2 * feat: Add async_get_clientsession to BSBLAN initialization This commit adds the `async_get_clientsession` function to the initialization of the `BSBLAN` class in both `__init__.py` and `config_flow.py` files. This allows the `BSBLAN` instance to have its own session for making HTTP requests. This change improves the performance and reliability of the BSBLAN integration.
This commit is contained in:
parent
e64ca7c274
commit
8cfac68317
@ -2,7 +2,7 @@
|
||||
|
||||
import dataclasses
|
||||
|
||||
from bsblan import BSBLAN, Device, Info, StaticState
|
||||
from bsblan import BSBLAN, BSBLANConfig, Device, Info, StaticState
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
@ -35,22 +35,28 @@ class HomeAssistantBSBLANData:
|
||||
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],
|
||||
# create config using BSBLANConfig
|
||||
config = BSBLANConfig(
|
||||
host=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,
|
||||
)
|
||||
|
||||
# create BSBLAN client
|
||||
session = async_get_clientsession(hass)
|
||||
bsblan = BSBLAN(config, session)
|
||||
|
||||
# Create and perform first refresh of the coordinator
|
||||
coordinator = BSBLanUpdateCoordinator(hass, entry, bsblan)
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
|
||||
# Fetch all required data concurrently
|
||||
device = await bsblan.device()
|
||||
info = await bsblan.info()
|
||||
static = await bsblan.static_values()
|
||||
|
||||
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = HomeAssistantBSBLANData(
|
||||
client=bsblan,
|
||||
coordinator=coordinator,
|
||||
|
@ -103,7 +103,7 @@ class BSBLANClimate(
|
||||
self._attr_min_temp = float(static.min_temp.value)
|
||||
self._attr_max_temp = float(static.max_temp.value)
|
||||
# check if self.coordinator.data.current_temperature.unit is "°C" or "°C"
|
||||
if self.coordinator.data.current_temperature.unit in ("°C", "°C"):
|
||||
if static.min_temp.unit in ("°C", "°C"):
|
||||
self._attr_temperature_unit = UnitOfTemperature.CELSIUS
|
||||
else:
|
||||
self._attr_temperature_unit = UnitOfTemperature.FAHRENHEIT
|
||||
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from bsblan import BSBLAN, BSBLANError
|
||||
from bsblan import BSBLAN, BSBLANConfig, BSBLANError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
@ -80,15 +80,15 @@ class BSBLANFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def _get_bsblan_info(self, raise_on_progress: bool = True) -> None:
|
||||
"""Get device information from an BSBLAN device."""
|
||||
session = async_get_clientsession(self.hass)
|
||||
bsblan = BSBLAN(
|
||||
config = BSBLANConfig(
|
||||
host=self.host,
|
||||
username=self.username,
|
||||
password=self.password,
|
||||
passkey=self.passkey,
|
||||
port=self.port,
|
||||
session=session,
|
||||
username=self.username,
|
||||
password=self.password,
|
||||
)
|
||||
session = async_get_clientsession(self.hass)
|
||||
bsblan = BSBLAN(config, session)
|
||||
device = await bsblan.device()
|
||||
self.mac = device.MAC
|
||||
|
||||
|
@ -21,6 +21,4 @@ ATTR_OUTSIDE_TEMPERATURE: Final = "outside_temperature"
|
||||
|
||||
CONF_PASSKEY: Final = "passkey"
|
||||
|
||||
CONF_DEVICE_IDENT: Final = "RVS21.831F/127"
|
||||
|
||||
DEFAULT_PORT: Final = 80
|
||||
|
@ -7,5 +7,5 @@
|
||||
"integration_type": "device",
|
||||
"iot_class": "local_polling",
|
||||
"loggers": ["bsblan"],
|
||||
"requirements": ["python-bsblan==0.5.19"]
|
||||
"requirements": ["python-bsblan==0.6.2"]
|
||||
}
|
||||
|
@ -2250,7 +2250,7 @@ python-awair==0.2.4
|
||||
python-blockchain-api==0.0.2
|
||||
|
||||
# homeassistant.components.bsblan
|
||||
python-bsblan==0.5.19
|
||||
python-bsblan==0.6.2
|
||||
|
||||
# homeassistant.components.clementine
|
||||
python-clementine-remote==1.0.1
|
||||
|
@ -1795,7 +1795,7 @@ python-MotionMount==2.0.0
|
||||
python-awair==0.2.4
|
||||
|
||||
# homeassistant.components.bsblan
|
||||
python-bsblan==0.5.19
|
||||
python-bsblan==0.6.2
|
||||
|
||||
# homeassistant.components.ecobee
|
||||
python-ecobee-api==0.2.18
|
||||
|
Loading…
x
Reference in New Issue
Block a user