@@ -96,14 +96,11 @@ class BSBLAN:
9696 _close_session : bool = False
9797 _firmware_version : str | None = None
9898 _api_version : str | None = None
99- _min_temp : float | None = None
100- _max_temp : float | None = None
101- _temperature_range_initialized : bool = False
10299 _api_data : APIConfig | None = None
103100 _initialized : bool = False
104101 _api_validator : APIValidator = field (init = False )
105102 _temperature_unit : str = "°C"
106- # Per-circuit temperature ranges: circuit_number -> ( min, max, initialized)
103+ # Per-circuit temperature ranges: circuit_number -> { min, max}
107104 _circuit_temp_ranges : dict [int , dict [str , float | None ]] = field (
108105 default_factory = dict ,
109106 )
@@ -345,7 +342,7 @@ async def _ensure_hot_water_group_validated(
345342 return
346343
347344 # Request only these specific parameters from the device
348- params = await self ._extract_params_summary (group_params )
345+ params = self ._extract_params_summary (group_params )
349346 response_data = await self ._request (
350347 params = {"Parameter" : params ["string_par" ]}
351348 )
@@ -386,39 +383,6 @@ async def _ensure_hot_water_group_validated(
386383 len (params_to_remove ),
387384 )
388385
389- async def _initialize_api_validator (self ) -> None :
390- """Initialize and validate API data against device capabilities.
391-
392- DEPRECATED: This method validates all sections upfront.
393- Use _setup_api_validator() + _ensure_section_validated() for lazy loading.
394- This method is kept for backwards compatibility.
395- """
396- if self ._api_version is None :
397- raise BSBLANError (ErrorMsg .API_VERSION )
398-
399- # Initialize API data if not already done
400- if self ._api_data is None :
401- self ._api_data = self ._copy_api_config ()
402-
403- # Initialize the API validator
404- self ._api_validator = APIValidator (self ._api_data )
405-
406- # Perform initial validation of each section (eager loading)
407- sections : list [SectionLiteral ] = [
408- "heating" ,
409- "sensor" ,
410- "staticValues" ,
411- "device" ,
412- "hot_water" ,
413- ]
414- for section in sections :
415- response_data = await self ._validate_api_section (section )
416-
417- # Extract temperature unit from heating section validation
418- # (parameter 710 - target_temperature is always in heating section)
419- if section == "heating" and response_data :
420- self ._extract_temperature_unit_from_response (response_data )
421-
422386 async def _validate_api_section (
423387 self , section : SectionLiteral , include : list [str ] | None = None
424388 ) -> dict [str , Any ] | None :
@@ -466,7 +430,7 @@ async def _validate_api_section(
466430
467431 try :
468432 # Request data from device for validation
469- params = await self ._extract_params_summary (section_data )
433+ params = self ._extract_params_summary (section_data )
470434 response_data = await self ._request (
471435 params = {"Parameter" : params ["string_par" ]}
472436 )
@@ -635,22 +599,12 @@ async def _initialize_temperature_range(
635599 from the response (parameter 710), so no extra API call is needed here.
636600
637601 """
638- if circuit == 1 and self ._temperature_range_initialized :
639- return
640- if circuit != 1 and circuit in self ._circuit_temp_initialized :
602+ if circuit in self ._circuit_temp_initialized :
641603 return
642604
643605 temp_range = await self ._fetch_temperature_range (circuit )
644-
645- if circuit == 1 :
646- # HC1 uses legacy fields for backwards compatibility
647- self ._min_temp = temp_range ["min" ]
648- self ._max_temp = temp_range ["max" ]
649- self ._temperature_range_initialized = True
650- else :
651- # HC2 uses per-circuit storage
652- self ._circuit_temp_ranges [circuit ] = temp_range
653- self ._circuit_temp_initialized .add (circuit )
606+ self ._circuit_temp_ranges [circuit ] = temp_range
607+ self ._circuit_temp_initialized .add (circuit )
654608
655609 def _validate_circuit (self , circuit : int ) -> None :
656610 """Validate the circuit number.
@@ -680,23 +634,6 @@ def get_temperature_unit(self) -> str:
680634 """
681635 return self ._temperature_unit
682636
683- async def _initialize_api_data (self ) -> APIConfig :
684- """Initialize and cache the API data.
685-
686- Returns:
687- APIConfig: The API configuration data.
688-
689- Raises:
690- BSBLANError: If the API version or data is not initialized.
691-
692- """
693- if self ._api_data is None :
694- self ._api_data = self ._copy_api_config ()
695- logger .debug ("API data initialized for version: %s" , self ._api_version )
696- if self ._api_data is None :
697- raise BSBLANError (ErrorMsg .API_DATA_NOT_INITIALIZED )
698- return self ._api_data
699-
700637 def _copy_api_config (self ) -> APIConfig :
701638 """Create a copy of the API configuration for the current version.
702639
@@ -900,7 +837,7 @@ def _validate_single_parameter(self, *params: Any, error_msg: str) -> None:
900837 if sum (param is not None for param in params ) != 1 :
901838 raise BSBLANError (error_msg )
902839
903- async def _extract_params_summary (self , params : dict [Any , Any ]) -> dict [Any , Any ]:
840+ def _extract_params_summary (self , params : dict [Any , Any ]) -> dict [Any , Any ]:
904841 """Get the parameters info from BSBLAN device.
905842
906843 Args:
@@ -961,7 +898,7 @@ async def _fetch_section_data(
961898 if not section_params :
962899 raise BSBLANError (ErrorMsg .INVALID_INCLUDE_PARAMS )
963900
964- params = await self ._extract_params_summary (section_params )
901+ params = self ._extract_params_summary (section_params )
965902 data = await self ._request (params = {"Parameter" : params ["string_par" ]})
966903 data = dict (zip (params ["list" ], list (data .values ()), strict = True ))
967904 return model_class .model_validate (data )
@@ -1219,21 +1156,12 @@ async def _validate_target_temperature(
12191156 raise BSBLANInvalidParameterError (target_temperature ) from err
12201157
12211158 # Try to load temperature range for bounds checking
1222- if circuit == 1 :
1223- # HC1 uses legacy fields for backwards compatibility
1224- if self ._min_temp is None or self ._max_temp is None :
1225- await self ._initialize_temperature_range (circuit )
1226-
1227- min_temp = self ._min_temp
1228- max_temp = self ._max_temp
1229- else :
1230- # HC2 uses per-circuit storage
1231- if circuit not in self ._circuit_temp_initialized :
1232- await self ._initialize_temperature_range (circuit )
1159+ if circuit not in self ._circuit_temp_initialized :
1160+ await self ._initialize_temperature_range (circuit )
12331161
1234- temp_range = self ._circuit_temp_ranges .get (circuit , {})
1235- min_temp = temp_range .get ("min" )
1236- max_temp = temp_range .get ("max" )
1162+ temp_range = self ._circuit_temp_ranges .get (circuit , {})
1163+ min_temp = temp_range .get ("min" )
1164+ max_temp = temp_range .get ("max" )
12371165
12381166 # Skip range validation if device doesn't provide min/max
12391167 if min_temp is None or max_temp is None :
@@ -1337,7 +1265,7 @@ async def _fetch_hot_water_data(
13371265 if not filtered_params :
13381266 raise BSBLANError (error_msg )
13391267
1340- params = await self ._extract_params_summary (filtered_params )
1268+ params = self ._extract_params_summary (filtered_params )
13411269 data = await self ._request (params = {"Parameter" : params ["string_par" ]})
13421270 data = dict (zip (params ["list" ], list (data .values ()), strict = True ))
13431271 return model_class .model_validate (data )
0 commit comments