full RGB support for users of tradfri GW#9411
Conversation
## 201709013: set_hex_color() seems not to work in pytradfri api - set_rgb_color() does ## -> changed function set_hex_color() to set_rgb_color() ## tested w. IKEA tradfri GW and zigbee rgb PWM module (dresden elektronik FLS-PP lp)
|
@spektren, thanks for your PR! By analyzing the history of the files in this pull request, we identified @ggravlingen, @matemaciek and @balloob to be potential reviewers. |
| ## 201709013: set_hex_color() seems not to work in pytradfri api - set_rgb_color() does | ||
| ## -> changed function set_hex_color() to set_rgb_color() | ||
| ## tested w. IKEA tradfri GW and zigbee rgb PWM module (dresden elektronik FLS-PP lp) | ||
| self._api(self._light.light_control.set_rgb_color(*kwargs[ATTR_RGB_COLOR])) |
There was a problem hiding this comment.
line too long (87 > 79 characters)
| #~ color_util.color_rgb_to_hex(*kwargs[ATTR_RGB_COLOR]))) | ||
| ## 201709013: set_hex_color() seems not to work in pytradfri api - set_rgb_color() does | ||
| ## -> changed function set_hex_color() to set_rgb_color() | ||
| ## tested w. IKEA tradfri GW and zigbee rgb PWM module (dresden elektronik FLS-PP lp) |
There was a problem hiding this comment.
too many leading '#' for block comment
line too long (97 > 79 characters)
trailing whitespace
| #~ self._api(self._light.light_control.set_hex_color( | ||
| #~ color_util.color_rgb_to_hex(*kwargs[ATTR_RGB_COLOR]))) | ||
| ## 201709013: set_hex_color() seems not to work in pytradfri api - set_rgb_color() does | ||
| ## -> changed function set_hex_color() to set_rgb_color() |
There was a problem hiding this comment.
too many leading '#' for block comment
| color_util.color_rgb_to_hex(*kwargs[ATTR_RGB_COLOR]))) | ||
| #~ self._api(self._light.light_control.set_hex_color( | ||
| #~ color_util.color_rgb_to_hex(*kwargs[ATTR_RGB_COLOR]))) | ||
| ## 201709013: set_hex_color() seems not to work in pytradfri api - set_rgb_color() does |
There was a problem hiding this comment.
too many leading '#' for block comment
line too long (99 > 79 characters)
trailing whitespace
| self._api(self._light.light_control.set_hex_color( | ||
| color_util.color_rgb_to_hex(*kwargs[ATTR_RGB_COLOR]))) | ||
| #~ self._api(self._light.light_control.set_hex_color( | ||
| #~ color_util.color_rgb_to_hex(*kwargs[ATTR_RGB_COLOR]))) |
There was a problem hiding this comment.
block comment should start with '# '
| if ATTR_RGB_COLOR in kwargs and self._light_data.hex_color is not None: | ||
| self._api(self._light.light_control.set_hex_color( | ||
| color_util.color_rgb_to_hex(*kwargs[ATTR_RGB_COLOR]))) | ||
| #~ self._api(self._light.light_control.set_hex_color( |
There was a problem hiding this comment.
block comment should start with '# '
Setup: Home Assistant 0.53.0 pytradfri 2.2 IKEA tradfri gateway fw 1.1.0015 zigbee rgb PWM module (dresden elektronik FLS-PP lp) Issue: pytradfri's set_hex_color() does not work for arbitrary colors with the current IKEA tradfri gateway. Only setting rgb hex values (param 5706) of some predefined colors has the desired effect. Others will fall back to one predefined value. I assume, the GW doesn't allow for values deviating from the predefined values. However, pytradfri's set_rgb_color() does also work for arbitrary colors. Latest pytradfri (2.2/PR51?) will convert rgb to xy and send xy thru the GW (param 5709 and 5710). -> changed the function used from set_hex_color() to set_rgb_color() in HA's component\light\tradfri Result: Full RGB support with arbitrary colors with my setup. Unfortunately I cannot test tradfri GW with other bulbs (no have hue/lightify bulbs). ___ Predefined colors from <home-assistant-libs/pytradfri#51>: this.f3891b = new HashMap(); this.f3891b.put("f5faf6", new C1386c(0.3804d, 0.3804d, "f5faf6", 0.54d)); this.f3891b.put("f1e0b5", new C1386c(0.4599d, 0.4106d, "CCT_LIGHT_NEUTRAL", 0.61d)); this.f3891b.put("efd275", new C1386c(0.5056d, 0.4152d, "efd275", 0.66d)); this.f3891b.put("dcf0f8", new C1386c(0.3221d, 0.3317d, "dcf0f8", 0.45d)); this.f3891b.put("eaf6fb", new C1386c(0.3451d, 0.3451d, "eaf6fb", 0.48d)); this.f3891b.put("f5faf6", new C1386c(0.3804d, 0.3804d, "f5faf6", 0.54d)); this.f3891b.put("f2eccf", new C1386c(0.4369d, 0.4041d, "f2eccf", 0.59d)); this.f3891b.put("CCT_LIGHT_NEUTRAL", new C1386c(0.4599d, 0.4106d, "CCT_LIGHT_NEUTRAL", 0.61d)); this.f3891b.put("efd275", new C1386c(0.5056d, 0.4152d, "efd275", 0.66d)); this.f3891b.put("ebb63e", new C1386c(0.5516d, 0.4075d, "ebb63e", 0.68d)); this.f3891b.put("e78834", new C1386c(0.58d, 0.38d, "e78834", 0.69d)); this.f3891b.put("e57345", new C1386c(0.58d, 0.35d, "e57345", 0.67d)); this.f3891b.put("da5d41", new C1386c(0.62d, 0.34d, "da5d41", 0.7d)); this.f3891b.put("dc4b31", new C1386c(0.66d, 0.32d, "dc4b31", 0.73d)); this.f3891b.put("e491af", new C1386c(0.5d, 0.28d, "e491af", 0.57d)); this.f3891b.put("e8bedd", new C1386c(0.45d, 0.28d, "e8bedd", 0.53d)); this.f3891b.put("d9337c", new C1386c(0.5d, 0.24d, "d9337c", 0.55d)); this.f3891b.put("c984bb", new C1386c(0.34d, 0.19d, "c984bb", 0.38d)); this.f3891b.put("8f2686", new C1386c(0.31d, 0.12d, "8f2686", 0.33d)); this.f3891b.put("4a418a", new C1386c(0.17d, 0.05d, "4a418a", 0.18d)); this.f3891b.put("6c83ba", new C1386c(0.2d, 0.1d, "6c83ba", 0.22d)); this.f3891b.put("a9d62b", new C1386c(0.4099999964237213d, 0.5099999904632568d, "a9d62b", 0.654d)); this.f3891b.put("d6e44b", new C1386c(0.44999998807907104d, 0.4699999988079071d, "d6e44b", 0.65d));
|
Thanks! And congratulations on your first PR ! 🐬 🎉 |
|
Thank you. I'm happy to contribute. |
the use of set_rgb_color() seems to be advantageous over set_hex_color() for full RGB support
Description:
Issue:
pytradfri's set_hex_color() does not work for arbitrary colors with the current IKEA tradfri gateway. Only setting rgb hex values (param 5706) of some predefined colors has the desired effect. Others will fall back to one predefined value. I assume, the GW doesn't allow for values deviating from the predefined values.
However, pytradfri's set_rgb_color() does also work for arbitrary colors. Latest pytradfri (2.2/PR51?) will convert rgb to xy and send xy thru the GW (param 5709 and 5710).
-> changed the function used from set_hex_color() to set_rgb_color() in HA's component\light\tradfri
Result:
Full RGB support with arbitrary colors with my setup.
Setup:
Home Assistant 0.53.0
pytradfri 2.2
IKEA tradfri gateway fw 1.1.0015
zigbee rgb PWM module (dresden elektronik FLS-PP lp)
Unfortunately I cannot test tradfri GW with other bulbs (no have hue/lightify bulbs).
Predefined colors from <home-assistant-libs/pytradfri#51>:
this.f3891b = new HashMap();
this.f3891b.put("f5faf6", new C1386c(0.3804d, 0.3804d, "f5faf6", 0.54d));
this.f3891b.put("f1e0b5", new C1386c(0.4599d, 0.4106d, "CCT_LIGHT_NEUTRAL", 0.61d));
this.f3891b.put("efd275", new C1386c(0.5056d, 0.4152d, "efd275", 0.66d));
this.f3891b.put("dcf0f8", new C1386c(0.3221d, 0.3317d, "dcf0f8", 0.45d));
this.f3891b.put("eaf6fb", new C1386c(0.3451d, 0.3451d, "eaf6fb", 0.48d));
this.f3891b.put("f5faf6", new C1386c(0.3804d, 0.3804d, "f5faf6", 0.54d));
this.f3891b.put("f2eccf", new C1386c(0.4369d, 0.4041d, "f2eccf", 0.59d));
this.f3891b.put("CCT_LIGHT_NEUTRAL", new C1386c(0.4599d, 0.4106d, "CCT_LIGHT_NEUTRAL", 0.61d));
this.f3891b.put("efd275", new C1386c(0.5056d, 0.4152d, "efd275", 0.66d));
this.f3891b.put("ebb63e", new C1386c(0.5516d, 0.4075d, "ebb63e", 0.68d));
this.f3891b.put("e78834", new C1386c(0.58d, 0.38d, "e78834", 0.69d));
this.f3891b.put("e57345", new C1386c(0.58d, 0.35d, "e57345", 0.67d));
this.f3891b.put("da5d41", new C1386c(0.62d, 0.34d, "da5d41", 0.7d));
this.f3891b.put("dc4b31", new C1386c(0.66d, 0.32d, "dc4b31", 0.73d));
this.f3891b.put("e491af", new C1386c(0.5d, 0.28d, "e491af", 0.57d));
this.f3891b.put("e8bedd", new C1386c(0.45d, 0.28d, "e8bedd", 0.53d));
this.f3891b.put("d9337c", new C1386c(0.5d, 0.24d, "d9337c", 0.55d));
this.f3891b.put("c984bb", new C1386c(0.34d, 0.19d, "c984bb", 0.38d));
this.f3891b.put("8f2686", new C1386c(0.31d, 0.12d, "8f2686", 0.33d));
this.f3891b.put("4a418a", new C1386c(0.17d, 0.05d, "4a418a", 0.18d));
this.f3891b.put("6c83ba", new C1386c(0.2d, 0.1d, "6c83ba", 0.22d));
this.f3891b.put("a9d62b", new C1386c(0.4099999964237213d, 0.5099999904632568d, "a9d62b", 0.654d));
this.f3891b.put("d6e44b", new C1386c(0.44999998807907104d, 0.4699999988079071d, "d6e44b", 0.65d));
Related issue (if applicable): fixes #
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.github.io#<home-assistant.github.io PR number goes here>
Example entry for
configuration.yaml(if applicable):Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
toxrun successfully. Your PR cannot be merged unless tests passREQUIREMENTSvariable (example).requirements_all.txtby runningscript/gen_requirements_all.py..coveragerc.If the code does not interact with devices:
toxrun successfully. Your PR cannot be merged unless tests pass