2626 LOCATIONS ,
2727 LOGGER ,
2828 MODULE_LOCATOR ,
29- NONE ,
3029 OFF ,
3130 P1_MEASUREMENTS ,
3231 TEMP_CELSIUS ,
@@ -80,7 +79,7 @@ def __init__(self) -> None:
8079 self ._is_thermostat : bool
8180 self ._loc_data : dict [str , ThermoLoc ]
8281 self ._schedule_old_states : dict [str , dict [str , str ]]
83- self ._gateway_id : str = NONE
82+ self ._gateway_id : str = None
8483 self ._zones : dict [str , GwEntityData ]
8584 self .gw_entities : dict [str , GwEntityData ]
8685 self .smile : Munch = Munch ()
@@ -131,10 +130,9 @@ def _get_appliances(self) -> None:
131130 ):
132131 appliance .type = f"{ appliance .type } _plug"
133132
134- # TODO: recreate functionality
135- # # Collect appliance info, skip orphaned/removed devices
136- # if not (appl := self._appliance_info_finder(appl, appliance)):
137- # continue
133+ # Collect appliance info, skip orphaned/removed devices
134+ if not self ._appliance_info_finder (appliance ):
135+ continue
138136
139137 # A smartmeter is not present as an appliance, add it specifically
140138 if self .smile .type == "power" or self .smile .anna_p1 :
@@ -182,6 +180,7 @@ def _get_locations(self) -> None:
182180 """Collect all locations."""
183181 counter = 0
184182 loc = Munch ()
183+ print (f"HOI15 { self .data } " )
185184 print (f"HOI15 { self .data .location } " )
186185 locations = self .data .location
187186 if not locations :
@@ -211,48 +210,51 @@ def _get_locations(self) -> None:
211210 "Error, location Home (building) not found!"
212211 ) # pragma: no cover
213212
214- def _appliance_info_finder (self , appliance : Appliance ) -> Appliance :
213+ def _appliance_info_finder (self , appliance : Appliance ) -> Appliance | None :
215214 """Collect info for all appliances found."""
215+ print (f"HOI22 appliance type { appliance .type } !" )
216216 match appliance .type :
217- # No longer needed since we have a Gateway
218- # case " gateway":
219- # # Collect gateway entity info
220- # return self._appl_gateway_info(appl, appliance)
217+ case "gateway" :
218+ # Collect gateway entity info
219+ print ( "HOI22 gateway!" )
220+ return self ._appl_gateway_info (appliance )
221221 case _ as dev_class if dev_class in THERMOSTAT_CLASSES :
222222 # Collect thermostat entity info
223- return self ._appl_thermostat_info (appl , appliance )
223+ return self ._appl_thermostat_info (appliance )
224224 case "heater_central" :
225225 # Collect heater_central entity info
226226 # 251016: the added guarding below also solves Core Issue #104433
227227 if not (
228- appl := self ._appl_heater_central_info (appl , appliance , False )
228+ appliance := self ._appl_heater_central_info (appliance , False )
229229 ): # False means non-legacy entity
230230 return Munch ()
231231 self ._dhw_allowed_modes = self ._get_appl_actuator_modes (
232232 appliance , "domestic_hot_water_mode_control_functionality"
233233 )
234- return appl
234+ return appliance
235235 case _ as s if s .endswith ("_plug" ):
236236 # Collect info from plug-types (Plug, Aqara Smart Plug)
237237 locator = MODULE_LOCATOR
238238 module_data = self ._get_module_data (appliance , locator )
239239 # A plug without module-data is orphaned/ no present
240240 if not module_data ["contents" ]:
241- return Munch ()
242-
243- appl .available = module_data ["reachable" ]
244- appl .firmware = module_data ["firmware_version" ]
245- appl .hardware = module_data ["hardware_version" ]
246- appl .model_id = module_data ["vendor_model" ]
247- appl .vendor_name = module_data ["vendor_name" ]
248- appl .model = check_model (appl .model_id , appl .vendor_name )
249- appl .zigbee_mac = module_data ["zigbee_mac_address" ]
250- return appl
241+ return None
242+
243+ print (f"HOI24 { module_data } " )
244+ appliance .available = module_data ["reachable" ]
245+ appliance .firmware_version = module_data ["firmware_version" ]
246+ appliance .hardware_version = module_data ["hardware_version" ]
247+ appliance .model_id = module_data ["vendor_model" ]
248+ appliance .vendor_name = module_data ["vendor_name" ]
249+ appliance .model = check_model (appl .model_id , appl .vendor_name )
250+ appliance .zigbee_mac_address = module_data ["zigbee_mac_address" ]
251+ return appliance
251252 case _: # pragma: no cover
252- return Munch ()
253+ return None
253254
254255 def _appl_gateway_info (self , appliance : Appliance ) -> Appliance :
255256 """Helper-function for _appliance_info_finder()."""
257+ print (f"HOI19 { appliance .id } " )
256258 self ._gateway_id = appliance .id
257259
258260 # Adam: collect the ZigBee MAC address of the Smile
@@ -272,7 +274,7 @@ def _appl_gateway_info(self, appliance: Appliance) -> Appliance:
272274 # Limit the possible gateway-modes
273275 self ._gw_allowed_modes = ["away" , "full" , "vacation" ]
274276
275- return appl
277+ return appliance
276278
277279 def _get_appl_actuator_modes (
278280 self , appliance : etree .Element , actuator_type : str
@@ -624,7 +626,7 @@ def _get_gateway_outdoor_temp(self, entity_id: str, data: GwEntityData) -> None:
624626 if self ._is_thermostat and entity_id == self ._gateway_id :
625627 locator = "./logs/point_log[type='outdoor_temperature']/period/measurement"
626628 if (found := self ._home_location .find (locator )) is not None :
627- value = format_measure (found .text , NONE )
629+ value = format_measure (found .text , None )
628630 data .update ({"sensors" : {"outdoor_temperature" : value }})
629631 self ._count += 1
630632
@@ -918,7 +920,7 @@ def _rule_ids_by_name(self, name: str, loc_id: str) -> dict[str, dict[str, str]]
918920 }
919921 else :
920922 schedule_ids [rule .get ("id" )] = {
921- "location" : NONE ,
923+ "location" : None ,
922924 "name" : name ,
923925 "active" : active ,
924926 }
@@ -945,7 +947,7 @@ def _rule_ids_by_tag(self, tag: str, loc_id: str) -> dict[str, dict[str, str]]:
945947 }
946948 else :
947949 schedule_ids [rule .get ("id" )] = {
948- "location" : NONE ,
950+ "location" : None ,
949951 "name" : name ,
950952 "active" : active ,
951953 }
@@ -958,9 +960,9 @@ def _schedules(self, location: str) -> tuple[list[str], str]:
958960 Obtain the available schedules/schedules. Adam: a schedule can be connected to more than one location.
959961 NEW: when a location_id is present then the schedule is active. Valid for both Adam and non-legacy Anna.
960962 """
961- available : list [str ] = [NONE ]
963+ available : list [str ] = [None ]
962964 rule_ids : dict [str , dict [str , str ]] = {}
963- selected = NONE
965+ selected = None
964966 tag = "zone_preset_based_on_time_and_presence_with_override"
965967 if not (rule_ids := self ._rule_ids_by_tag (tag , location )):
966968 return available , selected
@@ -980,9 +982,9 @@ def _schedules(self, location: str) -> tuple[list[str], str]:
980982 schedules .append (name )
981983
982984 if schedules :
983- available .remove (NONE )
985+ available .remove (None )
984986 available .append (OFF )
985- if selected == NONE :
987+ if selected == None :
986988 selected = OFF
987989
988990 return available , selected
0 commit comments