🔄 Enhanced Fix: v0.3.4 - Guaranteed Switch State Sync
Since optimistic updates alone didn't work, added scheduled polling to ensure UI syncs!
🛠️ What Changed
Multi-Layer Approach
When you toggle a switch, we now do 4 things to ensure the UI updates:
- Instant (0s): Optimistic UI update → Immediate feedback ⚡
- Immediate (0s): Trigger coordinator refresh → Try to sync now
- Delayed (5s): Scheduled refresh → Device has time to process 🕐
- Confirmation (15s): Final refresh → Catch slow responses ✅
Why This Works
- Optimistic update: Instant visual feedback (even if it doesn't always trigger)
- 5 second refresh: Gives device time to actually change state
- 15 second refresh: Confirmation that state persisted
- Catches edge cases: Slow device responses, API delays, UI glitches
📊 Timeline Example
0s: You toggle AC Output ON
→ UI shows ON (optimistic)
→ Request refresh (immediate)
5s: → Scheduled refresh polls device
→ Device confirms: AC is ON
→ UI confirms: ON ✓
15s: → Final refresh (confirmation)
→ State: ON ✓
📦 Upgrade
This should definitely fix the UI sync issue!
- Update to v0.3.4 via HACS
- Reload integration
- Toggle switches → UI should update within 5 seconds max
Full Changelog: https://github.com/jsight/ha-pecron/blob/main/CHANGELOG.md
Try it out! The UI should sync reliably now. 🎯