Skip to content

Commit 584f2cd

Browse files
committed
Rework cooling_present related
1 parent 154a100 commit 584f2cd

File tree

7 files changed

+35
-25
lines changed

7 files changed

+35
-25
lines changed

plugwise/__init__.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ def __init__(
6363
websession,
6464
)
6565

66-
self._cooling_present = False
6766
self._elga = False
6867
self._is_thermostat = False
6968
self._last_active: dict[str, str | None] = {}
@@ -74,6 +73,7 @@ def __init__(
7473
self._smile_api: SmileAPI | SmileLegacyAPI
7574
self._stretch_v2 = False
7675
self._target_smile: str = NONE
76+
self.cooling_present = False
7777
self.gw_data: GatewayData = {}
7878
self.smile_fw_version: Version | None = None
7979
self.smile_hostname: str = NONE
@@ -89,14 +89,29 @@ def __init__(
8989

9090
@property
9191
def gateway_id(self) -> str:
92-
"""Return the Smile gateway-id."""
92+
"""Return the gateway-id."""
9393
return self.gw_data["gateway_id"]
9494

9595
@property
9696
def heater_id(self) -> str:
97-
"""Return the Smile heater-id."""
97+
"""Return the heater-id."""
9898
return self.gw_data["heater_id"]
9999

100+
@property
101+
def item_count(self) -> int:
102+
"""Return the item-count."""
103+
return self.gw_data["item_count"]
104+
105+
@property
106+
def notifications(self) -> dict[str, dict[str, str]]:
107+
"""Return the Plugwise notifications."""
108+
return self.gw_data["notifications"]
109+
110+
@property
111+
def reboot(self) -> bool:
112+
"""Return the reboot capability."""
113+
return self.gw_data["reboot"]
114+
100115
async def connect(self) -> Version | None:
101116
"""Connect to the Plugwise Gateway and determine its name, type, version, and other data."""
102117
result = await self._request(DOMAIN_OBJECTS)
@@ -136,7 +151,7 @@ async def connect(self) -> Version | None:
136151
self._smile_api = (
137152
SmileAPI(
138153
self._request,
139-
self._cooling_present,
154+
self.cooling_present,
140155
self._elga,
141156
self._is_thermostat,
142157
self._last_active,
@@ -251,7 +266,7 @@ async def _smile_detect(self, result: etree, dsmrmain: etree) -> None:
251266
locator_1 = "./gateway/features/cooling"
252267
locator_2 = "./gateway/features/elga_support"
253268
if result.find(locator_1) is not None:
254-
self._cooling_present = True
269+
self.cooling_present = True
255270
if result.find(locator_2) is not None:
256271
self._elga = True
257272

plugwise/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init__(self) -> None:
3737
self._appliances: etree
3838
self._count: int
3939
self._domain_objects: etree
40-
self._cooling_present: bool
40+
self.cooling_present: bool
4141
self._heater_id: str
4242
self._on_off_device: bool
4343
self._opentherm_device: bool
@@ -84,7 +84,7 @@ def _appl_heater_central_info(
8484
appl.hardware = module_data["hardware_version"]
8585
appl.model_id = module_data["vendor_model"] if not legacy else None
8686
appl.model = (
87-
"Generic heater/cooler" if self._cooling_present else "Generic heater"
87+
"Generic heater/cooler" if self.cooling_present else "Generic heater"
8888
)
8989

9090
return appl

plugwise/data.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def _all_entity_data(self) -> None:
4747
self.gw_data["smile_name"] = self.smile_name
4848
if self._is_thermostat:
4949
self.gw_data["heater_id"] = self._heater_id
50-
self.gw_data["cooling_present"] = self._cooling_present
50+
self.gw_data["cooling_present"] = self.cooling_present
5151

5252
def _update_zones(self) -> None:
5353
"""Helper-function for _all_entity_data() and async_update().
@@ -134,7 +134,7 @@ def _update_for_cooling(self, entity: GwEntityData) -> None:
134134
# For Anna and heating + cooling, replace setpoint with setpoint_high/_low
135135
if (
136136
self.smile(ANNA)
137-
and self._cooling_present
137+
and self.cooling_present
138138
and entity["dev_class"] == "thermostat"
139139
):
140140
thermostat = entity["thermostat"]
@@ -243,7 +243,7 @@ def _get_adam_data(self, entity: GwEntityData, data: GwEntityData) -> None:
243243
if "binary_sensors" in data:
244244
if (
245245
"cooling_enabled" not in data["binary_sensors"]
246-
and self._cooling_present
246+
and self.cooling_present
247247
):
248248
data["binary_sensors"]["cooling_enabled"] = self._cooling_enabled
249249

@@ -287,7 +287,7 @@ def _climate_data(
287287
self._count += 1
288288
if sel_schedule in (NONE, OFF):
289289
data["climate_mode"] = "heat"
290-
if self._cooling_present:
290+
if self.cooling_present:
291291
data["climate_mode"] = (
292292
"cool" if self.check_reg_mode("cooling") else "heat_cool"
293293
)

plugwise/helper.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class SmileHelper(SmileCommon):
7171

7272
def __init__(self) -> None:
7373
"""Set the constructor for this class."""
74-
self._cooling_present: bool
74+
self.cooling_present: bool
7575
self._count: int
7676
self._dhw_allowed_modes: list[str] = []
7777
self._domain_objects: etree
@@ -327,15 +327,9 @@ def _get_appl_actuator_modes(
327327
) is not None and (modes := search.find("allowed_modes")) is not None:
328328
for mode in modes:
329329
mode_list.append(mode.text)
330-
self._check_cooling_mode(mode.text)
331330

332331
return mode_list
333332

334-
def _check_cooling_mode(self, mode: str) -> None:
335-
"""Check if cooling mode is present and update state."""
336-
if mode == "cooling":
337-
self._cooling_present = True
338-
339333
def _get_appliances_with_offset_functionality(self) -> list[str]:
340334
"""Helper-function collecting all appliance that have offset_functionality."""
341335
therm_list: list[str] = []
@@ -660,14 +654,14 @@ def _update_anna_cooling(self, entity_id: str, data: GwEntityData) -> None:
660654

661655
if "elga_status_code" in data:
662656
self._update_elga_cooling(data)
663-
elif self._cooling_present and "cooling_state" in data["binary_sensors"]:
657+
elif self.cooling_present and "cooling_state" in data["binary_sensors"]:
664658
self._update_loria_cooling(data)
665659

666660
def _update_elga_cooling(self, data: GwEntityData) -> None:
667661
"""# Anna+Elga: base cooling_state on the elga-status-code."""
668662
if data["thermostat_supports_cooling"]:
669663
# Techneco Elga has cooling-capability
670-
self._cooling_present = True
664+
self.cooling_present = True
671665
data["model"] = "Generic heater/cooler"
672666
# Cooling_enabled in xml does NOT show the correct status!
673667
# Setting it specifically:
@@ -707,7 +701,7 @@ def _cleanup_data(self, data: GwEntityData) -> None:
707701
"""
708702
# Don't show cooling-related when no cooling present,
709703
# but, keep cooling_enabled for Elga
710-
if not self._cooling_present:
704+
if not self.cooling_present:
711705
if "cooling_state" in data["binary_sensors"]:
712706
data["binary_sensors"].pop("cooling_state")
713707
self._count -= 1

plugwise/legacy/helper.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def __init__(self) -> None:
7979
self._stretch_v2: bool
8080
self._system: etree
8181

82+
self.cooling_present: bool
8283
self.gateway_id: str
8384
self.gw_entities: dict[str, GwEntityData] = {}
8485
self.smile_fw_version: Version | None

plugwise/legacy/smile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ def __init__(
5555
smile_zigbee_mac_address: str | None,
5656
) -> None:
5757
"""Set the constructor for this class."""
58-
self._cooling_present = False
5958
self._is_thermostat = _is_thermostat
6059
self._loc_data = _loc_data
6160
self._on_off_device = _on_off_device
6261
self._opentherm_device = _opentherm_device
6362
self._stretch_v2 = _stretch_v2
6463
self._target_smile = _target_smile
64+
self.cooling_present = False
6565
self.gw_data = gw_data
6666
self.request = request
6767
self.smile_fw_version = smile_fw_version

plugwise/smile.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class SmileAPI(SmileData):
4545
def __init__(
4646
self,
4747
request: Callable[..., Awaitable[Any]],
48-
_cooling_present: bool,
48+
cooling_present: bool,
4949
_elga: bool,
5050
_is_thermostat: bool,
5151
_last_active: dict[str, str | None],
@@ -66,7 +66,7 @@ def __init__(
6666
) -> None:
6767
"""Set the constructor for this class."""
6868
self._cooling_enabled = False
69-
self._cooling_present = _cooling_present
69+
self.cooling_present = cooling_present
7070
self._elga = _elga
7171
self._gateway_id: str = NONE
7272
self._heater_id: str = NONE
@@ -432,7 +432,7 @@ async def set_temperature(self, loc_id: str, items: dict[str, float]) -> None:
432432
if "setpoint" in items:
433433
setpoint = items["setpoint"]
434434

435-
if self.smile(ANNA) and self._cooling_present:
435+
if self.smile(ANNA) and self.cooling_present:
436436
if "setpoint_high" not in items:
437437
raise PlugwiseError(
438438
"Plugwise: failed setting temperature: no valid input provided"

0 commit comments

Comments
 (0)