@@ -61,7 +61,7 @@ def pw_notification_updater(devs, d_id, d_dict, notifs):
6161 devs [d_id ]["binary_sensors" ][item ] = notifs != {}
6262
6363
64- def update_helper (data , devs , d_dict , d_id , e_type , key ):
64+ def update_helper (data , devs , d_dict , d_id , e_type , key ) -> None :
6565 """Helper-function for async_update()."""
6666 for dummy in d_dict [e_type ]:
6767 if key != dummy :
@@ -72,7 +72,7 @@ def update_helper(data, devs, d_dict, d_id, e_type, key):
7272 devs [d_id ][e_type ][item ] = data [key ]
7373
7474
75- def check_model (name , v_name ):
75+ def check_model (name , v_name ) -> str :
7676 """Model checking before using version_to_model."""
7777 if v_name in ["Plugwise" , "Plugwise B.V." ]:
7878 if name == "ThermoTouch" :
@@ -84,24 +84,24 @@ def check_model(name, v_name):
8484 return name
8585
8686
87- def schemas_schedule_temp (schedules , name ):
87+ def schemas_schedule_temp (schedules , name ) -> float :
8888 """Helper-function for schemas().
8989 Obtain the schedule temperature of the schema/schedule.
9090 """
9191 if name == "None" :
9292 return # pragma: no cover
9393
94- schema_list = []
94+ schema_list : list [ str ] | None = [] # ???
9595 for period , temp in schedules [name ].items ():
96- tmp_list = []
96+ tmp_list : list [ tuple [ str , str , float ]] = []
9797 moment , dummy = period .split ("," )
9898 moment = moment .replace ("[" , "" ).split (" " )
9999 day_nr = DAYS .get (moment [0 ], "None" )
100100 start_time = dt .datetime .strptime (moment [1 ], "%H:%M" ).time ()
101101 tmp_list .extend ((day_nr , start_time , temp ))
102102 schema_list .append (tmp_list )
103103
104- length = len (schema_list )
104+ length : int = len (schema_list )
105105 schema_list = sorted (schema_list )
106106
107107 # Schema with less than 2 items
@@ -303,7 +303,7 @@ def __init__(self):
303303 self .smile_type : str = None
304304 self .smile_version : list [str ] = []
305305
306- def _locations_legacy (self ):
306+ def _locations_legacy (self ) -> None :
307307 """Helper-function for _all_locations().
308308 Create locations for legacy devices.
309309 """
@@ -347,7 +347,7 @@ def _locations_specials(self, loc, location):
347347
348348 return loc
349349
350- def _all_locations (self ):
350+ def _all_locations (self ) -> None :
351351 """Collect all locations."""
352352 loc = Munch ()
353353
@@ -360,7 +360,7 @@ def _all_locations(self):
360360 loc .name = location .find ("name" ).text
361361 loc .id = location .attrib ["id" ]
362362 # Filter the valid single location for P1 legacy: services not empty
363- locator = ".//services"
363+ locator : str = ".//services"
364364 if (
365365 self ._smile_legacy
366366 and self .smile_type == "power"
@@ -388,20 +388,20 @@ def _all_locations(self):
388388
389389 return
390390
391- def _get_module_data (self , appliance , locator , mod_type ):
391+ def _get_module_data (self , appliance , locator , mod_type ) -> list [ str | None ] :
392392 """Helper-function for _energy_device_info_finder() and _appliance_info_finder().
393393 Collect requested info from MODULES.
394394 """
395395 appl_search = appliance .find (locator )
396396 if appl_search is not None :
397- link_id = appl_search .attrib ["id" ]
398- locator = f".//{ mod_type } [@id='{ link_id } ']...."
399- module = self ._modules .find (locator )
397+ link_id : str = appl_search .attrib ["id" ]
398+ locator : str = f".//{ mod_type } [@id='{ link_id } ']...."
399+ module : etree | None = self ._modules .find (locator )
400400 if module is not None :
401- v_name = module .find ("vendor_name" ).text
402- v_model = module .find ("vendor_model" ).text
403- hw_version = module .find ("hardware_version" ).text
404- fw_version = module .find ("firmware_version" ).text
401+ v_name : str = module .find ("vendor_name" ).text
402+ v_model : str = module .find ("vendor_model" ).text
403+ hw_version : str = module .find ("hardware_version" ).text
404+ fw_version : str = module .find ("firmware_version" ).text
405405
406406 return [v_name , v_model , hw_version , fw_version ]
407407 return [None , None , None , None ]
@@ -411,8 +411,8 @@ def _energy_device_info_finder(self, appliance, appl):
411411 Collect energy device info (Circle, Plug, Stealth): firmware, model and vendor name.
412412 """
413413 if self ._stretch_v2 or self ._stretch_v3 :
414- locator = ".//services/electricity_point_meter"
415- mod_type = "electricity_point_meter"
414+ locator : str = ".//services/electricity_point_meter"
415+ mod_type : str = "electricity_point_meter"
416416 module_data = self ._get_module_data (appliance , locator , mod_type )
417417 appl .v_name = module_data [0 ]
418418 if appl .model != "Switchgroup" :
@@ -442,9 +442,11 @@ def _appliance_info_finder(self, appliance, appl):
442442 appl .v_name = "Plugwise B.V."
443443
444444 # Adam: check for cooling capability and active heating/cooling operation-mode
445- mode_list = []
446- locator = "./actuator_functionalities/regulation_mode_control_functionality"
447- search = appliance .find (locator )
445+ mode_list : list [str ] = []
446+ locator : str = (
447+ "./actuator_functionalities/regulation_mode_control_functionality"
448+ )
449+ search : etree | None = appliance .find (locator )
448450 if search is not None :
449451 if search .find ("mode" ) is not None :
450452 self .cooling_active = search .find ("mode" ).text == "cooling"
@@ -457,7 +459,7 @@ def _appliance_info_finder(self, appliance, appl):
457459
458460 if appl .pwclass in THERMOSTAT_CLASSES :
459461 locator = ".//logs/point_log[type='thermostat']/thermostat"
460- mod_type = "thermostat"
462+ mod_type : str = "thermostat"
461463 module_data = self ._get_module_data (appliance , locator , mod_type )
462464 appl .v_name = module_data [0 ]
463465 appl .model = check_model (module_data [1 ], appl .v_name )
@@ -481,8 +483,8 @@ def _appliance_info_finder(self, appliance, appl):
481483
482484 self ._heater_id = appliance .attrib ["id" ]
483485 appl .name = "OpenTherm"
484- locator1 = ".//logs/point_log[type='flame_state']/boiler_state"
485- locator2 = ".//services/boiler_state"
486+ locator1 : str = ".//logs/point_log[type='flame_state']/boiler_state"
487+ locator2 : str = ".//services/boiler_state"
486488 mod_type = "boiler_state"
487489 module_data = self ._get_module_data (appliance , locator1 , mod_type )
488490 if module_data == [None , None , None , None ]:
@@ -517,9 +519,11 @@ def _appliance_types_finder(self, appliance, appl):
517519 appl .types = self ._loc_data [self ._home_location ]["types" ]
518520
519521 # Determine appliance_type from functionality
520- relay_func = appliance .find (".//actuator_functionalities/relay_functionality" )
521- relay_act = appliance .find (".//actuators/relay" )
522- thermo_func = appliance .find (
522+ relay_func : etree | None = appliance .find (
523+ ".//actuator_functionalities/relay_functionality"
524+ )
525+ relay_act : etree | None = appliance .find (".//actuators/relay" )
526+ thermo_func : etree | None = appliance .find (
523527 ".//actuator_functionalities/thermostat_functionality"
524528 )
525529 if relay_func is not None or relay_act is not None :
@@ -529,7 +533,7 @@ def _appliance_types_finder(self, appliance, appl):
529533
530534 return appl
531535
532- def _all_appliances (self ):
536+ def _all_appliances (self ) -> None :
533537 """Collect all appliances with relevant info."""
534538 self ._all_locations ()
535539
@@ -563,10 +567,10 @@ def _all_appliances(self):
563567 )
564568
565569 # The presence of either indicates a local active device, e.g. heat-pump or gas-fired heater
566- ch_state = self ._appliances .find (
570+ ch_state : etree | None = self ._appliances .find (
567571 ".//logs/point_log[type='central_heating_state']"
568572 )
569- ot_fault_code = self ._appliances .find (
573+ ot_fault_code : etree | None = self ._appliances .find (
570574 ".//logs/point_log[type='open_therm_oem_fault_code']"
571575 )
572576 self ._opentherm_device = ch_state is not None and ot_fault_code is not None
@@ -582,7 +586,7 @@ def _all_appliances(self):
582586 appl .location = None
583587 appl .types = set ()
584588
585- appl .id = appliance .attrib ["id" ]
589+ appl .dev_id = appliance .attrib ["id" ]
586590 appl .name = appliance .find ("name" ).text
587591 appl .model = appl .pwclass .replace ("_" , " " ).title ()
588592 appl .fw = None
@@ -597,7 +601,7 @@ def _all_appliances(self):
597601 if not appl :
598602 continue
599603
600- self ._appl_data [appl .id ] = {
604+ self ._appl_data [appl .dev_id ] = {
601605 "class" : appl .pwclass ,
602606 "fw" : appl .fw ,
603607 "location" : appl .location ,
@@ -610,7 +614,7 @@ def _all_appliances(self):
610614 and appl .pwclass == "thermostat"
611615 and appl .location is None
612616 ):
613- self ._appl_data .pop (appl .id )
617+ self ._appl_data .pop (appl .dev_id )
614618
615619 def _match_locations (self ):
616620 """Helper-function for _scan_thermostats().
0 commit comments