Add MQTT features: routing, device control, discovery, notifications, sleep tracking - #3
Merged
Merged
Conversation
…diefan#33) - Connection registry routes MQTT commands to correct camera by baby UID - Manager registry tracks websocket connection managers per baby - Global MQTT handler registration (moved from per-connection to app-level) - Handler signatures now include babyUID for proper multi-camera routing - ForceReconnect() with cooldown skip for failed command recovery - Pending retry queue replays failed commands after reconnection - New env vars: NANIT_MQTT_RESET_WHEN_FAILED, NANIT_WEBSOCKET_TIMEOUT
- Extend protobuf schema with brightness (Settings), duration/soundtrack (Playback) - Add MQTT subscriptions for brightness, playback (start/stop), and volume commands - Route all commands through connection registry for multi-camera support - JSON payloads for brightness, playback, and volume topics
- Publish discovery configs on MQTT connect for each registered baby - Sensors: temperature, humidity, last motion/sound, stream URL - Binary sensors: night, stream active, camera online, crying, standing, left bed, alert zone, temp/humidity/breathing alerts, low battery, asleep, in bed - Switches: night light, standby mode - Gated behind NANIT_MQTT_DISCOVERY env var (default true when MQTT enabled)
- New notification package with event poller, deduplication, and publisher - Polls Nanit REST API for events with jitter and exponential backoff - Publishes events to MQTT: motion, sound, crying, standing, left bed, alert zone, temperature/humidity/breathing alerts, camera online/offline - New env vars: NANIT_NOTIFICATIONS_ENABLED, NANIT_NOTIFICATIONS_POLL_INTERVAL, NANIT_NOTIFICATIONS_MAX_BACKOFF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
All features gated behind env vars (
NANIT_MQTT_ENABLED,NANIT_NOTIFICATIONS_ENABLED). See README for full env var table.Test plan
go build ./cmd/nanit/)NANIT_MQTT_ENABLED=trueandNANIT_MQTT_BROKER_URLset