Skip to content

Commit 0709262

Browse files
authored
Merge pull request #206 from plugwise/copy_0_18_7
Various updates & fixes
2 parents 0b35dcf + 6af993e commit 0709262

File tree

8 files changed

+98
-107
lines changed

8 files changed

+98
-107
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
# v0.21.1: Smile: various updates % fixes
4+
- Change Anna-gateway name to Smile - related to https://developers.home-assistant.io/blog/2022/07/10/entity_naming/ and changes in the Core Plugwise(-beta) code.
5+
- Output elga_cooling_enabled, lortherm_cooling_enabled or adam_cooling_enabled when applicable. To be used in Core Plugwise(-beta) instead of calling api-variables.
6+
- Protect the self-variables that will no longer be used in Core Plugwise(-beta).
7+
- pyproject.toml updates.
8+
- Adapt test-code where needed.
9+
310
# v0.21.0: Smile: improve and add to output, fix cooling-bug
411
- Add `domestic_hot_water_setpoint` to the output. Will become an additional Number in Plugwise(-beta).
512
- Create separate dicts for `domestic_hot_water_setpoint`, `maximum_boiler_temperature`, and `thermostat` in the output.

plugwise/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Plugwise module."""
22

3-
__version__ = "0.21.0"
3+
__version__ = "0.21.1"
44

55
from plugwise.smile import Smile
66
from plugwise.stick import Stick

plugwise/connections/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ def _reader_deamon(self):
5959
_LOGGER.debug("Reader daemon stopped")
6060

6161
# TODO: 20220125 function instead of self
62-
# pylint: disable=no-self-use
6362
def _read_data(self):
6463
"""placeholder."""
6564
return b"0000"

plugwise/constants.py

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,6 @@
474474
ATTR_NAME: "water_temperature",
475475
ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS,
476476
},
477-
"cooling_enabled": {ATTR_UNIT_OF_MEASUREMENT: NONE},
478477
"domestic_hot_water_comfort_mode": {
479478
ATTR_NAME: "dhw_cm_switch",
480479
ATTR_UNIT_OF_MEASUREMENT: NONE,
@@ -529,45 +528,18 @@
529528

530529
# Known types of Smiles and Stretches
531530
SMILES: Final[dict[str, dict[str, str]]] = {
532-
"smile_open_therm_v3": {
533-
"type": "thermostat",
534-
"friendly_name": "Adam",
535-
},
536-
"smile_open_therm_v2": {
537-
"type": "thermostat",
538-
"friendly_name": "Adam",
539-
},
540-
"smile_thermo_v4": {
541-
"type": "thermostat",
542-
"friendly_name": "Anna",
543-
},
544-
"smile_thermo_v3": {
545-
"type": "thermostat",
546-
"friendly_name": "Anna",
547-
},
548-
"smile_thermo_v1": {
549-
"type": "thermostat",
550-
"friendly_name": "Anna",
551-
"legacy": "true",
552-
},
553-
"smile_v4": {
554-
"type": "power",
555-
"friendly_name": "P1",
556-
},
557-
"smile_v3": {
558-
"type": "power",
559-
"friendly_name": "P1",
560-
},
561-
"smile_v2": {
562-
"type": "power",
563-
"friendly_name": "P1",
564-
"legacy": "true",
565-
},
566-
"stretch_v3": {"type": "stretch", "friendly_name": "Stretch", "legacy": "true"},
567-
"stretch_v2": {"type": "stretch", "friendly_name": "Stretch", "legacy": "true"},
531+
"smile_v2": {"type": "power", "name": "P1"},
532+
"smile_v3": {"type": "power", "name": "P1"},
533+
"smile_v4": {"type": "power", "name": "P1"},
534+
"smile_open_therm_v2": {"type": "thermostat", "name": "Adam"},
535+
"smile_open_therm_v3": {"type": "thermostat", "name": "Adam"},
536+
"smile_thermo_v1": {"type": "thermostat", "name": "Smile"},
537+
"smile_thermo_v3": {"type": "thermostat", "name": "Smile"},
538+
"smile_thermo_v4": {"type": "thermostat", "name": "Smile"},
539+
"stretch_v2": {"type": "stretch", "name": "Stretch"},
540+
"stretch_v3": {"type": "stretch", "name": "Stretch"},
568541
}
569542

570-
571543
# All available Binary Sensor, Sensor, and Switch Types
572544

573545
BINARY_SENSORS: Final[list[str]] = [
@@ -684,7 +656,6 @@ class SmileSensors(TypedDict, total=False):
684656
battery: float
685657
cooling_activation_outdoor_temperature: float
686658
cooling_deactivation_threshold: float
687-
cooling_enabled: bool
688659
temperature: float
689660
electricity_consumed: float
690661
electricity_consumed_interval: float
@@ -782,8 +753,11 @@ class DeviceDataPoints(
782753
class DeviceData(ApplianceData, DeviceDataPoints, TypedDict, total=False):
783754
"""The Device Data class, covering the collected and ordere output-data per device."""
784755

756+
adam_cooling_enabled: bool
785757
binary_sensors: SmileBinarySensors
786758
domestic_hot_water_setpoint: ActuatorData
759+
elga_cooling_enabled: bool
760+
lortherm_cooling_enabled: bool
787761
sensors: SmileSensors
788762
switches: SmileSwitches
789763
thermostat: ActuatorData

plugwise/helper.py

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,11 @@ class SmileHelper:
314314

315315
def __init__(self) -> None:
316316
"""Set the constructor for this class."""
317-
self._appl_data: dict[str, ApplianceData] = {}
318-
self._appliances: etree
319-
self._allowed_modes: list[str] = []
320317
self._adam_cooling_enabled = False
318+
self._allowed_modes: list[str] = []
321319
self._anna_cooling_present = False
320+
self._appliances: etree
321+
self._appl_data: dict[str, ApplianceData] = {}
322322
self._cooling_activation_outdoor_temp: float
323323
self._cooling_deactivation_threshold: float
324324
self._cooling_present = False
@@ -327,8 +327,8 @@ def __init__(self) -> None:
327327
self._home_location: str
328328
self._is_thermostat = False
329329
self._last_active: dict[str, str | None] = {}
330-
self._loc_data: dict[str, ThermoLoc] = {}
331330
self._locations: etree
331+
self._loc_data: dict[str, ThermoLoc] = {}
332332
self._modules: etree
333333
self._on_off_device = False
334334
self._opentherm_device = False
@@ -338,23 +338,22 @@ def __init__(self) -> None:
338338
self._stretch_v2 = False
339339
self._stretch_v3 = False
340340
self._thermo_locs: dict[str, ThermoLoc] = {}
341-
342341
###################################################################
343-
# 'elga_cooling_enabled' refers to the state of the Elga heatpump
342+
# '_elga_cooling_enabled' refers to the state of the Elga heatpump
344343
# connected to an Anna. For Elga, 'elga_status_code' in [8, 9]
345344
# means cooling mode is available, next to heating mode.
346345
# 'elga_status_code' = 8 means cooling is active, 9 means idle.
347346
#
348-
# 'lortherm_cooling_enabled' refers to the state of the Loria or
347+
# '_lortherm_cooling_enabled' refers to the state of the Loria or
349348
# Thermastage heatpump connected to an Anna. For these,
350349
# 'cooling_state' = on means set to cooling mode, instead of to
351350
# heating mode.
352351
# 'modulation_level' = 100 means cooling is active, 0.0 means idle.
353352
###################################################################
354353
self._elga_cooling_active = False
355-
self.elga_cooling_enabled = False
354+
self._elga_cooling_enabled = False
356355
self._lortherm_cooling_active = False
357-
self.lortherm_cooling_enabled = False
356+
self._lortherm_cooling_enabled = False
358357

359358
self.gateway_id: str
360359
self.gw_data: GatewayData = {}
@@ -616,8 +615,8 @@ def _all_appliances(self) -> None:
616615
if self.smile_type == "thermostat":
617616
self._appl_data[self._home_location].update(
618617
{
619-
"model": "Anna",
620-
"name": "Anna",
618+
"model": "Smile",
619+
"name": "Smile",
621620
"vendor": "Plugwise B.V.",
622621
}
623622
)
@@ -888,20 +887,25 @@ def _get_appliance_data(self, d_id: str) -> DeviceData:
888887
if "temperature" in data:
889888
data.pop("heating_state", None)
890889

891-
if self.smile_name == "Anna" and d_id == self._heater_id:
892-
# Use elga_status_code or cooling_state to set the relevant *_cooling_enabled to True
893-
if self._anna_cooling_present:
890+
if d_id == self._heater_id:
891+
if self._adam_cooling_enabled:
892+
data["adam_cooling_enabled"] = self._adam_cooling_enabled
893+
if self.smile_name == "Smile":
894+
# Use elga_status_code or cooling_state to set the relevant *_cooling_enabled to True
895+
if not self._anna_cooling_present:
896+
pass
897+
894898
# Elga:
895899
if "elga_status_code" in data:
896-
self.elga_cooling_enabled = data["elga_status_code"] in [8, 9]
900+
self._elga_cooling_enabled = data["elga_status_code"] in [8, 9]
901+
data["elga_cooling_enabled"] = self._elga_cooling_enabled
897902
self._elga_cooling_active = data["elga_status_code"] == 8
898903
data.pop("elga_status_code", None)
899-
# Loria/Thermastate:
904+
# Loria/Thermastate: look at cooling_state, not at cooling_enabled, not available on R32!
900905
elif "cooling_state" in data:
901-
self.lortherm_cooling_enabled = data["cooling_state"]
902-
self._lortherm_cooling_active = False
903-
if data["modulation_level"] == 100:
904-
self._lortherm_cooling_active = True
906+
self._lortherm_cooling_enabled = data["cooling_state"]
907+
data["lortherm_cooling_enabled"] = self._lortherm_cooling_enabled
908+
self._lortherm_cooling_active = data["modulation_level"] == 100
905909

906910
# Don't show cooling_state when no cooling present
907911
if not self._cooling_present and "cooling_state" in data:
@@ -989,7 +993,7 @@ def _group_switches(self) -> dict[str, ApplianceData]:
989993
"""
990994
switch_groups: dict[str, ApplianceData] = {}
991995
# P1 and Anna don't have switchgroups
992-
if self.smile_type == "power" or self.smile_name == "Anna":
996+
if self.smile_type == "power" or self.smile_name == "Smile":
993997
return switch_groups
994998

995999
for group in self._domain_objects.findall("./group"):

plugwise/smile.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def update_for_cooling(self, devices: dict[str, DeviceData]) -> None:
5454
"""Helper-function for adding/updating various cooling-related values."""
5555
for _, device in devices.items():
5656
# For Anna + cooling, modify cooling_state based on provided info by Plugwise
57-
if self.smile_name == "Anna":
57+
if self.smile_name == "Smile":
5858
if device["dev_class"] == "heater_central" and self._cooling_present:
5959
device["binary_sensors"]["cooling_state"] = False
6060
if self._elga_cooling_active or self._lortherm_cooling_active:
@@ -64,7 +64,7 @@ def update_for_cooling(self, devices: dict[str, DeviceData]) -> None:
6464
if device["dev_class"] not in ZONE_THERMOSTATS:
6565
continue
6666

67-
if self.elga_cooling_enabled:
67+
if self._elga_cooling_enabled:
6868
# Replace setpoint with setpoint_high/_low
6969
thermostat = device["thermostat"]
7070
sensors = device["sensors"]
@@ -153,7 +153,7 @@ def get_all_devices(self) -> None:
153153
search = self._domain_objects
154154
self._anna_cooling_present = adam_cooling_present = False
155155
if search.find(locator_1) is not None:
156-
if self.smile_name == "Anna":
156+
if self.smile_name == "Smile":
157157
self._anna_cooling_present = True
158158
else:
159159
adam_cooling_present = True
@@ -245,9 +245,9 @@ def _device_data_climate(
245245
device_data["mode"] = "auto"
246246
if sel_schedule == "None":
247247
device_data["mode"] = "heat"
248-
if self.elga_cooling_enabled:
248+
if self._elga_cooling_enabled:
249249
device_data["mode"] = "heat_cool"
250-
if self._adam_cooling_enabled or self.lortherm_cooling_enabled:
250+
if self._adam_cooling_enabled or self._lortherm_cooling_enabled:
251251
device_data["mode"] = "cool"
252252

253253
return device_data
@@ -450,11 +450,11 @@ async def _smile_detect(self, result: etree, dsmrmain: etree) -> None:
450450
)
451451
raise UnsupportedDeviceError("Plugwise error, check log for more info.")
452452

453-
self.smile_name = SMILES[target_smile]["friendly_name"]
453+
self.smile_name = SMILES[target_smile]["name"]
454454
self.smile_type = SMILES[target_smile]["type"]
455455
self.smile_version = (self.smile_fw_version, ver)
456456

457-
if "legacy" in SMILES[target_smile]:
457+
if target_smile in ["smile_thermo_v1", "smile_v2", "stretch_v3", "stretch_v2"]:
458458
self._smile_legacy = True
459459

460460
if self.smile_type == "stretch":
@@ -661,7 +661,7 @@ async def set_temperature(self, loc_id: str, items: dict[str, float]) -> None:
661661
setpoint: float | None = None
662662
if "setpoint" in items:
663663
setpoint = items["setpoint"]
664-
if self.elga_cooling_enabled:
664+
if self._elga_cooling_enabled:
665665
if "setpoint_low" in items:
666666
setpoint = items["setpoint_low"]
667667
if self._elga_cooling_active:

pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ ignore = [
2626
# Disabled for now: https://github.com/PyCQA/pylint/issues/3584
2727
jobs = 2
2828
# Disabled pylint_strict_informational for codefactor
29-
load-plugins = [
30-
"pylint_strict_informational",
31-
]
29+
#load-plugins = [
30+
# "pylint_strict_informational",
31+
#]
3232
persistent = false
3333
extension-pkg-whitelist = [
3434
"ciso8601",
@@ -65,7 +65,6 @@ good-names = [
6565
# wrong-import-order - isort guards this
6666
disable = [
6767
"format",
68-
"abstract-class-little-used",
6968
"abstract-method",
7069
"consider-using-f-string",
7170
"cyclic-import",

0 commit comments

Comments
 (0)