Skip to content

Commit 1eb54e0

Browse files
committed
Try 3
1 parent 963af04 commit 1eb54e0

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
)
@@ -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."""

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)