Group "assume member state": colour-temperature commands never update members' colour mode
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- python
- Domain
- embedded-iot
Research direction
The bug is in _make_members_assume_group_state() in zha/application/platforms/light/init.py, around lines 1582-1594, where the colour-temperature and xy-colour blocks both assign assumed_color_mode. Read the guard that consumes it near lines 1643-1644 to see why colour-temperature commands never switch member mode. Done means a colour-temperature group command sets members' colour mode, while xy commands behave as before; the payload names no test file, so verify the change by tracing that path.
Written by the indexing model from the issue text.
Description
In _make_members_assume_group_state(), the colour-temperature and xy-colour blocks both write assumed_color_mode, and the second unconditionally overwrites the first:
https://github.com/zigpy/zha/blob/dev/zha/application/platforms/light/__init__.py#L1582-L1594
if color_temp is not None:
assumed_color_mode = self._color_mode
assumed_color_temp = self._color_temp
else:
assumed_color_mode = None
assumed_color_temp = None
if xy_color is not None:
assumed_color_mode = self._color_mode
assumed_xy_color = self._xy_color
else:
assumed_color_mode = None
assumed_xy_color = None
A colour-temperature command has xy_color is None, so the second else resets assumed_color_mode to None after the first block has just set it.
That value is consumed further down:
https://github.com/zigpy/zha/blob/dev/zha/application/platforms/light/__init__.py#L1643-L1644
if assumed_color_mode is not None and assumed_color_mode in supported_modes:
platform_entity._color_mode = assumed_color_mode
so the guard fails and members never have their colour mode switched. assumed_color_temp survives and is applied by its own separate guard, so the member ends up with an updated colour temperature while still reporting whatever colour mode it had before.
This only affects the "assume member group state" path, and only for colour-temperature commands — an xy command sets the mode last and is unaffected.
Suggested fix
Only reset assumed_color_mode when neither branch has set it, for example by computing it once from whether either color_temp or xy_color was supplied, rather than assigning it in both blocks.
Found while reading this function for an unrelated reason; not reproduced against hardware.
- Dominant language
- Python
- Stars
- 96
- Forks
- 84
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 30
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from zigpy/zha
-
Device override creates the generic entity instead of the vendor-specific one (Light instead of HueLight, ForceOnLight, MinTransitionLight)Possibly taken @zigpy-review-bot claimed this today. Openbot: code audit
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Each time a device becomes available again, ZHA adds another firmware update listener that is never releasedPossibly taken @zigpy-review-bot claimed this 1 day ago. Openbot: code audit
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
Devices that left the network are re-initialized on every availability check, reading attributes from a device that is gonePossibly taken @zigpy-review-bot claimed this 1 day ago. Openbot: code audit
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
device specific quirks
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
entities
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
pimutils/vdirsyncer#1242 ·
-
priority:P2
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
QuantConnect/lean-cli#792 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
open-webui/open-webui#35360 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Suggest link: Destiny Verify (MIT zero-dependency pre-commit security, citation & link hygiene CLI)Open
Difficulty 1/5 Under an hour Newbie friendliness 68/100