zigpy / zha

Zigbee Home Automation
Apache License 2.0
10 stars 4 forks source link

Remove sending HS color commands to lights #39

Open TheJulianJES opened 3 months ago

TheJulianJES commented 3 months ago

(Somewhat unfinished for now, see bottom. Already "works" if two lines are deleted from HA.)

Proposed change

This removes sending "move to hue/saturation" commands to lights supporting HS when the "always prefer xy mode" option is disabled. By default, it is already disabled.

The config option is now also removed and ZHA only sends XY color commands to color lights. There are no benefits to addressing the light with HS color calls, only downsides:

Do note that HA will convert HS args given to light.turn_on to XY colors, as we set "supported color modes" correctly. So, the functionality of being able to set the color of lights via HS colors doesn't break. They just get converted to XY first.

Further considerations

The unfinished test test_zha_group_light_entity is still unfinished and the HS attribute cache initialization probably doesn't make much sense to test now.

This also requires removing the CONF_ALWAYS_PREFER_XY_COLOR_MODE option from the ZHA websocket API in HA. I've not checked how HA deals with the fact if somebody has set CONF_ALWAYS_PREFER_XY_COLOR_MODE to False in their config. If it breaks, we should fix that.. and remove the option from the config.

For the few people that (accidentally) disabled the "Always prefer XY color mode" option in ZHA, the state might be shown incorrect in HA until the light is initialized/polled. This should happen shortly after HA startup. Even if the light is in "HS color mode" then, polling will revert the light color mode attribute to XY as expected and use the correct XY values.

more...?

Hence it's a only a draft PR for now.

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 94.18%. Comparing base (8fc3aba) to head (82332f2). Report is 2 commits behind head on dev.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## dev #39 +/- ## ========================================== + Coverage 93.90% 94.18% +0.27% ========================================== Files 61 61 Lines 9516 9453 -63 ========================================== - Hits 8936 8903 -33 + Misses 580 550 -30 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.