Repository navigation
fix: refresh on input changes without an executor job per state change (#158 + test fix) - #160
Merged
Merged
Conversation
The input listeners were plain functions, so Home Assistant ran each of the 11 as an executor job for every state_changed event in the system, and called hass.async_create_task from a worker thread. At shutdown the executor is gone and every state change logs 11 "Executor shutdown has been called" errors. They also never matched: they compared against number.<entry_id>_<key>, but entity_ids follow the device name, so a parameter change reached the controller only on the next interval tick. Use one callback listener with a callback event filter that matches the entry's input entities by unique_id, as PIDDeviceHandle already does. An entity being added, removed or passing through unavailable/unknown is not treated as a change.
Home Assistant 2026.10 replaced voluptuous with probatio and now types async_show_form's data_schema as probatio.Schema, so the lint job's mypy step fails on dev (scheduled run of 2026-10-05) and on every pull request. voluptuous is also no longer a Home Assistant dependency. Import probatio as vol from 2026.10 on and voluptuous before that. The choice goes by version, not by whether probatio imports: 2026.9 already installs probatio but still expects voluptuous schemas. The pre-commit mypy hook types against the latest stable release (2026.9) and the lint job against the one pytest-homeassistant-custom-component pins (2026.10), so the two config flow schemas are annotated Any. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012VjGcBURcFQJMzcFaFvciV
Both entities went from no state or unknown to a value, which the event filter rejects before it looks at the unique_id. The test therefore kept passing with the unique_id check replaced by 'return True'. Give them a value first, so the change under test is a real one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012VjGcBURcFQJMzcFaFvciV
…ude/pr158-test-fix Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012VjGcBURcFQJMzcFaFvciV
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.
Carries bvweerd/simple_pid_controller#158 by @alaraun unchanged (commit 357c020), plus one test fix. Merging this with a merge commit also marks #158 as merged.
What #158 does
The 11 input listeners in
sensor.pywere plain functions. Home Assistant ran each one as an executor job for everystate_changedevent in the system. They also never matched, because entity_ids follow the device name and not<entry_id>_<key>. #158 replaces them with one@callbacklistener and a@callbackevent filter that matches the entry's inputs by registryunique_id. The PR description of #158 has the details.Test fix (005127b)
test_unrelated_state_change_does_not_refreshnever reached theunique_idcheck. Both entities went from no state orunknownto a value, and the filter rejects that before it looks at theunique_id. Replacing the wholeunique_idcheck withreturn Trueleft all tests green. The test now gives both entities a real value first. With that change, the same mutation makes the test fail, and it passes without it.Behaviour change to be aware of
Before #158 the listeners never fired, so the controller only computed on its interval. Now a change to Kp, Ki, Kd, the setpoint, the output limits, the sample time, a switch or the start mode triggers a PID update straight away. The coordinator's debouncer allows at most one such update per 10 s. Each one adds an entry to the histories, shows a short "Actual Sample Time", and restarts the interval timer.
Also contains
bvweerd/simple_pid_controller#159 is merged in, so that lint is green here too. Once #159 is on
devthat part drops out of this diff.Validation
pytest: all pass on Python 3.14 / Home Assistant 2026.10.0b0 and on Python 3.13 / Home Assistant 2026.2.3mypyandpre-commit run --all-files: clean🤖 Generated with Claude Code
https://claude.ai/code/session_012VjGcBURcFQJMzcFaFvciV
Generated by Claude Code