Show each sensor's longest report gap; stop recording volatile attributes
Choosing room and weather freshness limits required knowing how long each sensor normally goes without reporting, which HA does not show. Add max_age_seconds_24h to every source in input_quality: the largest report age seen at polls over the last 24 hours (hourly buckets, reset on reload, underestimates by up to one poll interval). input_quality and weather_comparison change every poll, so the Recorder stored a new attribute row every five minutes. Mark them unrecorded; they remain visible on the Status entity. Model coefficients and other attributes are still recorded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c0e4de832b
commit
4daba5028b
6 files changed
+64
-3
No files matched your search
@@ -31,6 +31,18 @@ class FreshnessTests(unittest.TestCase):
|
||||
with self.assertRaises(ValueError):
|
||||
quality.freshness(now, now, limit)
|
||||
|
||||
def test_report_age_history_keeps_24_hour_maximum(self):
|
||||
history = quality.ReportAgeHistory()
|
||||
start = datetime(2026, 10, 26, tzinfo=timezone.utc)
|
||||
self.assertEqual(history.observe('sensor.a', start, 2400), 2400)
|
||||
self.assertEqual(history.observe('sensor.b', start, 60), 60)
|
||||
for minutes in range(5, 24 * 60, 5):
|
||||
result = history.observe('sensor.a', start + timedelta(minutes=minutes), 300)
|
||||
self.assertEqual(result, 2400) # still inside the 24-hour window
|
||||
later = start + timedelta(hours=24, minutes=5)
|
||||
self.assertEqual(history.observe('sensor.a', later, 300), 300)
|
||||
self.assertEqual(history.observe('sensor.b', later, 30), 30)
|
||||
|
||||
def test_freshness_settings_translated(self):
|
||||
for name in ('strings.json', 'translations/en.json', 'translations/ro.json'):
|
||||
data = json.loads((ROOT / name).read_text())
|
||||
|
||||
Reference in new issue
Block a user