@@ -54,6 +54,21 @@ def collect_power_values(
5454 data ["sensors" ][key ] = loc .f_val
5555
5656
57+ def get_zigbee_data (module : etree , module_data : ModuleData , legacy : bool ) -> None :
58+ """Helper-function for _get_module_data()."""
59+ if legacy :
60+ # Stretches
61+ if (router := module .find ("./protocols/network_router" )) is not None :
62+ module_data ["zigbee_mac_address" ] = router .find ("mac_address" ).text
63+ # Also look for the Circle+/Stealth M+
64+ if (coord := module .find ("./protocols/network_coordinator" )) is not None :
65+ module_data ["zigbee_mac_address" ] = coord .find ("mac_address" ).text
66+ # Adam
67+ elif (zb_node := module .find ("./protocols/zig_bee_node" )) is not None :
68+ module_data ["zigbee_mac_address" ] = zb_node .find ("mac_address" ).text
69+ module_data ["reachable" ] = zb_node .find ("reachable" ).text == "true"
70+
71+
5772def power_data_peak_value (loc : Munch , legacy : bool ) -> Munch :
5873 """Helper-function for _power_data_from_location() and _power_data_from_modules()."""
5974 loc .found = True
@@ -310,22 +325,6 @@ def _get_module_data(
310325 module_data ["vendor_model" ] = module .find ("vendor_model" ).text
311326 module_data ["hardware_version" ] = module .find ("hardware_version" ).text
312327 module_data ["firmware_version" ] = module .find ("firmware_version" ).text
313- self . _get_zigbee_data (module , module_data , legacy )
328+ get_zigbee_data (module , module_data , legacy )
314329
315330 return module_data
316-
317- def _get_zigbee_data (
318- self , module : etree , module_data : ModuleData , legacy : bool
319- ) -> None :
320- """Helper-function for _get_module_data()."""
321- if legacy :
322- # Stretches
323- if (router := module .find ("./protocols/network_router" )) is not None :
324- module_data ["zigbee_mac_address" ] = router .find ("mac_address" ).text
325- # Also look for the Circle+/Stealth M+
326- if (coord := module .find ("./protocols/network_coordinator" )) is not None :
327- module_data ["zigbee_mac_address" ] = coord .find ("mac_address" ).text
328- # Adam
329- elif (zb_node := module .find ("./protocols/zig_bee_node" )) is not None :
330- module_data ["zigbee_mac_address" ] = zb_node .find ("mac_address" ).text
331- module_data ["reachable" ] = zb_node .find ("reachable" ).text == "true"
0 commit comments