mirror of
https://github.com/adamzend/Uploading-server-data-meteo-to-Lemmy-instance.git
synced 2026-10-30 19:02:00 +01:00
Add configurable source heartbeat verification and bounded Modbus recovery
This commit is contained in:
1 parent
0c8b6e50a5
commit
dc244394ee
9 files changed
+218
-4
No files matched your search
@@ -120,6 +120,8 @@ def render_section(status, images, now=None, config=None):
|
||||
checked = datetime.fromisoformat(status['checked_at'])
|
||||
age = (now - checked).total_seconds()
|
||||
healthy = status['status'] == 'ok' and 0 <= age <= config['stale_after_minutes'] * 60
|
||||
if config.get('heartbeat', {}).get('enabled', False):
|
||||
healthy = healthy and status.get('freshness_verified') is True
|
||||
values = status.get('values') if healthy else status.get('last_success_values')
|
||||
def value(name, unit):
|
||||
return ('—' if not values else f"{values[name]:.1f}".replace('.', ',') + ' ' + unit)
|
||||
@@ -134,6 +136,10 @@ def render_section(status, images, now=None, config=None):
|
||||
lines.append('**Ostatni poprawny pomiar:** ' + shown)
|
||||
if not healthy and values:
|
||||
lines.append('\nPodane wartości pochodzą z ostatniego poprawnego pomiaru.')
|
||||
if not healthy:
|
||||
lines.append('\nBrak aktualnego, poprawnego odczytu lub potwierdzenia świeżości danych stacji.')
|
||||
elif not config.get('heartbeat', {}).get('enabled', False):
|
||||
lines.append('\nKontrola heartbeatu źródła jest wyłączona; status dotyczy odczytu Modbus.')
|
||||
lines.append('\n' + config['lemmy']['update_note'])
|
||||
for slug, title in CHARTS:
|
||||
lines.extend(['', f'### {title}', '', f""])
|
||||
|
||||
Reference in new issue
Block a user