feat: Enhance Nanit integration with WebSocket resilience and improved controls - #33
Open
tanvach wants to merge 1 commit into
Open
feat: Enhance Nanit integration with WebSocket resilience and improved controls#33tanvach wants to merge 1 commit into
tanvach wants to merge 1 commit into
Conversation
…d controls This comprehensive update combines multiple enhancements to the Nanit Home Assistant integration: ## WebSocket Connection Reset Mechanism - Implements automatic WebSocket reconnection when commands fail to receive responses - Configurable timeout system to detect and recover from 'half-dead' connections - Automatic command retry after successful reconnection - Resolves MQTT switch unresponsiveness issues that required manual container restarts ## Enhanced Camera Controls - Added standby mode toggle support for compatible Nanit cameras - Improved light switch functionality with initial state support - Refactored MQTT light hooks for better reliability - Fixed crashes when MQTT is not enabled ## Configuration Options - NANIT_MQTT_RESET_WHEN_FAILED: Enable automatic WebSocket reset (default: false) - NANIT_WEBSOCKET_TIMEOUT: Command response timeout (default: 1s) - Backward compatible - features are opt-in ## Reliability Improvements - Enhanced WebSocket connection lifecycle management - Improved error handling and logging for debugging - Cooldown bypass for immediate reconnection on failures - Robust command tracking and retry mechanisms ## Documentation - Comprehensive setup and troubleshooting guide in docs/switches.md - Configuration examples and best practices - Detailed explanation of the reset mechanism This update ensures the Nanit integration remains stable and responsive over long periods while adding valuable new control capabilities.
TheNimaj
approved these changes
Dec 12, 2025
Author
|
Update: I’ve been running with these changes with two camera and a light switch for many months now without any issues. |
stuart22
added a commit
to stuart22/home_assistant_nanit
that referenced
this pull request
Apr 12, 2026
…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
stuart22
added a commit
to stuart22/home_assistant_nanit
that referenced
this pull request
Apr 12, 2026
…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
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.
This comprehensive update combines multiple enhancements to the Nanit Home Assistant integration:
WebSocket Connection Reset Mechanism
Enhanced Camera Controls
Configuration Options
Reliability Improvements
Documentation
This update ensures the Nanit integration remains stable and responsive over long periods while adding valuable new control capabilities.
Full transparency - this PR generation was created with assistance of AI (Claud 4 Sonnet). Please let me know if you have any questions or issues. I've tested on a set up with 2 cameras and it's been working fine for a week now.