feat: v2 event_count for Light/Door/Move/Reed; unified naming

This commit is contained in:
2026-07-03 18:17:48 +02:00
parent d432d9607e
commit 035d4fed26
3 changed files with 7 additions and 13 deletions
Binary file not shown.
+5 -9
View File
@@ -98,18 +98,14 @@ def _decode_v2(b0: int, b1: int, b2: int, b3: int) -> dict:
result["temperature_c"] = round((temp_raw - 200) / 8, 2) result["temperature_c"] = round((temp_raw - 200) / 8, 2)
result["reed_switch"] = bool((b2 >> 6) & 0x01) result["reed_switch"] = bool((b2 >> 6) & 0x01)
# Byte 3 depends on mode # Byte 3 depends on mode (per v2 spec)
if mode == 0: # Button — software version if mode == 0: # Button — software version (fw major.minor)
result["fw_major"] = (b3 >> 4) & 0x0F result["fw_major"] = (b3 >> 4) & 0x0F
result["fw_minor"] = b3 & 0x0F result["fw_minor"] = b3 & 0x0F
elif mode == 1: # Temperature — humidity elif mode == 1: # Temperature — humidity percentage
result["humidity_pct"] = round(b3 * 0.5, 1) result["humidity_pct"] = round(b3 * 0.5, 1)
elif mode == 4: # Move — event count / status else: # Light, Door, Move, Reed Switch — number of alerts / events
result["move_events"] = b3 result["event_count"] = b3
elif mode == 5: # Reed Switch — event count
result["reed_events"] = b3
else:
result["byte3_raw"] = b3
return result return result
+2 -4
View File
@@ -125,8 +125,6 @@ function summaryLine(d) {
if ('vibration_status' in d) p.push(`vibration: ${d.vibration_status}`); if ('vibration_status' in d) p.push(`vibration: ${d.vibration_status}`);
if ('magnet_status' in d) p.push(`magnet: ${d.magnet_status}`); if ('magnet_status' in d) p.push(`magnet: ${d.magnet_status}`);
if ('event_count' in d && d.mode_id > 2) p.push(`${d.event_count} events`); if ('event_count' in d && d.mode_id > 2) p.push(`${d.event_count} events`);
if ('move_events' in d) p.push(`${d.move_events} moves`);
if ('reed_events' in d) p.push(`${d.reed_events} reed events`);
if ('fw_major' in d) p.push(`fw ${d.fw_major}.${d.fw_minor}`); if ('fw_major' in d) p.push(`fw ${d.fw_major}.${d.fw_minor}`);
if (p.length === 0) p.push('heartbeat'); if (p.length === 0) p.push('heartbeat');
return p.join(' · '); return p.join(' · ');
@@ -220,7 +218,7 @@ const chartPresets = {
Move: { Move: {
subtitle: 'Cumulative movement events', subtitle: 'Cumulative movement events',
datasets: (msgs) => [ datasets: (msgs) => [
makeDs('Move events', msgs.map(m => m.decoded?.move_events ?? null), '#e11d48', 'y'), makeDs('Event count', msgs.map(m => m.decoded?.event_count ?? null), '#e11d48', 'y'),
], ],
}, },
Magnet: { Magnet: {
@@ -232,7 +230,7 @@ const chartPresets = {
'Reed Switch': { 'Reed Switch': {
subtitle: 'Cumulative reed switch events', subtitle: 'Cumulative reed switch events',
datasets: (msgs) => [ datasets: (msgs) => [
makeDs('Reed events', msgs.map(m => m.decoded?.reed_events ?? null), '#7c3aed', 'y'), makeDs('Event count', msgs.map(m => m.decoded?.event_count ?? null), '#7c3aed', 'y'),
], ],
}, },
}; };