fix(climate): keep optimistic state until DKN cloud catches up
The DKN cloud REST endpoint lags behind the unit for several seconds after a write, even though the unit itself and the DKN app reflect the change immediately. The previous 2.5s optimistic-overlay TTL expired well before the cloud caught up, so the next coordinator publish (REST poll or socket device-data push) carried stale values and the HA UI reverted to the previous setting. Extend the overlay TTL to 30s as a safety bound, and track the underlying device key + expected device value alongside each overlay. On every coordinator publish, clear overlays whose device key now reports the expected value (cloud has confirmed). The TTL still caps how long a silently-failed write can hold a wrong value. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -39,9 +39,11 @@ DEFAULT_SCAN_INTERVAL = 60 # seconds
|
||||
MIN_SCAN_INTERVAL = 30
|
||||
MAX_SCAN_INTERVAL = 300
|
||||
|
||||
# Optimistic overlay: how long to hold a locally-set value before trusting
|
||||
# the next coordinator refresh. Must exceed the write→cloud→poll round-trip.
|
||||
OPTIMISTIC_TTL_SEC: float = 2.5
|
||||
# Optimistic overlay: safety bound for cloud-propagation lag. Overlays
|
||||
# normally clear earlier via reconciliation once the device echoes the
|
||||
# requested value; this TTL guarantees the UI cannot get stuck on a
|
||||
# locally-set value indefinitely if the write was silently rejected.
|
||||
OPTIMISTIC_TTL_SEC: float = 30.0
|
||||
|
||||
# Post-write coordinator refresh: coalesced delay after a device command.
|
||||
POST_WRITE_REFRESH_DELAY_SEC: float = 1.0
|
||||
|
||||
Reference in New Issue
Block a user