fix(integration): stop replaying stale sound events#65
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe coordinator now tracks each LAN DPS update separately from merged state. ChangesLAN sound-event tracking
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Warning |
Device
Tested with two Philips Avent Connected SCD923/26 baby monitors connected through the Philips Avent Home Assistant integration with working Tuya LAN push.
Bug
DPS 141(decibel_upload) is an event payload, but the coordinator merges it into persistentself.data. Once a real sound event has occurred, that value can remain in the merged state indefinitely.AventSoundDetectedcurrently reads the merged state on every coordinator update. Consequently, an old sound event is treated as new when:DPS 207;Each replay restarts the 30-second clear timer, producing regular
Detected -> Clearentries even in a quiet room.Debug logging confirmed the distinction:
DPS 141LAN payload;LAN push ... {'141': 'decibel_upload'}event;Solution
Keep the latest raw LAN payload and a monotonically increasing LAN-update sequence alongside the existing merged coordinator data. Each sound binary sensor remembers the last sequence it processed and only treats
DPS 141as a new event when it appears in a fresh, unprocessed LAN payload.The merged coordinator data remains unchanged for normal state entities. Equal sound payloads received separately from the camera still count as distinct real events.
This intentionally makes sound-event triggering depend on LAN push. If LAN connectivity is unavailable, the integration no longer replays ambiguous sticky cloud state as sound events.
No configuration changes are required.
Tests
Added regression coverage to the existing LAN tests for:
DPS 141state;decibel_uploadpayloads as distinct events.Validated locally with:
Summary by CodeRabbit