Repository navigation
Conversation
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
Make the native-API profile wait for a Home Assistant state subscriber before its full acquisition, so a short wake does not measure and sleep before the first client can receive the readings.
The wait runs at boot priority 399, after sensor setup (600) and display setup (400), and is asynchronous: Wi-Fi setup at priority 250 proceeds while it is pending.
api_connection_timeoutbounds it (default 10 s). The condition isapi.connected: {state_subscription_only: true}, so a client that only requests logs does not release the wait. Acquisition then runs once, on subscription or on timeout.The wait is optional network time, so it is skipped under critical battery or a restored low-battery latch until a valid reading reaches the exit threshold. A missing reading keeps the bypass when the latch is set and the bounded wait otherwise. The MQTT profile and the shared core sequence do not change.
docs/api-wake-window.mddocuments the sequence.Evidence
After: 88 tests pass on current upstream V2R1 (79 existing + 9 new in
tests/test_api_boot.py). They execute the real package actions for early and late subscribers, a logs-only client, no Home Assistant (single acquisition after timeout), a disconnect during acquisition, critical battery, a restored latch with and without a valid exit reading, and an unavailable battery.esphome config docs/source/files/configuration.yamlandscripts/validate_public_examples.pypass with ESPHome 2026.9.0 (the same steps as CI), using synthetic secrets. The new condition is accepted by that release's schema.Merge Danger
Door: two-way. Revert this PR; it does not touch the core or the MQTT profile. A source revert does not deploy firmware.
Blast Radius: firmware, API profile only. Affects users who later adopt this package: wake time can grow by up to
api_connection_timeout(default 10 s) when no client subscribes, which costs battery on devices that wake with no Home Assistant reachable. The low-battery bypass limits that cost near depletion. No deployment is included.AI assistance: Claude Code rebased and validated this contribution on current V2R1. Upstream review is requested; local tests do not constitute maintainer approval.
🤖 Generated with Claude Code
https://claude.ai/code/session_017fn1KdJJTY7LedVqZ7SxcA