feat: v2 event_count for Light/Door/Move/Reed; unified naming
This commit is contained in:
Binary file not shown.
@@ -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["reed_switch"] = bool((b2 >> 6) & 0x01)
|
||||
|
||||
# Byte 3 depends on mode
|
||||
if mode == 0: # Button — software version
|
||||
# Byte 3 depends on mode (per v2 spec)
|
||||
if mode == 0: # Button — software version (fw major.minor)
|
||||
result["fw_major"] = (b3 >> 4) & 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)
|
||||
elif mode == 4: # Move — event count / status
|
||||
result["move_events"] = b3
|
||||
elif mode == 5: # Reed Switch — event count
|
||||
result["reed_events"] = b3
|
||||
else:
|
||||
result["byte3_raw"] = b3
|
||||
else: # Light, Door, Move, Reed Switch — number of alerts / events
|
||||
result["event_count"] = b3
|
||||
return result
|
||||
|
||||
|
||||
|
||||
@@ -125,8 +125,6 @@ function summaryLine(d) {
|
||||
if ('vibration_status' in d) p.push(`vibration: ${d.vibration_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 ('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 (p.length === 0) p.push('heartbeat');
|
||||
return p.join(' · ');
|
||||
@@ -220,7 +218,7 @@ const chartPresets = {
|
||||
Move: {
|
||||
subtitle: 'Cumulative movement events',
|
||||
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: {
|
||||
@@ -232,7 +230,7 @@ const chartPresets = {
|
||||
'Reed Switch': {
|
||||
subtitle: 'Cumulative reed switch events',
|
||||
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'),
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user