Skip to content

Commit bce5881

Browse files
committed
Add cooling_present as a property
1 parent c7d4fc7 commit bce5881

File tree

7 files changed

+22
-19
lines changed

7 files changed

+22
-19
lines changed

plugwise/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def __init__(
6262
websession,
6363
)
6464

65+
self._cooling_present = False
6566
self._elga = False
6667
self._is_thermostat = False
6768
self._last_active: dict[str, str | None] = {}
@@ -73,7 +74,6 @@ def __init__(
7374
self._smile_props: SmileProps = {}
7475
self._stretch_v2 = False
7576
self._target_smile: str = NONE
76-
self.cooling_present = False
7777
self.smile_hostname: str = NONE
7878
self.smile_hw_version: str | None = None
7979
self.smile_legacy = False
@@ -85,6 +85,11 @@ def __init__(
8585
self.smile_version: Version | None = None
8686
self.smile_zigbee_mac_address: str | None = None
8787

88+
@property
89+
def cooling_present(self) -> str:
90+
"""Return the cooling capability."""
91+
return self._smile_props["cooling_present"]
92+
8893
@property
8994
def gateway_id(self) -> str:
9095
"""Return the gateway-id."""
@@ -148,6 +153,7 @@ async def connect(self) -> Version | None:
148153

149154
self._smile_api = (
150155
SmileAPI(
156+
self._cooling_present,
151157
self._elga,
152158
self._is_thermostat,
153159
self._last_active,
@@ -157,7 +163,6 @@ async def connect(self) -> Version | None:
157163
self._request,
158164
self._schedule_old_states,
159165
self._smile_props,
160-
self.cooling_present,
161166
self.smile_hostname,
162167
self.smile_hw_version,
163168
self.smile_mac_address,
@@ -262,7 +267,7 @@ async def _smile_detect(self, result: etree, dsmrmain: etree) -> None:
262267
locator_1 = "./gateway/features/cooling"
263268
locator_2 = "./gateway/features/elga_support"
264269
if result.find(locator_1) is not None:
265-
self.cooling_present = True
270+
self._cooling_present = True
266271
if result.find(locator_2) is not None:
267272
self._elga = True
268273

plugwise/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ class SmileCommon:
3535
def __init__(self) -> None:
3636
"""Init."""
3737
self._appliances: etree
38+
self._cooling_present: bool
3839
self._count: int
3940
self._domain_objects: etree
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._smile_props["smile_name"] = self.smile_name
4848
if self._is_thermostat:
4949
self._smile_props["heater_id"] = self._heater_id
50-
self._smile_props["cooling_present"] = self.cooling_present
50+
self._smile_props["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 & 4 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
@@ -653,14 +653,14 @@ def _update_anna_cooling(self, entity_id: str, data: GwEntityData) -> None:
653653

654654
if "elga_status_code" in data:
655655
self._update_elga_cooling(data)
656-
elif self.cooling_present and "cooling_state" in data["binary_sensors"]:
656+
elif self._cooling_present and "cooling_state" in data["binary_sensors"]:
657657
self._update_loria_cooling(data)
658658

659659
def _update_elga_cooling(self, data: GwEntityData) -> None:
660660
"""# Anna+Elga: base cooling_state on the elga-status-code."""
661661
if data["thermostat_supports_cooling"]:
662662
# Techneco Elga has cooling-capability
663-
self.cooling_present = True
663+
self._cooling_present = True
664664
data["model"] = "Generic heater/cooler"
665665
# Cooling_enabled in xml does NOT show the correct status!
666666
# Setting it specifically:
@@ -700,7 +700,7 @@ def _cleanup_data(self, data: GwEntityData) -> None:
700700
"""
701701
# Don't show cooling-related when no cooling present,
702702
# but, keep cooling_enabled for Elga
703-
if not self.cooling_present:
703+
if not self._cooling_present:
704704
if "cooling_state" in data["binary_sensors"]:
705705
data["binary_sensors"].pop("cooling_state")
706706
self._count -= 1

plugwise/legacy/helper.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ def __init__(self) -> None:
7878
self._status: etree
7979
self._stretch_v2: bool
8080
self._system: etree
81-
82-
self.cooling_present: bool
8381
self.gateway_id: str
8482
self.gw_entities: dict[str, GwEntityData] = {}
8583
self.smile_hw_version: str | None

plugwise/legacy/smile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def __init__(
5555
smile_zigbee_mac_address: str | None,
5656
) -> None:
5757
"""Set the constructor for this class."""
58+
self._cooling_present = False
5859
self._is_thermostat = _is_thermostat
5960
self._loc_data = _loc_data
6061
self._on_off_device = _on_off_device
@@ -63,7 +64,6 @@ def __init__(
6364
self._smile_props = _smile_props
6465
self._stretch_v2 = _stretch_v2
6566
self._target_smile = _target_smile
66-
self.cooling_present = False
6767
self.smile_hostname = smile_hostname
6868
self.smile_hw_version = smile_hw_version
6969
self.smile_mac_address = smile_mac_address

plugwise/smile.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class SmileAPI(SmileData):
4444

4545
def __init__(
4646
self,
47+
_cooling_present: bool,
4748
_elga: bool,
4849
_is_thermostat: bool,
4950
_last_active: dict[str, str | None],
@@ -53,7 +54,6 @@ def __init__(
5354
_request: Callable[..., Awaitable[Any]],
5455
_schedule_old_states: dict[str, dict[str, str]],
5556
_smile_props: SmileProps,
56-
cooling_present: bool,
5757
smile_hostname: str | None,
5858
smile_hw_version: str | None,
5959
smile_mac_address: str | None,
@@ -65,6 +65,7 @@ def __init__(
6565
) -> None:
6666
"""Set the constructor for this class."""
6767
self._cooling_enabled = False
68+
self._cooling_present = _cooling_present
6869
self._elga = _elga
6970
self._gateway_id: str = NONE
7071
self._heater_id: str = NONE
@@ -76,7 +77,6 @@ def __init__(
7677
self._request = _request
7778
self._schedule_old_states = _schedule_old_states
7879
self._smile_props = _smile_props
79-
self.cooling_present = cooling_present
8080
self.smile_hostname = smile_hostname
8181
self.smile_hw_version = smile_hw_version
8282
self.smile_mac_address = smile_mac_address
@@ -430,7 +430,7 @@ async def set_temperature(self, loc_id: str, items: dict[str, float]) -> None:
430430
if "setpoint" in items:
431431
setpoint = items["setpoint"]
432432

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

0 commit comments

Comments
 (0)