File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -63,12 +63,13 @@ def _update_gw_devices(self) -> None:
6363
6464 device .update (data )
6565
66- if (
66+ is_battery_low = (
6767 mac_list
6868 and "battery_state" in device ["binary_sensors" ]
6969 and device ["zigbee_mac_address" ] in mac_list
7070 and device ["sensors" ]["battery" ] < 15
71- ):
71+ )
72+ if is_battery_low :
7273 device ["binary_sensors" ]["battery_state" ] = True
7374
7475 self ._update_for_cooling (device )
@@ -78,13 +79,13 @@ def _update_gw_devices(self) -> None:
7879 def _detect_low_batteries (self ) -> list [str ]:
7980 """Helper-function updating the battery_state binary_sensor status from a Battery-is-low message."""
8081 mac_address_list : list [str ] = []
81- mac_pattern = "(?:[0-9A-F]{2}){8}"
82+ mac_pattern = re . compile ( r "(?:[0-9A-F]{2}){8}")
8283 matches = ["Battery" , "below" ]
8384 if self ._notifications :
8485 for msg_id , notification in list (self ._notifications .items ()):
8586 mac_address : str | None = None
8687 message : str | None = notification .get ("message" )
87- if message is not None and all (x in message for x in matches ) and (mac_addresses := re .findall (mac_pattern , message )):
88+ if message is not None and all (x in message for x in matches ) and (mac_addresses := mac_pattern .findall (message )):
8889 mac_address = mac_addresses [0 ] # re.findall() outputs a list
8990
9091 if mac_address is not None :
You can’t perform that action at this time.
0 commit comments