Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tools/regenerate_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ async def main(files: list[str] | None = None) -> None:
paths = [pathlib.Path(f) for f in files]

async with create_zha_gateway() as zha_gateway:
# Regeneration should be deterministic: disable background tasks that can
# 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
Copy Markdown
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
Copy Markdown
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...


for device_json in paths:
_LOGGER.info("Migrating %s", device_json)
zigpy_device = await zigpy_device_from_json(
Expand Down
Loading