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 :
@@ -206,48 +205,51 @@ def _get_locations(self) -> None:
206205 "Error, location Home (building) not found!"
207206 ) # pragma: no cover
208207
209- def _appliance_info_finder (self , appliance : Appliance ) -> Appliance :
208+ def _appliance_info_finder (self , appliance : Appliance ) -> Appliance | None :
210209 """Collect info for all appliances found."""
210+ print (f"HOI22 appliance type { appliance .type } !" )
211211 match appliance .type :
212- # No longer needed since we have a Gateway
213- # case " gateway":
214- # # Collect gateway entity info
215- # return self._appl_gateway_info(appl, appliance)
212+ case "gateway" :
213+ # Collect gateway entity info
214+ print ( "HOI22 gateway!" )
215+ return self ._appl_gateway_info (appliance )
216216 case _ as dev_class if dev_class in THERMOSTAT_CLASSES :
217217 # Collect thermostat entity info
218- return self ._appl_thermostat_info (appl , appliance )
218+ return self ._appl_thermostat_info (appliance )
219219 case "heater_central" :
220220 # Collect heater_central entity info
221221 # 251016: the added guarding below also solves Core Issue #104433
222222 if not (
223- appl := self ._appl_heater_central_info (appl , appliance , False )
223+ appliance := self ._appl_heater_central_info (appliance , False )
224224 ): # False means non-legacy entity
225225 return Munch ()
226226 self ._dhw_allowed_modes = self ._get_appl_actuator_modes (
227227 appliance , "domestic_hot_water_mode_control_functionality"
228228 )
229- return appl
229+ return appliance
230230 case _ as s if s .endswith ("_plug" ):
231231 # Collect info from plug-types (Plug, Aqara Smart Plug)
232232 locator = MODULE_LOCATOR
233233 module_data = self ._get_module_data (appliance , locator )
234234 # A plug without module-data is orphaned/ no present
235235 if not module_data ["contents" ]:
236- return Munch ()
237-
238- appl .available = module_data ["reachable" ]
239- appl .firmware = module_data ["firmware_version" ]
240- appl .hardware = module_data ["hardware_version" ]
241- appl .model_id = module_data ["vendor_model" ]
242- appl .vendor_name = module_data ["vendor_name" ]
243- appl .model = check_model (appl .model_id , appl .vendor_name )
244- appl .zigbee_mac = module_data ["zigbee_mac_address" ]
245- return appl
236+ return None
237+
238+ print (f"HOI24 { module_data } " )
239+ appliance .available = module_data ["reachable" ]
240+ appliance .firmware_version = module_data ["firmware_version" ]
241+ appliance .hardware_version = module_data ["hardware_version" ]
242+ appliance .model_id = module_data ["vendor_model" ]
243+ appliance .vendor_name = module_data ["vendor_name" ]
244+ appliance .model = check_model (appl .model_id , appl .vendor_name )
245+ appliance .zigbee_mac_address = module_data ["zigbee_mac_address" ]
246+ return appliance
246247 case _: # pragma: no cover
247- return Munch ()
248+ return None
248249
249250 def _appl_gateway_info (self , appliance : Appliance ) -> Appliance :
250251 """Helper-function for _appliance_info_finder()."""
252+ print (f"HOI19 { appliance .id } " )
251253 self ._gateway_id = appliance .id
252254
253255 # Adam: collect the ZigBee MAC address of the Smile
@@ -267,7 +269,7 @@ def _appl_gateway_info(self, appliance: Appliance) -> Appliance:
267269 # Limit the possible gateway-modes
268270 self ._gw_allowed_modes = ["away" , "full" , "vacation" ]
269271
270- return appl
272+ return appliance
271273
272274 def _get_appl_actuator_modes (
273275 self , appliance : etree .Element , actuator_type : str
@@ -601,7 +603,7 @@ def _get_gateway_outdoor_temp(self, entity_id: str, data: GwEntityData) -> None:
601603 if self ._is_thermostat and entity_id == self ._gateway_id :
602604 locator = "./logs/point_log[type='outdoor_temperature']/period/measurement"
603605 if (found := self ._home_location .find (locator )) is not None :
604- value = format_measure (found .text , NONE )
606+ value = format_measure (found .text , None )
605607 data .update ({"sensors" : {"outdoor_temperature" : value }})
606608 self ._count += 1
607609
@@ -905,7 +907,7 @@ def _rule_ids_by_name(self, name: str, loc_id: str) -> dict[str, dict[str, str]]
905907 }
906908 else :
907909 schedule_ids [rule .get ("id" )] = {
908- "location" : NONE ,
910+ "location" : None ,
909911 "name" : name ,
910912 "active" : active ,
911913 }
@@ -932,7 +934,7 @@ def _rule_ids_by_tag(self, tag: str, loc_id: str) -> dict[str, dict[str, str]]:
932934 }
933935 else :
934936 schedule_ids [rule .get ("id" )] = {
935- "location" : NONE ,
937+ "location" : None ,
936938 "name" : name ,
937939 "active" : active ,
938940 }
@@ -945,9 +947,9 @@ def _schedules(self, location: str) -> tuple[list[str], str]:
945947 Obtain the available schedules/schedules. Adam: a schedule can be connected to more than one location.
946948 NEW: when a location_id is present then the schedule is active. Valid for both Adam and non-legacy Anna.
947949 """
948- available : list [str ] = [NONE ]
950+ available : list [str ] = [None ]
949951 rule_ids : dict [str , dict [str , str ]] = {}
950- selected = NONE
952+ selected = None
951953 tag = "zone_preset_based_on_time_and_presence_with_override"
952954 if not (rule_ids := self ._rule_ids_by_tag (tag , location )):
953955 return available , selected
@@ -967,9 +969,9 @@ def _schedules(self, location: str) -> tuple[list[str], str]:
967969 schedules .append (name )
968970
969971 if schedules :
970- available .remove (NONE )
972+ available .remove (None )
971973 available .append (OFF )
972- if selected == NONE :
974+ if selected == None :
973975 selected = OFF
974976
975977 return available , selected
0 commit comments