Skip to content

Commit 562554a

Browse files
authored
Merge pull request #403 from plugwise/obsolete_sensors
Improve handling of obsolete sensors
2 parents 77260f7 + 322a404 commit 562554a

File tree

4 files changed

+79
-54
lines changed

4 files changed

+79
-54
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Ongoing
44

5+
- Improve handling of obsolete sensors (solution for [HA Core issue #100306](https://github.com/home-assistant/core/issues/100306)
56
- Improve handling of invalid actuator xml-data (partial solution for [HA Core issue #99372](https://github.com/home-assistant/core/issues/99372)
67

78
## v0.32.3 Improve quality by extended testing, bugfix

plugwise/constants.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,11 @@
186186
"outdoor_temperature": DATA("outdoor_air_temperature", TEMP_CELSIUS),
187187
}
188188

189+
OBSOLETE_MEASUREMENTS: Final[tuple[str, ...]] = (
190+
"central_heater_water_pressure",
191+
"outdoor_air_temperature",
192+
)
193+
189194
# Known types of Smiles and Stretches
190195
SMILE = namedtuple("SMILE", "smile_type smile_name")
191196
SMILES: Final[dict[str, SMILE]] = {

plugwise/helper.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
LOCATIONS,
4141
LOGGER,
4242
NONE,
43+
OBSOLETE_MEASUREMENTS,
4344
P1_LEGACY_MEASUREMENTS,
4445
P1_MEASUREMENTS,
4546
POWER_WATT,
@@ -842,13 +843,19 @@ def _appliance_measurements(
842843
if self._smile_legacy and measurement == "domestic_hot_water_state":
843844
continue
844845

845-
# Fix for Adam + Anna: there is a pressure-measurement with an unrealistic value,
846-
# this measurement appears at power-on and is never updated, therefore remove.
847-
if (
848-
measurement == "central_heater_water_pressure"
849-
and float(appl_p_loc.text) > 3.5
850-
):
851-
continue
846+
# Skip known obsolete measurements
847+
updated_date_locator = (
848+
f'.//logs/point_log[type="{measurement}"]/updated_date'
849+
)
850+
if measurement in OBSOLETE_MEASUREMENTS:
851+
if (
852+
updated_date_key := appliance.find(updated_date_locator)
853+
) is not None:
854+
updated_date = updated_date_key.text.split("T")[0]
855+
date_1 = dt.datetime.strptime(updated_date, "%Y-%m-%d")
856+
date_2 = dt.datetime.now()
857+
if int((date_2 - date_1).days) > 7:
858+
continue
852859

853860
if new_name := getattr(attrs, ATTR_NAME, None):
854861
measurement = new_name

0 commit comments

Comments
 (0)