Skip to content

Disable device availability checker during diagnostics regeneration#682

Draft
TheJulianJES wants to merge 1 commit intozigpy:devfrom
TheJulianJES:tjj/disable_polling_diagnostics_regen
Draft

Disable device availability checker during diagnostics regeneration#682
TheJulianJES wants to merge 1 commit intozigpy:devfrom
TheJulianJES:tjj/disable_polling_diagnostics_regen

Conversation

@TheJulianJES
Copy link
Contributor

Proposed change

This disable device availability checker during diagnostics regeneration.
At the moment, there's a rare issue where you can manage to regenerate diagnostics with available being set to false everywhere, as the checker starts after 30 to 45 seconds of running diagnostics regeneration.

It's possible that the implementation can be cleaned up. Just wanted to put it into a PR for now.

@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.51%. Comparing base (229df22) to head (96248f9).
⚠️ Report is 1 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev     #682   +/-   ##
=======================================
  Coverage   97.51%   97.51%           
=======================================
  Files          62       62           
  Lines       10949    10949           
=======================================
  Hits        10677    10677           
  Misses        272      272           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

# asynchronously mutate device availability while fixtures are being written.
zha_gateway.global_updater.stop()
zha_gateway._device_availability_checker.stop() # noqa: SLF001
zha_gateway.config.allow_polling = False
Copy link
Contributor Author

@TheJulianJES TheJulianJES Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zha_gateway.config.allow_polling will be set to True by fetch_updated_state:

self.config.allow_polling = True

With #654, we make sure to run that before regenerating diagnostics but that also means it'll re-enable allow_polling still. So that's why we also stop the global_updater and _device_availability_checker to fix the issue.

Maybe we should just patch out fetch_updated_state entirely for diagnostics. EDIT: Eh, also not possible in a nice way.

Copy link
Contributor Author

@TheJulianJES TheJulianJES Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we'd set allow_polling = False after this line, it should work without needing to stop the global_updater and _device_availability_checker:

await zha_gateway.async_block_till_done(wait_background_tasks=True)

Hmm...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant