-
-
Notifications
You must be signed in to change notification settings - Fork 35.7k
Debounce updates in Idasen Desk #153503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debounce updates in Idasen Desk #153503
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements debouncing for the Idasen Desk integration to reduce the frequency of state updates when the desk is moving. The desk sends frequent updates during movement, which can overwhelm Home Assistant with unnecessary state changes.
Key changes:
- Added a debouncer with 0.2-second delay to coordinator updates
- Updated test files to accommodate the new debouncing behavior
- Introduced proper time-based testing using freezegun
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
homeassistant/components/idasen_desk/coordinator.py |
Added debouncing logic with 0.2s cooldown to handle desk updates more efficiently |
tests/components/idasen_desk/__init__.py |
Added UPDATE_DEBOUNCE_TIME constant for consistent test timing |
tests/components/idasen_desk/test_sensor.py |
Updated tests to handle debounced updates with proper time manipulation |
tests/components/idasen_desk/test_cover.py |
Updated tests to handle debounced updates with proper time manipulation |
|
The Data Update Coordinator also implements a debouncer. That's set to 10 seconds. |
| logger=_LOGGER, | ||
| cooldown=UPDATE_DEBOUNCE_TIME, | ||
| immediate=True, | ||
| function=async_update_data, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am only wondering if a lambda would be more readable here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree in a way, but let's move forward to get this into the patch 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It needs to have the @callback decorator so it runs in the event loop. Otherwise:
Detected that integration 'idasen_desk' calls async_write_ha_state from a thread other than the event loop, which may cause Home Assistant to crash or data to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @abmantis 👍
../Frenck
The Coordinator's Debouncer works only for polling use cases, not when using |
Proposed change
The desk sends a lot of updates when moving. This adds a debounce to reduce the number of state updates.
Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: