From 1842c31d252e4d6f2d84e0c248b767c761d8b62a Mon Sep 17 00:00:00 2001 From: Bouwe Date: Sun, 17 Mar 2024 14:28:01 +0100 Subject: [PATCH 1/7] Replace slave and master with secondary and main --- plugwise/constants.py | 10 +++---- plugwise/data.py | 4 +-- plugwise/helper.py | 30 +++++++++---------- plugwise/legacy/data.py | 2 +- tests/data/anna/anna_elga_2.json | 2 +- tests/data/anna/anna_elga_2_cooling.json | 2 +- tests/data/anna/anna_elga_no_cooling.json | 2 +- tests/data/anna/anna_heatpump_cooling.json | 2 +- tests/data/anna/anna_heatpump_heating.json | 2 +- .../anna_heatpump_heating_UPDATED_DATA.json | 2 +- 10 files changed, 29 insertions(+), 29 deletions(-) diff --git a/plugwise/constants.py b/plugwise/constants.py index 752d2600d..5425d9199 100644 --- a/plugwise/constants.py +++ b/plugwise/constants.py @@ -168,7 +168,7 @@ # Available with the Loria and Elga (newer Anna firmware) heatpumps "cooling_enabled": UOM(NONE), # Next 2 keys are used to show the state of the gas-heater used next to the Elga heatpump - marcelveldt - "slave_boiler_state": UOM(NONE), + "slave_boiler_state": DATA("secondary_boiler_state", NONE), "flame_state": UOM(NONE), # Also present when there is a single gas-heater "central_heater_water_pressure": DATA("water_pressure", PRESSURE_BAR), # Legacy Anna: similar to flame-state on Anna/Adam @@ -260,7 +260,7 @@ "flame_state", "heating_state", "plugwise_notification", - "slave_boiler_state", + "secondary_boiler_state", ] BINARY_SENSORS: Final[tuple[str, ...]] = get_args(BinarySensorType) @@ -410,7 +410,7 @@ class SmileBinarySensors(TypedDict, total=False): flame_state: bool heating_state: bool plugwise_notification: bool - slave_boiler_state: bool + secondary_boiler_state: bool class SmileSensors(TypedDict, total=False): @@ -482,9 +482,9 @@ class ThermoLoc(TypedDict, total=False): """Thermo Location class.""" name: str - master: str | None + main: str | None master_prio: int - slaves: set[str] + secondary: set[str] class ActuatorData(TypedDict, total=False): diff --git a/plugwise/data.py b/plugwise/data.py index 3bf49e7f6..280a113de 100644 --- a/plugwise/data.py +++ b/plugwise/data.py @@ -125,7 +125,7 @@ def _get_device_data(self, dev_id: str) -> DeviceData: self._device_data_switching_group(device, data) # Adam data self._device_data_adam(device, data) - # Skip obtaining data for non master-thermostats + # Skip obtaining data for non main-thermostats if device["dev_class"] not in ZONE_THERMOSTATS: return data @@ -173,7 +173,7 @@ def _device_data_adam(self, device: DeviceData, data: DeviceData) -> None: data["gateway_modes"] = self._gw_allowed_modes self._count += 1 - # Control_state, only for Adam master thermostats + # Control_state, only for Adam main thermostats if device["dev_class"] in ZONE_THERMOSTATS: loc_id = device["location"] if ctrl_state := self._control_state(loc_id): diff --git a/plugwise/helper.py b/plugwise/helper.py index 0612c9c89..e8e23d414 100644 --- a/plugwise/helper.py +++ b/plugwise/helper.py @@ -813,7 +813,7 @@ def _scan_thermostats(self) -> None: """Helper-function for smile.py: get_all_devices(). Update locations with thermostat ranking results and use - the result to update the device_class of slave thermostats. + the result to update the device_class of secondary thermostats. """ self._thermo_locs = self._match_locations() @@ -828,11 +828,11 @@ def _scan_thermostats(self) -> None: for dev_id, device in self.gw_devices.items(): self._rank_thermostat(thermo_matching, loc_id, dev_id, device) - # Update slave thermostat class where needed + # Update secondary thermostat class where needed for dev_id, device in self.gw_devices.items(): if (loc_id := device["location"]) in self._thermo_locs: tl_loc_id = self._thermo_locs[loc_id] - if "slaves" in tl_loc_id and dev_id in tl_loc_id["slaves"]: + if "secondary" in tl_loc_id and dev_id in tl_loc_id["secondary"]: device["dev_class"] = "thermo_sensor" def _match_locations(self) -> dict[str, ThermoLoc]: @@ -845,7 +845,7 @@ def _match_locations(self) -> dict[str, ThermoLoc]: for appliance_details in self.gw_devices.values(): if appliance_details["location"] == location_id: location_details.update( - {"master": None, "master_prio": 0, "slaves": set()} + {"main": None, "main_prio": 0, "secondary": set()} ) matched_locations[location_id] = location_details @@ -860,29 +860,29 @@ def _rank_thermostat( ) -> None: """Helper-function for _scan_thermostats(). - Rank the thermostat based on appliance_details: master or slave. + Rank the thermostat based on appliance_details: main or secondary. """ appl_class = appliance_details["dev_class"] appl_d_loc = appliance_details["location"] if loc_id == appl_d_loc and appl_class in thermo_matching: - # Pre-elect new master - if thermo_matching[appl_class] > self._thermo_locs[loc_id]["master_prio"]: - # Demote former master - if (tl_master := self._thermo_locs[loc_id]["master"]) is not None: - self._thermo_locs[loc_id]["slaves"].add(tl_master) + # Pre-elect new main + if thermo_matching[appl_class] > self._thermo_locs[loc_id]["main_prio"]: + # Demote former main + if (tl_main := self._thermo_locs[loc_id]["main"]) is not None: + self._thermo_locs[loc_id]["secondary"].add(tl_main) - # Crown master - self._thermo_locs[loc_id]["master_prio"] = thermo_matching[appl_class] - self._thermo_locs[loc_id]["master"] = appliance_id + # Crown main + self._thermo_locs[loc_id]["main_prio"] = thermo_matching[appl_class] + self._thermo_locs[loc_id]["main"] = appliance_id else: - self._thermo_locs[loc_id]["slaves"].add(appliance_id) + self._thermo_locs[loc_id]["secondary"].add(appliance_id) def _control_state(self, loc_id: str) -> str | bool: """Helper-function for _device_data_adam(). Adam: find the thermostat control_state of a location, from DOMAIN_OBJECTS. - Represents the heating/cooling demand-state of the local master thermostat. + Represents the heating/cooling demand-state of the local main thermostat. Note: heating or cooling can still be active when the setpoint has been reached. """ locator = f'location[@id="{loc_id}"]' diff --git a/plugwise/legacy/data.py b/plugwise/legacy/data.py index 74dd0d222..f2f8f9097 100644 --- a/plugwise/legacy/data.py +++ b/plugwise/legacy/data.py @@ -57,7 +57,7 @@ def _get_device_data(self, dev_id: str) -> DeviceData: # Switching groups data self._device_data_switching_group(device, data) - # Skip obtaining data for non master-thermostats + # Skip obtaining data for non main-thermostats if device["dev_class"] not in ZONE_THERMOSTATS: return data diff --git a/tests/data/anna/anna_elga_2.json b/tests/data/anna/anna_elga_2.json index 5bcfe4a0c..0eed7c034 100644 --- a/tests/data/anna/anna_elga_2.json +++ b/tests/data/anna/anna_elga_2.json @@ -34,7 +34,7 @@ "compressor_state": false, "cooling_state": false, "cooling_enabled": false, - "slave_boiler_state": false, + "secondary_boiler_state": false, "flame_state": false }, "sensors": { diff --git a/tests/data/anna/anna_elga_2_cooling.json b/tests/data/anna/anna_elga_2_cooling.json index 0883ef00c..20a0b293b 100644 --- a/tests/data/anna/anna_elga_2_cooling.json +++ b/tests/data/anna/anna_elga_2_cooling.json @@ -8,7 +8,7 @@ "dhw_state": false, "flame_state": false, "heating_state": false, - "slave_boiler_state": false + "secondary_boiler_state": false }, "dev_class": "heater_central", "location": "d34dfe6ab90b410c98068e75de3eb631", diff --git a/tests/data/anna/anna_elga_no_cooling.json b/tests/data/anna/anna_elga_no_cooling.json index e3342814b..92925247d 100644 --- a/tests/data/anna/anna_elga_no_cooling.json +++ b/tests/data/anna/anna_elga_no_cooling.json @@ -38,7 +38,7 @@ "dhw_state": false, "heating_state": true, "compressor_state": true, - "slave_boiler_state": false, + "secondary_boiler_state": false, "flame_state": false }, "sensors": { diff --git a/tests/data/anna/anna_heatpump_cooling.json b/tests/data/anna/anna_heatpump_cooling.json index dc4f32e53..88b5ef37f 100644 --- a/tests/data/anna/anna_heatpump_cooling.json +++ b/tests/data/anna/anna_heatpump_cooling.json @@ -34,7 +34,7 @@ "compressor_state": true, "cooling_enabled": true, "cooling_state": true, - "slave_boiler_state": false, + "secondary_boiler_state": false, "flame_state": false }, "sensors": { diff --git a/tests/data/anna/anna_heatpump_heating.json b/tests/data/anna/anna_heatpump_heating.json index 66083ca89..b38d2b7d9 100644 --- a/tests/data/anna/anna_heatpump_heating.json +++ b/tests/data/anna/anna_heatpump_heating.json @@ -40,7 +40,7 @@ "compressor_state": true, "cooling_state": false, "cooling_enabled": false, - "slave_boiler_state": false, + "secondary_boiler_state": false, "flame_state": false }, "sensors": { diff --git a/tests/data/anna/anna_heatpump_heating_UPDATED_DATA.json b/tests/data/anna/anna_heatpump_heating_UPDATED_DATA.json index 136af014c..e5ad81261 100644 --- a/tests/data/anna/anna_heatpump_heating_UPDATED_DATA.json +++ b/tests/data/anna/anna_heatpump_heating_UPDATED_DATA.json @@ -18,7 +18,7 @@ "compressor_state": true, "cooling_state": false, "cooling_enabled": false, - "slave_boiler_state": false, + "secondary_boiler_state": false, "flame_state": false }, "sensors": { From 9b483e426430eb7a7f96909b5da75e9dcc46ce5f Mon Sep 17 00:00:00 2001 From: Bouwe Date: Sun, 17 Mar 2024 14:28:43 +0100 Subject: [PATCH 2/7] Save updated fixtures --- fixtures/anna_elga_2/all_data.json | 2 +- fixtures/anna_elga_2_cooling/all_data.json | 2 +- fixtures/anna_elga_2_schedule_off/all_data.json | 2 +- fixtures/anna_elga_no_cooling/all_data.json | 2 +- fixtures/anna_heatpump_cooling/all_data.json | 2 +- fixtures/anna_heatpump_cooling_fake_firmware/all_data.json | 2 +- fixtures/anna_heatpump_heating/all_data.json | 2 +- fixtures/m_anna_heatpump_cooling/all_data.json | 2 +- fixtures/m_anna_heatpump_idle/all_data.json | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fixtures/anna_elga_2/all_data.json b/fixtures/anna_elga_2/all_data.json index d9121e94d..ae143390a 100644 --- a/fixtures/anna_elga_2/all_data.json +++ b/fixtures/anna_elga_2/all_data.json @@ -9,7 +9,7 @@ "dhw_state": false, "flame_state": false, "heating_state": false, - "slave_boiler_state": false + "secondary_boiler_state": false }, "dev_class": "heater_central", "location": "d34dfe6ab90b410c98068e75de3eb631", diff --git a/fixtures/anna_elga_2_cooling/all_data.json b/fixtures/anna_elga_2_cooling/all_data.json index 509ed34a4..6e5fef4ac 100644 --- a/fixtures/anna_elga_2_cooling/all_data.json +++ b/fixtures/anna_elga_2_cooling/all_data.json @@ -9,7 +9,7 @@ "dhw_state": false, "flame_state": false, "heating_state": false, - "slave_boiler_state": false + "secondary_boiler_state": false }, "dev_class": "heater_central", "location": "d34dfe6ab90b410c98068e75de3eb631", diff --git a/fixtures/anna_elga_2_schedule_off/all_data.json b/fixtures/anna_elga_2_schedule_off/all_data.json index 1d502983e..f3b446721 100644 --- a/fixtures/anna_elga_2_schedule_off/all_data.json +++ b/fixtures/anna_elga_2_schedule_off/all_data.json @@ -9,7 +9,7 @@ "dhw_state": false, "flame_state": false, "heating_state": false, - "slave_boiler_state": false + "secondary_boiler_state": false }, "dev_class": "heater_central", "location": "d34dfe6ab90b410c98068e75de3eb631", diff --git a/fixtures/anna_elga_no_cooling/all_data.json b/fixtures/anna_elga_no_cooling/all_data.json index e1c6ffcfe..863795608 100644 --- a/fixtures/anna_elga_no_cooling/all_data.json +++ b/fixtures/anna_elga_no_cooling/all_data.json @@ -23,7 +23,7 @@ "dhw_state": false, "flame_state": false, "heating_state": true, - "slave_boiler_state": false + "secondary_boiler_state": false }, "dev_class": "heater_central", "location": "a57efe5f145f498c9be62a9b63626fbf", diff --git a/fixtures/anna_heatpump_cooling/all_data.json b/fixtures/anna_heatpump_cooling/all_data.json index 95cceaa49..5b37b339d 100644 --- a/fixtures/anna_heatpump_cooling/all_data.json +++ b/fixtures/anna_heatpump_cooling/all_data.json @@ -25,7 +25,7 @@ "dhw_state": false, "flame_state": false, "heating_state": false, - "slave_boiler_state": false + "secondary_boiler_state": false }, "dev_class": "heater_central", "location": "a57efe5f145f498c9be62a9b63626fbf", diff --git a/fixtures/anna_heatpump_cooling_fake_firmware/all_data.json b/fixtures/anna_heatpump_cooling_fake_firmware/all_data.json index 71cff7131..595d43951 100644 --- a/fixtures/anna_heatpump_cooling_fake_firmware/all_data.json +++ b/fixtures/anna_heatpump_cooling_fake_firmware/all_data.json @@ -25,7 +25,7 @@ "dhw_state": false, "flame_state": false, "heating_state": false, - "slave_boiler_state": false + "secondary_boiler_state": false }, "dev_class": "heater_central", "location": "a57efe5f145f498c9be62a9b63626fbf", diff --git a/fixtures/anna_heatpump_heating/all_data.json b/fixtures/anna_heatpump_heating/all_data.json index d655f95c7..d496edb41 100644 --- a/fixtures/anna_heatpump_heating/all_data.json +++ b/fixtures/anna_heatpump_heating/all_data.json @@ -25,7 +25,7 @@ "dhw_state": false, "flame_state": false, "heating_state": true, - "slave_boiler_state": false + "secondary_boiler_state": false }, "dev_class": "heater_central", "location": "a57efe5f145f498c9be62a9b63626fbf", diff --git a/fixtures/m_anna_heatpump_cooling/all_data.json b/fixtures/m_anna_heatpump_cooling/all_data.json index 92c95f6c5..ef7af8a36 100644 --- a/fixtures/m_anna_heatpump_cooling/all_data.json +++ b/fixtures/m_anna_heatpump_cooling/all_data.json @@ -25,7 +25,7 @@ "dhw_state": false, "flame_state": false, "heating_state": false, - "slave_boiler_state": false + "secondary_boiler_state": false }, "dev_class": "heater_central", "location": "a57efe5f145f498c9be62a9b63626fbf", diff --git a/fixtures/m_anna_heatpump_idle/all_data.json b/fixtures/m_anna_heatpump_idle/all_data.json index be400b9bc..8f2e6a75f 100644 --- a/fixtures/m_anna_heatpump_idle/all_data.json +++ b/fixtures/m_anna_heatpump_idle/all_data.json @@ -25,7 +25,7 @@ "dhw_state": false, "flame_state": false, "heating_state": false, - "slave_boiler_state": false + "secondary_boiler_state": false }, "dev_class": "heater_central", "location": "a57efe5f145f498c9be62a9b63626fbf", From 171d0c87d6e896ae3c26c602db2fd12005f110c2 Mon Sep 17 00:00:00 2001 From: Bouwe Date: Sun, 17 Mar 2024 14:40:04 +0100 Subject: [PATCH 3/7] Use primary instead of main --- plugwise/constants.py | 4 ++-- plugwise/data.py | 4 ++-- plugwise/helper.py | 22 +++++++++++----------- plugwise/legacy/data.py | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/plugwise/constants.py b/plugwise/constants.py index 5425d9199..9075eb576 100644 --- a/plugwise/constants.py +++ b/plugwise/constants.py @@ -482,8 +482,8 @@ class ThermoLoc(TypedDict, total=False): """Thermo Location class.""" name: str - main: str | None - master_prio: int + primary: str | None + primary_prio: int secondary: set[str] diff --git a/plugwise/data.py b/plugwise/data.py index 280a113de..edb350411 100644 --- a/plugwise/data.py +++ b/plugwise/data.py @@ -125,7 +125,7 @@ def _get_device_data(self, dev_id: str) -> DeviceData: self._device_data_switching_group(device, data) # Adam data self._device_data_adam(device, data) - # Skip obtaining data for non main-thermostats + # Skip obtaining data for non primary-thermostats if device["dev_class"] not in ZONE_THERMOSTATS: return data @@ -173,7 +173,7 @@ def _device_data_adam(self, device: DeviceData, data: DeviceData) -> None: data["gateway_modes"] = self._gw_allowed_modes self._count += 1 - # Control_state, only for Adam main thermostats + # Control_state, only for Adam primary thermostats if device["dev_class"] in ZONE_THERMOSTATS: loc_id = device["location"] if ctrl_state := self._control_state(loc_id): diff --git a/plugwise/helper.py b/plugwise/helper.py index e8e23d414..1eb427446 100644 --- a/plugwise/helper.py +++ b/plugwise/helper.py @@ -845,7 +845,7 @@ def _match_locations(self) -> dict[str, ThermoLoc]: for appliance_details in self.gw_devices.values(): if appliance_details["location"] == location_id: location_details.update( - {"main": None, "main_prio": 0, "secondary": set()} + {"primary": None, "primary_prio": 0, "secondary": set()} ) matched_locations[location_id] = location_details @@ -860,20 +860,20 @@ def _rank_thermostat( ) -> None: """Helper-function for _scan_thermostats(). - Rank the thermostat based on appliance_details: main or secondary. + Rank the thermostat based on appliance_details: primary or secondary. """ appl_class = appliance_details["dev_class"] appl_d_loc = appliance_details["location"] if loc_id == appl_d_loc and appl_class in thermo_matching: - # Pre-elect new main - if thermo_matching[appl_class] > self._thermo_locs[loc_id]["main_prio"]: - # Demote former main - if (tl_main := self._thermo_locs[loc_id]["main"]) is not None: - self._thermo_locs[loc_id]["secondary"].add(tl_main) + # Pre-elect new primary + if thermo_matching[appl_class] > self._thermo_locs[loc_id]["primary_prio"]: + # Demote former primary + if (tl_primary:= self._thermo_locs[loc_id]["primary"]) is not None: + self._thermo_locs[loc_id]["secondary"].add(tl_primary) - # Crown main - self._thermo_locs[loc_id]["main_prio"] = thermo_matching[appl_class] - self._thermo_locs[loc_id]["main"] = appliance_id + # Crown primary + self._thermo_locs[loc_id]["primary_prio"] = thermo_matching[appl_class] + self._thermo_locs[loc_id]["primary"] = appliance_id else: self._thermo_locs[loc_id]["secondary"].add(appliance_id) @@ -882,7 +882,7 @@ def _control_state(self, loc_id: str) -> str | bool: """Helper-function for _device_data_adam(). Adam: find the thermostat control_state of a location, from DOMAIN_OBJECTS. - Represents the heating/cooling demand-state of the local main thermostat. + Represents the heating/cooling demand-state of the local primary thermostat. Note: heating or cooling can still be active when the setpoint has been reached. """ locator = f'location[@id="{loc_id}"]' diff --git a/plugwise/legacy/data.py b/plugwise/legacy/data.py index f2f8f9097..6ca8a1bf0 100644 --- a/plugwise/legacy/data.py +++ b/plugwise/legacy/data.py @@ -57,7 +57,7 @@ def _get_device_data(self, dev_id: str) -> DeviceData: # Switching groups data self._device_data_switching_group(device, data) - # Skip obtaining data for non main-thermostats + # Skip obtaining data for non primary-thermostats if device["dev_class"] not in ZONE_THERMOSTATS: return data From 632a054ecc96d58bea45bea22623845558a72a72 Mon Sep 17 00:00:00 2001 From: Bouwe Date: Sun, 17 Mar 2024 19:52:44 +0100 Subject: [PATCH 4/7] Improve comments --- plugwise/data.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugwise/data.py b/plugwise/data.py index edb350411..1df72b30d 100644 --- a/plugwise/data.py +++ b/plugwise/data.py @@ -125,7 +125,7 @@ def _get_device_data(self, dev_id: str) -> DeviceData: self._device_data_switching_group(device, data) # Adam data self._device_data_adam(device, data) - # Skip obtaining data for non primary-thermostats + # Skip obtaining data for (Adam) secondary thermostats if device["dev_class"] not in ZONE_THERMOSTATS: return data @@ -164,7 +164,7 @@ def _device_data_adam(self, device: DeviceData, data: DeviceData) -> None: ): data["binary_sensors"]["heating_state"] = self._heating_valves() != 0 - # Show the allowed regulation modes and gateway_modes + # Show the allowed regulation_modes and gateway_modes if device["dev_class"] == "gateway": if self._reg_allowed_modes: data["regulation_modes"] = self._reg_allowed_modes @@ -173,7 +173,7 @@ def _device_data_adam(self, device: DeviceData, data: DeviceData) -> None: data["gateway_modes"] = self._gw_allowed_modes self._count += 1 - # Control_state, only for Adam primary thermostats + # Control_state, only available for Adam primary thermostats if device["dev_class"] in ZONE_THERMOSTATS: loc_id = device["location"] if ctrl_state := self._control_state(loc_id): From 4269a3a7e787839eee105447375f90b643ea2575 Mon Sep 17 00:00:00 2001 From: Bouwe Date: Sun, 17 Mar 2024 19:59:09 +0100 Subject: [PATCH 5/7] Improve code --- plugwise/legacy/data.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugwise/legacy/data.py b/plugwise/legacy/data.py index 6ca8a1bf0..908888c9b 100644 --- a/plugwise/legacy/data.py +++ b/plugwise/legacy/data.py @@ -6,7 +6,7 @@ # Dict as class # Version detection -from plugwise.constants import NONE, ZONE_THERMOSTATS, DeviceData +from plugwise.constants import NONE, DeviceData from plugwise.legacy.helper import SmileLegacyHelper from plugwise.util import remove_empty_platform_dicts @@ -57,8 +57,8 @@ def _get_device_data(self, dev_id: str) -> DeviceData: # Switching groups data self._device_data_switching_group(device, data) - # Skip obtaining data for non primary-thermostats - if device["dev_class"] not in ZONE_THERMOSTATS: + # Skip obtaining data when not a thermostat + if device["dev_class"] != "thermostat": return data # Thermostat data (presets, temperatures etc) From b0345436a600185f534abbc6bcfc2439ded90d2e Mon Sep 17 00:00:00 2001 From: Bouwe Date: Sun, 17 Mar 2024 20:01:23 +0100 Subject: [PATCH 6/7] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02edca25b..c2fce8547 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Ongoing +- Code improvements - Remove unused dependencies from pyproject.toml ## V0.37.1 From 86ec5b719809339875e446d3746d7a4f60514246 Mon Sep 17 00:00:00 2001 From: Bouwe Date: Sun, 17 Mar 2024 20:22:13 +0100 Subject: [PATCH 7/7] Sort constants --- plugwise/constants.py | 79 ++++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/plugwise/constants.py b/plugwise/constants.py index 9075eb576..3b959d68c 100644 --- a/plugwise/constants.py +++ b/plugwise/constants.py @@ -121,21 +121,20 @@ # radiator_valve: 'uncorrected_temperature', 'temperature_offset' DEVICE_MEASUREMENTS: Final[dict[str, DATA | UOM]] = { - # HA Core thermostat current_temperature - "temperature": UOM(TEMP_CELSIUS), - # HA Core thermostat setpoint - "thermostat": DATA("setpoint", TEMP_CELSIUS), - # Specific for an Anna - "illuminance": UOM(UNIT_LUMEN), + "humidity": UOM(PERCENTAGE), # Specific for a Jip + "illuminance": UOM(UNIT_LUMEN), # Specific for an Anna + "temperature": UOM(TEMP_CELSIUS), # HA Core thermostat current_temperature + "thermostat": DATA("setpoint", TEMP_CELSIUS), # HA Core thermostat setpoint + ######################################################## # Specific for an Anna with heatpump extension installed "cooling_activation_outdoor_temperature": UOM(TEMP_CELSIUS), "cooling_deactivation_threshold": UOM(TEMP_CELSIUS), - # Specific for a Lisa a Tom/Floor + ################################## + # Specific for a Lisa or Tom/Floor "battery": UOM(PERCENTAGE), "temperature_difference": UOM(DEGREE), "valve_position": UOM(PERCENTAGE), - # Specific for a Jip - "humidity": UOM(PERCENTAGE), + ##################### # Specific for a Plug "electricity_consumed": UOM(POWER_WATT), "electricity_produced": UOM(POWER_WATT), @@ -144,39 +143,43 @@ # Heater Central related measurements HEATER_CENTRAL_MEASUREMENTS: Final[dict[str, DATA | UOM]] = { + "boiler_state": DATA( + "flame_state", NONE + ), # Legacy Anna: similar to flame-state on Anna/Adam "boiler_temperature": DATA("water_temperature", TEMP_CELSIUS), + "central_heating_state": DATA( + "c_heating_state", NONE + ), # For Elga (heatpump) use this instead of intended_central_heating_state + "central_heater_water_pressure": DATA("water_pressure", PRESSURE_BAR), + "compressor_state": UOM(NONE), # present with heatpump + "cooling_enabled": UOM( + NONE + ), # Available with the Loria and Elga (newer Anna firmware) heatpumps + "cooling_state": UOM(NONE), "domestic_hot_water_mode": DATA("select_dhw_mode", NONE), "domestic_hot_water_setpoint": UOM(TEMP_CELSIUS), "domestic_hot_water_state": DATA("dhw_state", NONE), "domestic_hot_water_temperature": DATA("dhw_temperature", TEMP_CELSIUS), "elga_status_code": UOM(NONE), + "intended_boiler_state": DATA( + "heating_state", NONE + ), # Legacy Anna: shows when heating is active, we don't show dhw_state, cannot be determined reliably + "flame_state": UOM( + NONE + ), # Also present when there is a single gas-heater "intended_boiler_temperature": UOM( TEMP_CELSIUS ), # Non-zero when heating, zero when dhw-heating - "central_heating_state": DATA( - "c_heating_state", NONE - ), # For Elga (heatpump) use this instead of intended_central_heating_state "intended_central_heating_state": DATA( "heating_state", NONE ), # This key shows in general the heating-behavior better than c-h_state. except when connected to a heatpump "modulation_level": UOM(PERCENTAGE), "return_water_temperature": DATA("return_temperature", TEMP_CELSIUS), - # Used with the Elga heatpump - marcelveldt - "compressor_state": UOM(NONE), - "cooling_state": UOM(NONE), - "thermostat_supports_cooling": UOM(NONE), - # Available with the Loria and Elga (newer Anna firmware) heatpumps - "cooling_enabled": UOM(NONE), - # Next 2 keys are used to show the state of the gas-heater used next to the Elga heatpump - marcelveldt + "outdoor_temperature": DATA( + "outdoor_air_temperature", TEMP_CELSIUS + ), # Outdoor temperature from APPLIANCES - present for a heatpump "slave_boiler_state": DATA("secondary_boiler_state", NONE), - "flame_state": UOM(NONE), # Also present when there is a single gas-heater - "central_heater_water_pressure": DATA("water_pressure", PRESSURE_BAR), - # Legacy Anna: similar to flame-state on Anna/Adam - "boiler_state": DATA("flame_state", NONE), - # Legacy Anna: shows when heating is active, we don't show dhw_state, cannot be determined reliably - "intended_boiler_state": DATA("heating_state", NONE), - # Outdoor temperature from APPLIANCES - present for a heatpump - "outdoor_temperature": DATA("outdoor_air_temperature", TEMP_CELSIUS), + "thermostat_supports_cooling": UOM(NONE), # present with heatpump } OBSOLETE_MEASUREMENTS: Final[tuple[str, ...]] = ( @@ -253,8 +256,8 @@ ] BinarySensorType = Literal[ - "cooling_enabled", "compressor_state", + "cooling_enabled", "cooling_state", "dhw_state", "flame_state", @@ -265,10 +268,10 @@ BINARY_SENSORS: Final[tuple[str, ...]] = get_args(BinarySensorType) LIMITS: Final[tuple[str, ...]] = ( + "lower_bound", "offset", - "setpoint", "resolution", - "lower_bound", + "setpoint", "upper_bound", ) @@ -329,8 +332,8 @@ SPECIAL_PLUG_TYPES: Final[tuple[str, ...]] = ( "central_heating_pump", - "valve_actuator", "heater_electric", + "valve_actuator", ) SpecialType = Literal[ @@ -350,14 +353,14 @@ ] SWITCHES: Final[tuple[str, ...]] = get_args(SwitchType) -SWITCH_GROUP_TYPES: Final[tuple[str, ...]] = ("switching", "report") +SWITCH_GROUP_TYPES: Final[tuple[str, ...]] = ("report", "switching") THERMOSTAT_CLASSES: Final[tuple[str, ...]] = ( "thermostat", + "thermostatic_radiator_valve", "thermo_sensor", "zone_thermometer", "zone_thermostat", - "thermostatic_radiator_valve", ) ToggleNameType = Literal[ @@ -392,19 +395,19 @@ class ModelData(TypedDict): """The ModelData class.""" contents: bool - vendor_name: str | None - vendor_model: str | None - hardware_version: str | None firmware_version: str | None - zigbee_mac_address: str | None + hardware_version: str | None reachable: bool | None + vendor_model: str | None + vendor_name: str | None + zigbee_mac_address: str | None class SmileBinarySensors(TypedDict, total=False): """Smile Binary Sensors class.""" - cooling_enabled: bool compressor_state: bool + cooling_enabled: bool cooling_state: bool dhw_state: bool flame_state: bool