-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Fix ESPHome entities unavailable if deep sleep enabled after entry setup #144970
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
Fix ESPHome entities unavailable if deep sleep enabled after entry setup #144970
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.
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Hey there @OttoWinter, @jesserockz, @kbx81, @bdraco, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
apologies, accidentally submitted while filling in and formatting the PR message, give me a bit to complete it. |
ESPHome
We should update the cached version when it changes instead so the entity isn't re-reading it every time. |
This change will also need test coverage |
How would you suggest the testing be implemented? |
I made a tweak to only update it when it changes. Please check that it still solves the issue. For a test we already have some that mock_disconnect, change device_info, and reconnect. We can copy one of those and adjust it for this case |
I was looking at the callback stuff right now, it's a bit complex to track down what it does, but if it indeed does what I think it might, that change looks good – I'll do some testing. |
Are PRs squash-merged, or should I clean up the git history? (when that time comes) |
everything is squashed at the end. ok to be a bit messy if you want |
The updated changes also fix the issue 👍 The new tests are also working, undoing the fix and it catches the problem. |
Co-authored-by: Shay Levy <levyshay1@gmail.com> Co-authored-by: Allen Porter <allen.porter@gmail.com> Co-authored-by: Franck Nijhof <git@frenck.dev> Co-authored-by: Martin Hjelmare <marhje52@gmail.com> Co-authored-by: TimL <tl@smlight.tech> Co-authored-by: Seweryn Zeman <seweryn.zeman@jazzy.pro> Co-authored-by: hahn-th <15319212+hahn-th@users.noreply.github.com> Co-authored-by: Luke Lashley <conway220@gmail.com> Co-authored-by: starkillerOG <starkiller.og@gmail.com> Co-authored-by: J. Nick Koston <nick@koston.org> Co-authored-by: Arie Catsman <120491684+catsmanac@users.noreply.github.com> Co-authored-by: Josef Zweck <josef@zweck.dev> Co-authored-by: Simon Lamon <32477463+silamon@users.noreply.github.com> Co-authored-by: Ruben van Dijk <15885455+RubenNL@users.noreply.github.com> Co-authored-by: G Johansson <goran.johansson@shiftit.se> Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> Co-authored-by: Thomas55555 <59625598+Thomas55555@users.noreply.github.com> Co-authored-by: Øyvind Matheson Wergeland <oyvind@wergeland.org> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com> Co-authored-by: Brett Adams <Bre77@users.noreply.github.com> Co-authored-by: rjblake <richard.blake@gmail.com> Co-authored-by: Daniel Hjelseth Høyer <github@dahoiv.net> Co-authored-by: Matthias Alphart <farmio@alphart.net> Co-authored-by: Erik Montnemery <erik@montnemery.com> Co-authored-by: Robert Resch <robert@resch.dev> Co-authored-by: Odd Stråbø <oddstr13@openshell.no> Co-authored-by: puddly <32534428+puddly@users.noreply.github.com> Co-authored-by: Bram Kragten <mail@bramkragten.nl> fix privacy mode availability for NVR IPC cams (#144569) fix enphase_envoy diagnostics home endpoint name (#144634) Close Octoprint aiohttp session on unload (#144670) Fix strings typo for Comelit (#144672) Fix wrong state in Husqvarna Automower (#144684) Fix Netgear handeling of missing MAC in device registry (#144722) Fix blocking call in azure storage (#144803) Fix Z-Wave unique id after controller reset (#144813) Fix blocking call in azure_storage config flow (#144818) Fix wall connector states in Teslemetry (#144855) Fix Reolink setup when ONVIF push is unsupported (#144869) Fix some Home Connect translation strings (#144905) Fix unknown Pure AQI in Sensibo (#144924) Fix Home Assistant Yellow config entry data (#144948) Fix ESPHome entities unavailable if deep sleep enabled after entry setup (#144970) fix from ZHA event `unique_id` (#145006) Fix climate idle state for Comelit (#145059) Fix fan AC mode in SmartThings AC (#145064) Fix Ecovacs mower area sensors (#145071)
Proposed change
This change removes the entity-local caching of the
device_info
object.This object is never updated with new metadata, but is replaced when the device connects, causing the cached object to become stale.
This is likely most often noticed as the device entities going unavailable when the device enters deep sleep, even if it disconnected properly.
To reproduce the issue;
The reason for why this happens is that, even if the
has_deep_sleep
flag is properly picked up by HA, the entity objects are still holding on to an old copy of the device_info object, which still has thehas_deep_sleep
flag set toFalse
.The following actions will seemingly fix the issue (but only until the conditions are triggered again);
This can make it seem like updates have fixed the issue, but then reappear at a later time.
Type of change
Additional information
The debugging conversation can be found in this Discord thread on the ESPHome server.
Issue introduced with #94930
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: