Skip to content

Commit 04f9daa

Browse files
committed
Try 3
1 parent ca0a8cf commit 04f9daa

File tree

4 files changed

+68
-21
lines changed

4 files changed

+68
-21
lines changed

plugwise/__init__.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
from typing import cast
99

1010
from plugwise.constants import (
11+
ADAM,
12+
ANNA,
1113
DEFAULT_LEGACY_TIMEOUT,
1214
DEFAULT_PORT,
1315
DEFAULT_TIMEOUT,
@@ -16,12 +18,16 @@
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
)
2733
from 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:

plugwise/constants.py

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
SmartEnergyLegacySensors,
1919
SmartEnergyMeter,
2020
SmileP1Gateway,
21+
SmileThermostatGateway,
2122
StretchGateway,
2223
ThermoZone,
2324
)
@@ -534,28 +535,54 @@ class ActuatorData(TypedDict, total=False):
534535

535536

536537
@dataclass
537-
class GwEntityData(
538+
class GwEntityData:
539+
"""The base Gateway Entity data class."""
540+
541+
# For temporary use
542+
cooling_enabled: bool
543+
domestic_hot_water_setpoint: float
544+
elga_status_code: int
545+
c_heating_state: bool
546+
thermostat_supports_cooling: bool
547+
548+
549+
@dataclass
550+
class PlugwiseAnnaData(
551+
AnnaData,
552+
GwEntityData,
553+
OnOffTherm,
554+
OpenTherm,
555+
SmileThermostatGateway,
556+
):
557+
"""The Plugwise Anna Data class."""
558+
559+
560+
@dataclass
561+
class PlugwiseAdamData(
538562
AdamGateway,
539563
AnnaAdamData,
540-
AnnaData,
564+
GwEntityData,
541565
JipLisaTomData,
542566
PlugData,
543567
OnOffTherm,
544568
OpenTherm,
569+
ThermoZone,
570+
):
571+
"""The Plugwise Adam Data class."""
572+
573+
574+
@dataclass
575+
class PlugwiseP1Data(
545576
SmartEnergyLegacySensors,
546577
SmartEnergyMeter,
547578
SmileP1Gateway,
548-
StretchGateway,
549-
ThermoZone,
550579
):
551-
"""The Gateway Entity data class.
580+
"""The Plugwise P1 Data class."""
552581

553-
Covering the collected output-data per device or location.
554-
"""
555582

556-
# For temporary use
557-
cooling_enabled: bool
558-
domestic_hot_water_setpoint: float
559-
elga_status_code: int
560-
c_heating_state: bool
561-
thermostat_supports_cooling: bool
583+
@dataclass
584+
class PlugwiseStretchData(
585+
PlugData,
586+
StretchGateway,
587+
):
588+
"""The Plugwise Stretch Data class."""

plugwise/legacy/smile.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
RULES,
2121
STATE_OFF,
2222
STATE_ON,
23-
GwEntityData,
23+
PlugwiseAdamData,
24+
PlugwiseAnnaData,
25+
PlugwiseP1Data,
26+
PlugwiseStretchData,
2427
ThermoLoc,
2528
)
2629
from 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.

plugwise/smile.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
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.

0 commit comments

Comments
 (0)