@@ -88,29 +88,35 @@ def update_for_cooling(self, device: DeviceData) -> DeviceData:
8888
8989 return device
9090
91- def _all_device_data (self ) -> None :
92- """Helper-function for get_all_devices().
9391
94- Collect data for each device and add to self.gw_data and self.gw_devices.
95- """
92+ def _update_gw_devices (self ) -> None :
93+ """Helper-function for _all_device_data() and async_update().
94+
95+ Collect data for each device and add to self.gw_devices.
96+ """
9697 for device_id , device in self .gw_devices .items ():
9798 data = self ._get_device_data (device_id )
98- device .update (data )
99- # Add plugwise notification binary_sensor to the relevant gateway
100- if device_id == self .gateway_id and (
101- self ._is_thermostat
102- or (not self ._smile_legacy and self .smile_type == "power" )
99+ if ("binary_sensors" in device and "plugwise_notification" in device ["binary_sensors" ])
100+ or (device_id == self .gateway_id and (self ._is_thermostator or (self .smile_type == "power" and not self ._smile_legacy ))
103101 ):
104- device ["binary_sensors" ]["plugwise_notification" ] = bool (
102+ data ["binary_sensors" ]["plugwise_notification" ] = bool (
105103 self ._notifications
106104 )
105+ device .update (data )
107106
108107 # Update for cooling
109108 if device ["dev_class" ] in ZONE_THERMOSTATS :
110109 self .update_for_cooling (device )
111110
112111 remove_empty_platform_dicts (device )
113112
113+
114+ def _all_device_data (self ) -> None :
115+ """Helper-function for get_all_devices().
116+
117+ Collect data for each device and add to self.gw_data and self.gw_devices.
118+ """
119+ self ._update_gw_devices ()
114120 self .gw_data .update (
115121 {
116122 "smile_name" : self .smile_name ,
@@ -537,25 +543,9 @@ async def async_update(self) -> PlugwiseData:
537543 case self ._target_smile if self ._target_smile in REQUIRE_APPLIANCES :
538544 self ._appliances = await self ._request (APPLIANCES )
539545
546+ self ._update_gw_devices ()
540547 self .gw_data ["notifications" ] = self ._notifications
541548
542- for device_id , device in self .gw_devices .items ():
543- data = self ._get_device_data (device_id )
544- if (
545- "binary_sensors" in device
546- and "plugwise_notification" in device ["binary_sensors" ]
547- ):
548- data ["binary_sensors" ]["plugwise_notification" ] = bool (
549- self ._notifications
550- )
551- device .update (data )
552-
553- # Update for cooling
554- if device ["dev_class" ] in ZONE_THERMOSTATS :
555- self .update_for_cooling (device )
556-
557- remove_empty_platform_dicts (device )
558-
559549 return PlugwiseData (self .gw_data , self .gw_devices )
560550
561551 async def _set_schedule_state_legacy (
0 commit comments