Skip to content

Commit febd1e4

Browse files
committed
Cleaning up SmileProps
1 parent d665c45 commit febd1e4

File tree

6 files changed

+7
-44
lines changed

6 files changed

+7
-44
lines changed

plugwise/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
STATUS,
1919
SYSTEM,
2020
GwEntityData,
21-
SmileProps,
2221
ThermoLoc,
2322
)
2423
from plugwise.exceptions import (
@@ -69,7 +68,6 @@ def __init__(
6968
self._opentherm_device = False
7069
self._schedule_old_states: dict[str, dict[str, str]] = {}
7170
self._smile_api: SmileAPI | SmileLegacyAPI
72-
self._smile_props: SmileProps = {}
7371
self._stretch_v2 = False
7472
self._target_smile: str = NONE
7573
self.smile_hostname: str = NONE
@@ -158,7 +156,6 @@ async def connect(self) -> Version:
158156
self._opentherm_device,
159157
self._request,
160158
self._schedule_old_states,
161-
self._smile_props,
162159
self.smile_hostname,
163160
self.smile_hw_version,
164161
self.smile_mac_address,
@@ -175,7 +172,6 @@ async def connect(self) -> Version:
175172
self._on_off_device,
176173
self._opentherm_device,
177174
self._request,
178-
self._smile_props,
179175
self._stretch_v2,
180176
self._target_smile,
181177
self.smile_hostname,

plugwise/constants.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -393,17 +393,6 @@
393393
)
394394

395395

396-
class SmileProps(TypedDict, total=False):
397-
"""The SmileProps Data class."""
398-
399-
cooling_present: bool
400-
gateway_id: str
401-
heater_id: str
402-
item_count: int
403-
reboot: bool
404-
smile_name: str
405-
406-
407396
class ModuleData(TypedDict):
408397
"""The Module data class."""
409398

plugwise/data.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
OFF,
1717
ActuatorData,
1818
GwEntityData,
19-
SmileProps,
2019
)
2120
from plugwise.helper import SmileHelper
2221
from plugwise.util import remove_empty_platform_dicts
@@ -28,27 +27,18 @@ class SmileData(SmileHelper):
2827
def __init__(self) -> None:
2928
"""Init."""
3029
super().__init__()
31-
self._smile_props: SmileProps
3230
self._zones: dict[str, GwEntityData] = {}
3331

3432
def _all_entity_data(self) -> None:
3533
"""Helper-function for get_all_gateway_entities().
3634
37-
Collect data for each entity and add to self._smile_props and self.gw_entities.
35+
Collect data for each entity and add to self.gw_entities.
3836
"""
3937
self._update_gw_entities()
4038
if self.smile(ADAM):
4139
self._update_zones()
4240
self.gw_entities.update(self._zones)
4341

44-
self._smile_props["gateway_id"] = self._gateway_id
45-
self._smile_props["item_count"] = self._count
46-
self._smile_props["reboot"] = True
47-
self._smile_props["smile_name"] = self.smile_name
48-
if self._is_thermostat:
49-
self._smile_props["heater_id"] = self._heater_id
50-
self._smile_props["cooling_present"] = self._cooling_present
51-
5242
def _update_zones(self) -> None:
5343
"""Helper-function for _all_entity_data() and async_update().
5444

plugwise/legacy/data.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# Dict as class
99
# Version detection
10-
from plugwise.constants import NONE, OFF, GwEntityData, SmileProps
10+
from plugwise.constants import NONE, OFF, GwEntityData
1111
from plugwise.legacy.helper import SmileLegacyHelper
1212
from plugwise.util import remove_empty_platform_dicts
1313

@@ -18,19 +18,13 @@ class SmileLegacyData(SmileLegacyHelper):
1818
def __init__(self) -> None:
1919
"""Init."""
2020
super().__init__()
21-
self._smile_props: SmileProps
2221

2322
def _all_entity_data(self) -> None:
2423
"""Helper-function for get_all_gateway_entities().
2524
26-
Collect data for each entity and add to self._smile_props and self.gw_entities.
25+
Collect data for each entity and add to self.gw_entities.
2726
"""
2827
self._update_gw_entities()
29-
self._smile_props["gateway_id"] = self.gateway_id
30-
self._smile_props["item_count"] = self._count
31-
self._smile_props["smile_name"] = self.smile_name
32-
if self._is_thermostat:
33-
self._smile_props["heater_id"] = self._heater_id
3428

3529
def _update_gw_entities(self) -> None:
3630
"""Helper-function for _all_entity_data() and async_update().

plugwise/legacy/smile.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
REQUIRE_APPLIANCES,
2020
RULES,
2121
GwEntityData,
22-
SmileProps,
2322
ThermoLoc,
2423
)
2524
from plugwise.exceptions import ConnectionFailedError, DataMissingError, PlugwiseError
@@ -41,7 +40,6 @@ def __init__(
4140
_on_off_device: bool,
4241
_opentherm_device: bool,
4342
_request: Callable[..., Awaitable[Any]],
44-
_smile_props: SmileProps,
4543
_stretch_v2: bool,
4644
_target_smile: str,
4745
smile_hostname: str,
@@ -61,7 +59,6 @@ def __init__(
6159
self._on_off_device = _on_off_device
6260
self._opentherm_device = _opentherm_device
6361
self._request = _request
64-
self._smile_props = _smile_props
6562
self._stretch_v2 = _stretch_v2
6663
self._target_smile = _target_smile
6764
self.smile_hostname = smile_hostname

plugwise/smile.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
OFF,
2323
RULES,
2424
GwEntityData,
25-
SmileProps,
2625
ThermoLoc,
2726
)
2827
from plugwise.data import SmileData
@@ -51,7 +50,6 @@ def __init__(
5150
_opentherm_device: bool,
5251
_request: Callable[..., Awaitable[Any]],
5352
_schedule_old_states: dict[str, dict[str, str]],
54-
_smile_props: SmileProps,
5553
smile_hostname: str | None,
5654
smile_hw_version: str | None,
5755
smile_mac_address: str | None,
@@ -72,7 +70,6 @@ def __init__(
7270
self._opentherm_device = _opentherm_device
7371
self._request = _request
7472
self._schedule_old_states = _schedule_old_states
75-
self._smile_props = _smile_props
7673
self.smile_hostname = smile_hostname
7774
self.smile_hw_version = smile_hw_version
7875
self.smile_mac_address = smile_mac_address
@@ -126,8 +123,8 @@ async def async_update(self) -> dict[str, GwEntityData]:
126123
self.get_all_gateway_entities()
127124
# Set self._cooling_enabled - required for set_temperature(),
128125
# also, check for a failed data-retrieval
129-
if "heater_id" in self._smile_props:
130-
heat_cooler = self.gw_entities[self._smile_props["heater_id"]]
126+
if self.heater_id != NONE:
127+
heat_cooler = self.gw_entities[self.heater_id]
131128
if (
132129
"binary_sensors" in heat_cooler
133130
and "cooling_enabled" in heat_cooler["binary_sensors"]
@@ -136,7 +133,7 @@ async def async_update(self) -> dict[str, GwEntityData]:
136133
"cooling_enabled"
137134
]
138135
else: # cover failed data-retrieval for P1
139-
_ = self.gw_entities[self._smile_props["gateway_id"]]["location"]
136+
_ = self.gw_entities[self.gateway_id]["location"]
140137
except KeyError as err:
141138
raise DataMissingError("No Plugwise actual data received") from err
142139

@@ -278,7 +275,7 @@ async def set_gateway_mode(self, mode: str) -> None:
278275
f"{valid}"
279276
"</gateway_mode_control_functionality>"
280277
)
281-
uri = f"{APPLIANCES};id={self._smile_props['gateway_id']}/gateway_mode_control"
278+
uri = f"{APPLIANCES};id={self.gateway_id}/gateway_mode_control"
282279
await self.call_request(uri, method="put", data=data)
283280

284281
async def set_regulation_mode(self, mode: str) -> None:

0 commit comments

Comments
 (0)