File tree Expand file tree Collapse file tree 4 files changed +68
-21
lines changed
Expand file tree Collapse file tree 4 files changed +68
-21
lines changed Original file line number Diff line number Diff line change 88from typing import cast
99
1010from plugwise .constants import (
11+ ADAM ,
12+ ANNA ,
1113 DEFAULT_LEGACY_TIMEOUT ,
1214 DEFAULT_PORT ,
1315 DEFAULT_TIMEOUT ,
1618 LOGGER ,
1719 MODULES ,
1820 NONE ,
21+ SMILE_P1 ,
1922 SMILES ,
2023 STATE_OFF ,
2124 STATE_ON ,
2225 STATUS ,
2326 SYSTEM ,
24- GwEntityData ,
27+ PlugwiseAdamData ,
28+ PlugwiseAnnaData ,
29+ PlugwiseP1Data ,
30+ PlugwiseStretchData ,
2531 ThermoLoc ,
2632)
2733from plugwise .exceptions import (
@@ -308,9 +314,17 @@ async def _smile_detect_legacy(
308314 self .smile .legacy = True
309315 return return_model
310316
311- async def async_update (self ) -> dict [str , GwEntityData ]:
312- """Update the Plughwise Gateway entities and their data and states."""
313- data : dict [str , GwEntityData ] = {}
317+ async def async_update (self ) -> dict [str , PlugwiseAnnaData | PlugwiseAdamData | PlugwiseP1Data | PlugwiseStretchData ]:
318+ """Update the Plugwise Gateway entities and their data and states."""
319+ if self .smile .type == ANNA :
320+ data : dict [str , PlugwiseAnnaData ] = {}
321+ if self .smile .type == ADAM :
322+ data : dict [str , PlugwiseAdamData ] = {}
323+ if self .smile .type == SMILE_P1 :
324+ data : dict [str , PlugwiseP1Data ] = {}
325+ if self .smile .type == "Stretch" :
326+ data : dict [str , PlugwiseStretchData ] = {}
327+
314328 try :
315329 data = await self ._smile_api .async_update ()
316330 except (DataMissingError , KeyError ) as err :
Original file line number Diff line number Diff line change 1818 SmartEnergyLegacySensors ,
1919 SmartEnergyMeter ,
2020 SmileP1Gateway ,
21+ SmileThermostatGateway ,
2122 StretchGateway ,
2223 ThermoZone ,
2324)
@@ -523,28 +524,54 @@ class ActuatorData(TypedDict, total=False):
523524
524525
525526@dataclass
526- class GwEntityData (
527+ class GwEntityData :
528+ """The base Gateway Entity data class."""
529+
530+ # For temporary use
531+ cooling_enabled : bool
532+ domestic_hot_water_setpoint : float
533+ elga_status_code : int
534+ c_heating_state : bool
535+ thermostat_supports_cooling : bool
536+
537+
538+ @dataclass
539+ class PlugwiseAnnaData (
540+ AnnaData ,
541+ GwEntityData ,
542+ OnOffTherm ,
543+ OpenTherm ,
544+ SmileThermostatGateway ,
545+ ):
546+ """The Plugwise Anna Data class."""
547+
548+
549+ @dataclass
550+ class PlugwiseAdamData (
527551 AdamGateway ,
528552 AnnaAdamData ,
529- AnnaData ,
553+ GwEntityData ,
530554 JipLisaTomData ,
531555 PlugData ,
532556 OnOffTherm ,
533557 OpenTherm ,
558+ ThermoZone ,
559+ ):
560+ """The Plugwise Adam Data class."""
561+
562+
563+ @dataclass
564+ class PlugwiseP1Data (
534565 SmartEnergyLegacySensors ,
535566 SmartEnergyMeter ,
536567 SmileP1Gateway ,
537- StretchGateway ,
538- ThermoZone ,
539568):
540- """The Gateway Entity data class.
569+ """The Plugwise P1 Data class."""
541570
542- Covering the collected output-data per device or location.
543- """
544571
545- # For temporary use
546- cooling_enabled : bool
547- domestic_hot_water_setpoint : float
548- elga_status_code : int
549- c_heating_state : bool
550- thermostat_supports_cooling : bool
572+ @ dataclass
573+ class PlugwiseStretchData (
574+ PlugData ,
575+ StretchGateway ,
576+ ):
577+ """The Plugwise Stretch Data class."""
Original file line number Diff line number Diff line change 2020 RULES ,
2121 STATE_OFF ,
2222 STATE_ON ,
23- GwEntityData ,
23+ PlugwiseAdamData ,
24+ PlugwiseAnnaData ,
25+ PlugwiseP1Data ,
26+ PlugwiseStretchData ,
2427 ThermoLoc ,
2528)
2629from plugwise .exceptions import ConnectionFailedError , DataMissingError , PlugwiseError
@@ -87,7 +90,7 @@ def get_all_gateway_entities(self) -> None:
8790
8891 self ._all_entity_data ()
8992
90- async def async_update (self ) -> dict [str , GwEntityData ]:
93+ async def async_update (self ) -> dict [str , PlugwiseAnnaData | PlugwiseAdamData | PlugwiseP1Data | PlugwiseStretchData ]:
9194 """Perform an full update update at day-change: re-collect all gateway entities and their data and states.
9295
9396 Otherwise perform an incremental update: only collect the entities updated data and states.
Original file line number Diff line number Diff line change 2424 RULES ,
2525 STATE_OFF ,
2626 STATE_ON ,
27- GwEntityData ,
27+ PlugwiseAdamData ,
28+ PlugwiseAnnaData ,
29+ PlugwiseP1Data ,
30+ PlugwiseStretchData ,
2831 SwitchType ,
2932 ThermoLoc ,
3033)
@@ -121,7 +124,7 @@ def get_all_gateway_entities(self) -> None:
121124
122125 self ._all_entity_data ()
123126
124- async def async_update (self ) -> dict [str , GwEntityData ]:
127+ async def async_update (self ) -> dict [str , PlugwiseAnnaData | PlugwiseAdamData | PlugwiseP1Data | PlugwiseStretchData ]:
125128 """Perform an full update: re-collect all gateway entities and their data and states.
126129
127130 Any change in the connected entities will be detected immediately.
You can’t perform that action at this time.
0 commit comments