Conversation
The Opener's ring is an event, not a status: Nuki reports `state.ringactionState = true` again for every ring while `state.ringactionTimestamp` advances each time. `Library._setValue()` deduplicates writes against its internal `_STATES` cache, so the repeated `true` is swallowed and `state.ringState` is never written again. Consumers subscribing to that state therefore miss every ring after the first one -- e.g. a parcel service ringing shortly after the postman produces no second notification. The cache can also drift from the actual state: anything that writes `ringState` from outside the adapter (a script resetting it to false, a VIS widget, a manual change) leaves the adapter believing the value is still `true`, which suppresses subsequent writes until the adapter is restarted. Fix: whenever a newer `ringactionTimestamp` arrives in `updateDevice()`, invalidate the cached `ringState` entry so the event is written through. This is scoped to an actual new ring, so it cannot cause repeated writes on regular polling cycles. Adds `Library.invalidateDeviceState()` for that purpose. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Problem
The Opener's ring is an event, not a status. Nuki reports
state.ringactionState = trueagain for every ring, whilestate.ringactionTimestampadvances each time.Library._setValue()deduplicates writes against its internal_STATEScache:https://github.com/iobroker-community-adapters/ioBroker.nuki-extended/blob/master/lib/library.js#L597-L612
Because the value is
trueboth times, the second ring is swallowed andstate.ringStateis never written again. Anything subscribing to that state misses every ring after the first.There is a second, related effect: the cache can drift from the actual state. If
ringStateis written from outside the adapter — a script resetting it tofalse, a VIS widget, a manual change — the adapter still believes the value istrueand suppresses all further writes until it is restarted.How to reproduce
<instance>.openers.<opener>.state.ringState.true, the subscription fires.Real-world symptom: the postman rings and the announcement plays; the parcel service rings minutes later and nothing happens. It works again after an adapter restart (cache reset) or if Nuki happens to report
falsein between, which is why it looks intermittent.state.ringStateUpdate(the timestamp) is unaffected and can be used as a workaround, butringStateis the obvious state to subscribe to and currently misleads consumers.Fix
Whenever a newer
ringactionTimestamparrives inNukiTools.updateDevice(), invalidate the cachedringStateentry so the event is written through. This is deliberately scoped to an actual new ring, so it cannot cause repeated writes on regular polling cycles, and it leaves every other state untouched.Adds a small
Library.invalidateDeviceState()helper for that purpose, mirroring the existingresetStates().Notes
🤖 Generated with Claude Code