diff --git a/custom_components/heating_mpc/compatibility.py b/custom_components/heating_mpc/compatibility.py index 00cd6ae..71a62c9 100644 --- a/custom_components/heating_mpc/compatibility.py +++ b/custom_components/heating_mpc/compatibility.py @@ -15,7 +15,7 @@ everything else is kept. What each fingerprint covers: * ventilation terms: the measurement plus the zone's windows (sensor, polarity, opening factor); "vent_wind_dir" also the windows' facing directions; "recovery" also the recovery time constant; "vent_cross" also the other zones' - windows. + windows (sensor, polarity, opening factor). Comfort weight, target offset and names are not physical and are never included. """ @@ -71,7 +71,7 @@ def zone_fingerprints(zones: Mapping[str, Any], sources: Iterable[Any], windows: m = measured[key] plain = zone_windows(key) # Cross-ventilation scales with the other zones' openings. - others = sorted([w.sensor, w.opening] for w in windows if w.zone != key and w.enabled) + others = sorted([w.sensor, w.inverted, w.opening] for w in windows if w.zone != key and w.enabled) prints = {"base": m, "loss": m, "heat": m, "bias": m, "internal": _hash([m, sorted(source_signature(s, sources) for s in sources if s.zone == key and s.enabled)]), diff --git a/tests/test_compatibility.py b/tests/test_compatibility.py index f269b71..746c58e 100644 --- a/tests/test_compatibility.py +++ b/tests/test_compatibility.py @@ -72,6 +72,12 @@ class FingerprintTests(unittest.TestCase): self.assertEqual(diff['bed'], ['recovery', 'vent_cross', 'vent_gust', 'vent_natural', 'vent_wind', 'vent_wind_dir']) self.assertEqual(diff['living'], ['vent_cross']) # sees the bedroom's windows + # A flipped polarity reverses what every term saw as open, the neighbour's too. + flipped = [{'key': 'w1', 'sensor': 'binary_sensor.w1', 'zone': 'bed', 'azimuth': 345, 'inverted': True}, + {'key': 'w2', 'sensor': 'binary_sensor.w2', 'zone': 'living', 'azimuth': 345}] + diff = differing(self.base, setup(windows=flipped)[0]) + self.assertIn('vent_natural', diff['bed']) + self.assertEqual(diff['living'], ['vent_cross']) self.assertEqual(differing(self.base, setup(recovery=40)[0]), {'living': ['recovery'], 'bed': ['recovery']}) def test_baseline_prints_and_change_detection(self):