@@ -293,53 +293,53 @@ def _get_schedule_states_with_off(
293293 if all_off :
294294 data ["select_schedule" ] = OFF
295295
296- def _check_availability (self , device : DeviceData , device_data : DeviceData ) -> None :
296+ def _check_availability (
297+ self , device : DeviceData , data : DeviceData , dev_class : str , message : str
298+ ) -> None :
297299 """Helper-function for _get_device_data().
298300
299301 Provide availability status for the wired-commected devices.
300302 """
301- # OpenTherm device
302- if device ["dev_class" ] == "heater_central" and device ["name" ] != "OnOff" :
303- device_data ["available" ] = True
304- self ._count += 1
305- for data in self ._notifications .values ():
306- for msg in data .values ():
307- if "no OpenTherm communication" in msg :
308- device_data ["available" ] = False
309-
310- # Smartmeter
311- if device ["dev_class" ] == "smartmeter" :
312- device_data ["available" ] = True
303+ if device ["dev_class" ] == dev_class :
304+ data ["available" ] = True
313305 self ._count += 1
314- for data in self ._notifications .values ():
315- for msg in data .values ():
316- if "P1 does not seem to be connected to a smart meter" in msg :
317- device_data ["available" ] = False
306+ for item in self ._notifications .values ():
307+ for msg in item .values ():
308+ if message in msg :
309+ data ["available" ] = False
318310
319311 def _get_device_data (self , dev_id : str ) -> DeviceData :
320312 """Helper-function for _all_device_data() and async_update().
321313
322314 Provide device-data, based on Location ID (= dev_id), from APPLIANCES.
323315 """
324316 device = self .gw_devices [dev_id ]
325- device_data = self ._get_measurement_data (dev_id )
317+ data = self ._get_measurement_data (dev_id )
326318
327319 # Check availability of non-legacy wired-connected devices
328320 if not self ._smile_legacy :
329- self ._check_availability (device , device_data )
321+ # Smartmeter
322+ self ._check_availability (
323+ device , data , "smartmeter" , "P1 does not seem to be connected"
324+ )
325+ # OpenTherm device
326+ if device ["name" ] != "OnOff" :
327+ self ._check_availability (
328+ device , data , "heater_central" , "no OpenTherm communication"
329+ )
330330
331331 # Switching groups data
332- device_data = self ._device_data_switching_group (device , device_data )
332+ data = self ._device_data_switching_group (device , data )
333333 # Adam data
334- device_data = self ._device_data_adam (device , device_data )
334+ data = self ._device_data_adam (device , data )
335335 # Skip obtaining data for non master-thermostats
336336 if device ["dev_class" ] not in ZONE_THERMOSTATS :
337- return device_data
337+ return data
338338
339339 # Thermostat data (presets, temperatures etc)
340- device_data = self ._device_data_climate (device , device_data )
340+ data = self ._device_data_climate (device , data )
341341
342- return device_data
342+ return data
343343
344344
345345class Smile (SmileComm , SmileData ):
0 commit comments