diff --git a/.strict-typing b/.strict-typing index 6f08b8e6e14..f2bef7f82dd 100644 --- a/.strict-typing +++ b/.strict-typing @@ -131,6 +131,7 @@ homeassistant.components.bring.* homeassistant.components.brother.* homeassistant.components.browser.* homeassistant.components.bryant_evolution.* +homeassistant.components.bsblan.* homeassistant.components.bthome.* homeassistant.components.button.* homeassistant.components.calendar.* diff --git a/homeassistant/components/bsblan/climate.py b/homeassistant/components/bsblan/climate.py index c6de76d056b..6a6aa46b9e9 100644 --- a/homeassistant/components/bsblan/climate.py +++ b/homeassistant/components/bsblan/climate.py @@ -101,16 +101,16 @@ class BSBLANClimate(BSBLanEntity, ClimateEntity): @property def current_temperature(self) -> float | None: """Return the current temperature.""" - if self.coordinator.data.state.current_temperature is None: + if (current_temp := self.coordinator.data.state.current_temperature) is None: return None - return self.coordinator.data.state.current_temperature.value + return current_temp.value @property def target_temperature(self) -> float | None: """Return the temperature we try to reach.""" - if self.coordinator.data.state.target_temperature is None: + if (target_temp := self.coordinator.data.state.target_temperature) is None: return None - return self.coordinator.data.state.target_temperature.value + return target_temp.value @property def _hvac_mode_value(self) -> int | str | None: diff --git a/homeassistant/components/bsblan/coordinator.py b/homeassistant/components/bsblan/coordinator.py index b39376f6f02..f708b05de5e 100644 --- a/homeassistant/components/bsblan/coordinator.py +++ b/homeassistant/components/bsblan/coordinator.py @@ -1,7 +1,10 @@ """DataUpdateCoordinator for the BSB-Lan integration.""" +from __future__ import annotations + from dataclasses import dataclass from datetime import timedelta +from typing import TYPE_CHECKING from bsblan import ( BSBLAN, @@ -14,7 +17,6 @@ from bsblan import ( State, ) -from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_HOST from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed @@ -22,6 +24,9 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, Upda from .const import DOMAIN, LOGGER, SCAN_INTERVAL_FAST, SCAN_INTERVAL_SLOW +if TYPE_CHECKING: + from . import BSBLanConfigEntry + # Filter lists for optimized API calls - only fetch parameters we actually use # This significantly reduces response time (~0.2s per parameter saved) STATE_INCLUDE = ["current_temperature", "target_temperature", "hvac_mode"] @@ -54,12 +59,12 @@ class BSBLanSlowData: class BSBLanCoordinator[T](DataUpdateCoordinator[T]): """Base BSB-Lan coordinator.""" - config_entry: ConfigEntry + config_entry: BSBLanConfigEntry def __init__( self, hass: HomeAssistant, - config_entry: ConfigEntry, + config_entry: BSBLanConfigEntry, client: BSBLAN, name: str, update_interval: timedelta, @@ -81,7 +86,7 @@ class BSBLanFastCoordinator(BSBLanCoordinator[BSBLanFastData]): def __init__( self, hass: HomeAssistant, - config_entry: ConfigEntry, + config_entry: BSBLanConfigEntry, client: BSBLAN, ) -> None: """Initialize the BSB-Lan fast coordinator.""" @@ -126,7 +131,7 @@ class BSBLanSlowCoordinator(BSBLanCoordinator[BSBLanSlowData]): def __init__( self, hass: HomeAssistant, - config_entry: ConfigEntry, + config_entry: BSBLanConfigEntry, client: BSBLAN, ) -> None: """Initialize the BSB-Lan slow coordinator.""" diff --git a/homeassistant/components/bsblan/water_heater.py b/homeassistant/components/bsblan/water_heater.py index f871e890f0d..a4aa23f96f3 100644 --- a/homeassistant/components/bsblan/water_heater.py +++ b/homeassistant/components/bsblan/water_heater.py @@ -110,27 +110,28 @@ class BSBLANWaterHeater(BSBLanDualCoordinatorEntity, WaterHeaterEntity): @property def current_operation(self) -> str | None: """Return current operation.""" - if self.coordinator.data.dhw.operating_mode is None: + if (operating_mode := self.coordinator.data.dhw.operating_mode) is None: return None # The operating_mode.value is an integer (0=Off, 1=On, 2=Eco) - current_mode_value = self.coordinator.data.dhw.operating_mode.value - if isinstance(current_mode_value, int): - return BSBLAN_TO_HA_OPERATION_MODE.get(current_mode_value) + if isinstance(operating_mode.value, int): + return BSBLAN_TO_HA_OPERATION_MODE.get(operating_mode.value) return None @property def current_temperature(self) -> float | None: """Return the current temperature.""" - if self.coordinator.data.dhw.dhw_actual_value_top_temperature is None: + if ( + current_temp := self.coordinator.data.dhw.dhw_actual_value_top_temperature + ) is None: return None - return self.coordinator.data.dhw.dhw_actual_value_top_temperature.value + return current_temp.value @property def target_temperature(self) -> float | None: """Return the temperature we try to reach.""" - if self.coordinator.data.dhw.nominal_setpoint is None: + if (target_temp := self.coordinator.data.dhw.nominal_setpoint) is None: return None - return self.coordinator.data.dhw.nominal_setpoint.value + return target_temp.value async def async_set_temperature(self, **kwargs: Any) -> None: """Set new target temperature.""" diff --git a/mypy.ini b/mypy.ini index d32fc0567dc..814b8ce0402 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1065,6 +1065,16 @@ disallow_untyped_defs = true warn_return_any = true warn_unreachable = true +[mypy-homeassistant.components.bsblan.*] +check_untyped_defs = true +disallow_incomplete_defs = true +disallow_subclassing_any = true +disallow_untyped_calls = true +disallow_untyped_decorators = true +disallow_untyped_defs = true +warn_return_any = true +warn_unreachable = true + [mypy-homeassistant.components.bthome.*] check_untyped_defs = true disallow_incomplete_defs = true