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:
Willem-Jan van Rootselaar 2024-08-12 10:57:51 +02:00 committed by GitHub
parent e64ca7c274
commit 8cfac68317
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 21 additions and 17 deletions

View File

@ -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,

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"]
}

View File

@ -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

View File

@ -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