Skip to content

Commit 3690dac

Browse files
committed
Improve handling of obsolete measurements
1 parent 77260f7 commit 3690dac

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

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: 11 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,16 @@ 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 = f'.//logs/point_log[type="{measurement}"]/updated_date'
848+
if (updated_date_key := appliance.find(updated_date_locator) is not None:
849+
if measurement in OBSOLETE_MEASUREMENTS:
850+
updated_date = updated_date_key.text.strip("T")
851+
t1 = dt.strptime(updated_date, "%Y-%m-%d")
852+
t2 = dt.datetime.now().strftime("%Y-%m-%d")
853+
difference = (t2 -t1).days
854+
if difference > 30:
855+
continue
852856

853857
if new_name := getattr(attrs, ATTR_NAME, None):
854858
measurement = new_name

0 commit comments

Comments
 (0)