Merge pull request 'Release Rev 2.0' (#1) from develop into main
Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
@@ -362,16 +362,19 @@ def on_message(client, userdata, msg):
|
||||
notify_update() # <--- WEBSOCKET
|
||||
|
||||
# --- PUSH TRIGGER: NODE STATE ---
|
||||
if payload.upper() == 'OFFLINE':
|
||||
if last_notified_errors.get(f"{cid}_NODE") != 'OFFLINE':
|
||||
# L'agente invia "OFFLINE - <ID>" (anche come LWT) e "ONLINE - <profilo>": si confronta il PREFISSO.
|
||||
# I messaggi retained (già sul broker quando il server si avvia) non generano notifiche.
|
||||
state_up = payload.upper()
|
||||
if state_up.startswith('OFFLINE'):
|
||||
if not msg.retain and last_notified_errors.get(f"{cid}_NODE") != 'OFFLINE':
|
||||
broadcast_push_notification(f"💀 NODE OFFLINE: {cid.upper()}", "Connection lost with broker.", cid=cid)
|
||||
last_notified_errors[f"{cid}_NODE"] = 'OFFLINE'
|
||||
elif payload.upper() == 'ONLINE':
|
||||
elif state_up.startswith('ONLINE'):
|
||||
if last_notified_errors.get(f"{cid}_NODE") == 'OFFLINE':
|
||||
broadcast_push_notification(f"🌤️ NODE ONLINE: {cid.upper()}", "Node is back online.", cid=cid)
|
||||
del last_notified_errors[f"{cid}_NODE"]
|
||||
|
||||
if payload.upper() not in ['OFF', 'OFFLINE', '']:
|
||||
if not state_up.startswith('OFF') and state_up != '':
|
||||
tel = client_telemetry.get(cid, {})
|
||||
if isinstance(tel, dict) and '🔄' in str(tel.get('ts1', '')):
|
||||
client_telemetry[cid] = {"ts1": "Waiting...", "ts2": "Waiting...", "alt": ""}
|
||||
@@ -388,7 +391,8 @@ def on_message(client, userdata, msg):
|
||||
"disk": round(data.get("disk_usage_percent", 0), 1),
|
||||
"processes": data.get("processes", {}),
|
||||
"files": data.get("files", data.get("config_files", [])),
|
||||
"profiles": data.get("profiles", {"A": "PROFILE A", "B": "PROFILE B"})
|
||||
"profiles": data.get("profiles", {"A": "PROFILE A", "B": "PROFILE B"}),
|
||||
"interval": data.get("update_interval")
|
||||
}
|
||||
health_changed = device_health.get(cid) != new_health
|
||||
device_health[cid] = new_health
|
||||
@@ -442,7 +446,7 @@ def on_message(client, userdata, msg):
|
||||
logger.error(f"Error parsing DMRGateway for {cid}: {e}")
|
||||
|
||||
# --- MMDVMHOST INFO MANAGEMENT (FREQUENZE & LOCATION) ---
|
||||
elif len(parts) >= 4 and p0 == 'data' and p2 == 'mmdvm' and parts[3].lower() == 'info':
|
||||
elif len(parts) >= 4 and p0 == 'data' and p2 in ('mmdvm', 'mmdvmhost') and parts[3].lower() == 'info':
|
||||
try:
|
||||
cid = parts[1].lower()
|
||||
data = json.loads(payload)
|
||||
@@ -471,7 +475,7 @@ def on_message(client, userdata, msg):
|
||||
logger.error(f"Error parsing MMDVMHost info for {cid}: {e}")
|
||||
|
||||
# --- MMDVMHOST GENERAL MANAGEMENT (CALLSIGN & ID & DUPLEX) ---
|
||||
elif len(parts) >= 4 and p0 == 'data' and p2 == 'mmdvm' and parts[3].lower() == 'general':
|
||||
elif len(parts) >= 4 and p0 == 'data' and p2 in ('mmdvm', 'mmdvmhost') and parts[3].lower() == 'general':
|
||||
try:
|
||||
cid = parts[1].lower()
|
||||
data = json.loads(payload)
|
||||
|
||||
@@ -516,7 +516,10 @@
|
||||
}
|
||||
|
||||
// Agent: heartbeat periodico, se tace a lungo con nodo "online" qualcosa non va
|
||||
const warnA = isOnline && (ages.health === undefined ? upSec > 300 : ages.health > 180);
|
||||
// Soglia in base all'intervallo di telemetria dichiarato dall'agente (default 60 s): 3 intervalli, minimo 180 s
|
||||
const hObj = (data.health && data.health[c.id.toLowerCase()]) || {};
|
||||
const iv = Number(hObj.interval) > 0 ? Number(hObj.interval) : 60;
|
||||
const warnA = isOnline && (ages.health === undefined ? upSec > Math.max(300, iv * 5) : ages.health > Math.max(180, iv * 3));
|
||||
const tipA = warnA
|
||||
? (it ? 'L\'agent del nodo non invia più lo stato (devices/<id>/services): connessione bloccata?' : 'The node agent stopped sending its status (devices/<id>/services): stuck connection?')
|
||||
: (it ? 'Ultimo stato ricevuto dall\'agent del nodo (devices/<id>/services)' : 'Last status received from the node agent (devices/<id>/services)');
|
||||
|
||||
Reference in New Issue
Block a user