Refactor zone group refresh to sequential execution#30
Conversation
Refactor zone refresh logic for sequential processing and extend group assertion.
| await asyncio.gather( | ||
| *[self._refresh_zone_group(i, notify) for i in range(0, zones, 4)] | ||
| ) | ||
| # Sequential refresh of groups (0, 4, 8, 12) |
There was a problem hiding this comment.
Hi, I don't think you need to get rid of the gather here. Can do all these symultaniously that way. Just need to get the next group as part of the gather.
| # We allow 12 here because for 13 zones, the loop (0, 13, 4) produces 0, 4, 8, 12 | ||
| assert group in [0, 4, 8, 12] | ||
|
|
||
| if group == 12: |
There was a problem hiding this comment.
Maybe >= ? I wonder where 14+ would go. I don't think we have any examples anyhow.
|
|
||
| if group == 12: | ||
| # Fetches the pair 13 & 14, even if you only have 13 | ||
| zone_data_part = await self._get_resource("Zones13_14") |
There was a problem hiding this comment.
f"Zones{group+1}_{group+2}" ?? Hard to know.
Might be better just to do this and deal with any failures if/when they come up.
|
Thanks for the review, I'll have a play over the weekend and get back to you with my findings. |
Hi Penny, I have update the code based on you're review and it's working well. I also tested added a 14th zone to check that it would detect this and it did. I also checked the logs and there were no errors. I'm hope I'm doing the correct thing by commit directly to the ScottyB007-patch-1 branch
|
Hi Again, Please let me know if I've done the right thing with updating the code, testing and then committing it directly to the existing branch. If I've done the wrong thing please let me know what I need to do. Thanks again, Scott |
Refactor zone refresh logic for sequential processing and extend group assertion for users with more then 12 Zones.
This code fixes the following issue:
The iZone integration successfully discovers the iZone hub but fails to initialize any entities (Controler and Zones). The logs show an AssertionError in the underlying pizone library, specifically when fetching zone groups. It appears the code is hard-coded to only allow 12 zones (groups 0, 4, and 8), but with a CEXT (6 Zone Extender) iZone can support up to 14 zones).
Logs:
2026-01-10 23:37:38.855 DEBUG (MainThread) [pizone.discovery] Datagram Recieved b'ASPort_12107,Mac_000096081,IP_192.168.0.20,iZoneV2,iLight,iDrate,iPower,Split,VRF'
2026-01-10 23:37:38.858 INFO (MainThread) [homeassistant.components.climate] Setting up izone.climate
2026-01-10 23:37:38.869 ERROR (MainThread) [pizone.discovery] Uncaught exception
Traceback (most recent call last):
File "/usr/local/lib/python3.13/site-packages/pizone/discovery.py", line 408, in initialize_controller
await controller._initialize()
File "/usr/local/lib/python3.13/site-packages/pizone/controller.py", line 113, in _initialize
await self._refresh_zones(notify=False)
File "/usr/local/lib/python3.13/site-packages/pizone/controller.py", line 395, in _refresh_zones
await asyncio.gather(
*[self._refresh_zone_group(i, notify) for i in range(0, zones, 4)]
)
File "/usr/local/lib/python3.13/site-packages/pizone/controller.py", line 400, in _refresh_zone_group
assert group in [0, 4, 8]
^^^^^^^^^^^^^^^^^^
AssertionError