Repository navigation
Throttle attribute-only state writes to one per minute - #148
Conversation
Charging Power (nrg) gets new per-phase voltages pushed about once per second, also while idle at 0 W. Unrecorded attributes still bump last_updated, so the recorder wrote a states row every second: ~86,000 rows per day for this one entity, about half of all state rows on the install where it was measured. ChargerPlatformEntity._write_state() now sets the state and writes it, but skips the write when the state is unchanged and the last write was less than ATTR_ONLY_WRITE_INTERVAL (60 s, const.py) ago. State changes are still written immediately. async_local_push and async_local_poll use it instead of calling async_write_ha_state() directly. AGENTS.md records the rule and the reason. The test stub in tests/conftest.py gets the new constant. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Seeing the same here on v0.4.0 (HA 2026.10.4, HAOS on a Raspberry Pi 5, SQLite recorder). In 24 hours Is a 0.4.1 release planned soon? I'd rather wait for the release than patch the files by hand. I'll post the row count once I've updated. |
|
is there any plan to make it configurable? I updated yesterday to 0.4.1 and saw that "charging power" sensor and "max charging current" slider update very slow. Downgraded back to 0.3.9 and everything is back to normal. |
|
Row count as promised: on 0.4.1 (running since 2026-11-14), |
Problem
The charger pushes
nrgabout once per second, also while the car is not charging. While idle, Charging Power stays at0, but the per-phase voltages in its attributes change on every push.Since #140 the attributes are no longer stored. Every write still bumps
last_updated, though, and the recorder stores a newstatesrow for each one. Measured on one install (MariaDB recorder, 7 days):sensor.wattpilot_charging_powerper day0(idle)Change
ChargerPlatformEntity._write_state(state). It sets the state and callsasync_write_ha_state(), but skips the write when the state is unchanged and the last write was less thanATTR_ONLY_WRITE_INTERVAL(60 s, inconst.py) ago.async_local_pushandasync_local_pollcall it instead of writing directly._write_state(), with the reason.Expected effect for Charging Power: idle writes drop from ~78,000 to at most 1,440 per day.
Behavior change
While the state is unchanged, attributes shown in the UI can be up to 60 s old. Nothing else changes: no entity IDs, no configuration, no wallbox commands.
Tests
pytest tests/ -v --tb=short: 74 passed (Python 3.14), including two new tests inTestAttributeOnlyWriteThrottle.pytest tests_ha/ -v --tb=short: 4 passed.🤖 Generated with Claude Code