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 (
@@ -326,9 +332,17 @@ async def _smile_detect_legacy(
326332 self .smile .legacy = True
327333 return return_model
328334
329- async def async_update (self ) -> dict [str , GwEntityData ]:
330- """Update the Plughwise Gateway entities and their data and states."""
331- data : dict [str , GwEntityData ] = {}
335+ async def async_update (self ) -> dict [str , PlugwiseAnnaData | PlugwiseAdamData | PlugwiseP1Data | PlugwiseStretchData ]:
336+ """Update the Plugwise Gateway entities and their data and states."""
337+ if self .smile .type == ANNA :
338+ data : dict [str , PlugwiseAnnaData ] = {}
339+ if self .smile .type == ADAM :
340+ data : dict [str , PlugwiseAdamData ] = {}
341+ if self .smile .type == SMILE_P1 :
342+ data : dict [str , PlugwiseP1Data ] = {}
343+ if self .smile .type == "Stretch" :
344+ data : dict [str , PlugwiseStretchData ] = {}
345+
332346 try :
333347 data = await self ._smile_api .async_update ()
334348 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)
@@ -541,28 +542,54 @@ class ActuatorData(TypedDict, total=False):
541542
542543
543544@dataclass
544- class GwEntityData (
545+ class GwEntityData :
546+ """The base Gateway Entity data class."""
547+
548+ # For temporary use
549+ cooling_enabled : bool
550+ domestic_hot_water_setpoint : float
551+ elga_status_code : int
552+ c_heating_state : bool
553+ thermostat_supports_cooling : bool
554+
555+
556+ @dataclass
557+ class PlugwiseAnnaData (
558+ AnnaData ,
559+ GwEntityData ,
560+ OnOffTherm ,
561+ OpenTherm ,
562+ SmileThermostatGateway ,
563+ ):
564+ """The Plugwise Anna Data class."""
565+
566+
567+ @dataclass
568+ class PlugwiseAdamData (
545569 AdamGateway ,
546570 AnnaAdamData ,
547- AnnaData ,
571+ GwEntityData ,
548572 JipLisaTomData ,
549573 PlugData ,
550574 OnOffTherm ,
551575 OpenTherm ,
576+ ThermoZone ,
577+ ):
578+ """The Plugwise Adam Data class."""
579+
580+
581+ @dataclass
582+ class PlugwiseP1Data (
552583 SmartEnergyLegacySensors ,
553584 SmartEnergyMeter ,
554585 SmileP1Gateway ,
555- StretchGateway ,
556- ThermoZone ,
557586):
558- """The Gateway Entity data class.
587+ """The Plugwise P1 Data class."""
559588
560- Covering the collected output-data per device or location.
561- """
562589
563- # For temporary use
564- cooling_enabled : bool
565- domestic_hot_water_setpoint : float
566- elga_status_code : int
567- c_heating_state : bool
568- thermostat_supports_cooling : bool
590+ @ dataclass
591+ class PlugwiseStretchData (
592+ PlugData ,
593+ StretchGateway ,
594+ ):
595+ """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 2525 RULES ,
2626 STATE_OFF ,
2727 STATE_ON ,
28- GwEntityData ,
28+ PlugwiseAdamData ,
29+ PlugwiseAnnaData ,
30+ PlugwiseP1Data ,
31+ PlugwiseStretchData ,
2932 SwitchType ,
3033 ThermoLoc ,
3134)
@@ -120,7 +123,7 @@ def get_all_gateway_entities(self) -> None:
120123
121124 self ._all_entity_data ()
122125
123- async def async_update (self ) -> dict [str , GwEntityData ]:
126+ async def async_update (self ) -> dict [str , PlugwiseAnnaData | PlugwiseAdamData | PlugwiseP1Data | PlugwiseStretchData ]:
124127 """Perform an full update: re-collect all gateway entities and their data and states.
125128
126129 Any change in the connected entities will be detected immediately.
You can’t perform that action at this time.
0 commit comments