1.6 KiB
presence
Purpose
Tracks whether household members are home by ICMP-pinging their phones on the LAN at a fixed interval. Derives an overall household state (EMPTY, OCCUPIED, etc.) from per-member presence and publishes both to MQTT so the rule engine and arm-state FSM can react.
Key files
vigilar/presence/monitor.py—PresenceMonitor: ping loop, per-member state machine withdeparture_delay_mgrace period, publishes per-member and household-level topicsvigilar/presence/models.py—MemberPresencedataclass andderive_household_stateaggregatorvigilar/presence/__init__.py
MQTT topics
Subscribes: none Publishes:
vigilar/presence/{name}— per-member status (HOMEorAWAY, plus role)vigilar/presence/status— aggregated household state and a{name: HOME|AWAY}map
Database tables
none — presence state lives only in memory and on the bus.
Depends on
- LAN reachability of configured
[presence.members]IPs pingbinary on the host
Consumed by
events— rules and the arm-state FSM react to household state changesalerts— smart alert profile matcher invigilar/alerts/profiles.pybranches onHouseholdState
Notes
A member is marked HOME the moment a ping succeeds, but only marked AWAY after departure_delay_m minutes without a successful ping — this prevents a single dropped reply from flipping the household state. The monitor uses time.monotonic() for the grace window, so it is immune to wall-clock jumps. Per-member and household topics are republished every poll, not only on transitions, so late subscribers always get current state.