@@ -214,6 +214,15 @@ async def full_update_device(self):
214214 if self .smile_type != "power" :
215215 self ._modules = await self .request (MODULES )
216216
217+ def update_helper (self , data , dev_dict , dev_id , key , entity_type ):
218+ """Helper for update_gw_devices."""
219+ for tmp_dict in dev_dict [entity_type ]:
220+ if key == tmp_dict [ATTR_ID ]:
221+ gw_list = self .gw_devices [dev_id ][entity_type ]
222+ for idx , item in enumerate (gw_list ):
223+ if key == item [ATTR_ID ]:
224+ gw_list [idx ][ATTR_STATE ] = data [key ]
225+
217226 def update_device_state (self , data , dev_dict ):
218227 """Helper for device_state_updater()."""
219228 _cooling_state = False
@@ -256,16 +265,7 @@ def device_state_updater(self, data, dev_id, dev_dict):
256265 self .gw_devices [dev_id ]["sensors" ][idx ][ATTR_STATE ] = result [0 ]
257266 self .gw_devices [dev_id ]["sensors" ][idx ][ATTR_ICON ] = result [1 ]
258267
259- def update_helper (self , data , dev_dict , dev_id , key , entity_type ):
260- """Helper for update_gw_devices."""
261- for tmp_dict in dev_dict [entity_type ]:
262- if key == tmp_dict [ATTR_ID ]:
263- gw_list = self .gw_devices [dev_id ][entity_type ]
264- for idx , item in enumerate (gw_list ):
265- if key == item [ATTR_ID ]:
266- gw_list [idx ][ATTR_STATE ] = data [key ]
267-
268- def update_pw_notification (self , dev_id , dev_dict ):
268+ def pw_notification_updater (self , dev_id , dev_dict ):
269269 """ PW_Notification update helper."""
270270 for idx , item in enumerate (dev_dict ["binary_sensors" ]):
271271 if item [ATTR_ID ] == "plugwise_notification" :
@@ -289,7 +289,7 @@ async def update_gw_devices(self):
289289 if "binary_sensors" in dev_dict :
290290 for key , value in list (data .items ()):
291291 self .update_helper (data , dev_dict , dev_id , key , "binary_sensors" )
292- self .update_pw_notification (dev_id , dev_dict )
292+ self .pw_notification_updater (dev_id , dev_dict )
293293 if "sensors" in dev_dict :
294294 for key , value in list (data .items ()):
295295 self .update_helper (data , dev_dict , dev_id , key , "sensors" )
0 commit comments