glenndehaan / ikea-tradfri-coap-docs

How can you communicate to your ikea tradfri gateway/hub through coap-client
MIT License
189 stars 21 forks source link

Try RGB-Colors but failed #13

Closed Joey-1970 closed 7 months ago

Joey-1970 commented 4 years ago

Hello Glenn,

may be you see want is wong, but for me the RGB-command failed. I try your example: coap-client -m put -u "$TF_USERNAME" -k "$TF_PRESHARED_KEY" -e '{ "3311": ["5709": 65535, "5710": 65535] }' "coaps://$TF_GATEWAYIP:5684/15001/$TF_DEVICEID" to adapt for me: coap-client -m put -u "myusername" -k "mykey" -e '{ "3311": ["5709": 65535, "5710": 65535] }' "coaps://192.168.178.52:5684/15001/65538" but I get this return: v:1 t:CON c:PUT i:2312 {} [ ] decrypt_verify(): found 24 bytes cleartext decrypt_verify(): found 15 bytes cleartext 5.00 {"r":"07"} I think that 5.00 {"r":"07"} should show me that something is wrong, but I don't see it...

Joachim

Joey-1970 commented 4 years ago

...maybe, the middle-part must be something in this way: '{ "3311": [{"5709": 65353, "5710": 65535}] }' (one more { left, and right } from the array) ...I try several variations, but in this I have a reaction...

Joachim

glenndehaan commented 4 years ago

That command should work fine. One thing to note is that if your bulb isn't an RGB bulb this won't work. Also if you enter an out of bounds value the bulb won't change and isn't going to give a response.

Can you first try a HEX value to make sure that your bulb is RGB capable and is changing accordingly.

Joey-1970 commented 4 years ago

Hello Glenn,

the bulb I try is a "Tradfri bulb E14 CWS opal 600lm". I thing this is a "RGB"? Maybe I have two parts where I can make a mistake:

  1. Convert from RGB-Hex (given from the color-picker in the application) to xyY-Value
  2. Convert the xyY from the given value to 0-65535 A "normal" xyY-Value look like a value that ist 0 to 1?
    Do you have any idea for me?

Joachim

glenndehaan commented 4 years ago

That bulb should be indeed an RGB one. If you try this command is it changing to Blue for example?:

coap-client -m put -u "$TF_USERNAME" -k "$TF_PRESHARED_KEY" -e '{ "3311": [{ "5706": ¨4a418a¨ }] }' "coaps://$TF_GATEWAYIP:5684/15001/$TF_DEVICEID"
Joey-1970 commented 4 years ago

...that was first I try - direkt from the hex-value from color-picker send to the bulb, but not every time I see a reaction. I will try it again...

Joachim

glenndehaan commented 4 years ago

Yeah the bulbs are picky about the colors and I have to say that I didn't found a good HEX to xyY converter yet

kollokollo commented 3 years ago

Some of the color bulbs are not true RGB. The use four groups of LEDs instead. blue, red, cold white and warm white. So e.g. the green colors cannot really be displayed (only a very bright greenish color). One can draw the area used in the Color space diagram to indicate, which xy colors can be used. Also depending on the brighness wanted not all colors can be set either. This might be complicated. One would need to find out the xyY values for each of the LED grould used and then draw four points in the xy diagram accordingly. Connect them with a line and you get the area which can be used.

snigel commented 7 months ago

I solved it. I was having the same issue, couldn't set the colors without getting the return 5.00 {"r":"07"}

Trying a custom color failed.

coap-client-gnutls -m put -u "$TF_USERNAME" -k "$TF_PRESHARED_KEY" -e '{ "3311": ["5709": 65535, "5710": 65535] }' "coaps://$TF_GATEWAYIP:5684/15001/$TF_DEVICEID"
5.00 {"r":"07"}

But using hex works.

coap-client-gnutls -m put -u "$TF_USERNAME" -k "$TF_PRESHARED_KEY" -e '{ "3311": [{ "5706": "ff0000" }] }' "coaps://$TF_GATEWAYIP:5684/15001/$TF_DEVICEID

The custom color is missing the curly brackets inside the array. Hex: '{ "3311": [{ "5706": "ff0000" }] }' Custom color: '{ "3311": ["5709": 65535, "5710": 65535] }'

Trying with the curly brackets added, custom colors work fine.

coap-client-gnutls -m put -u "$TF_USERNAME" -k "$TF_PRESHARED_KEY" -e '{ "3311": [{"5709": 65535, "5710": 65535}] }' "coaps://$TF_GATEWAYIP:5684/15001/$TF_DEVICEID"

No return message and bulb changes color.

PR for the readme. https://github.com/glenndehaan/ikea-tradfri-coap-docs/pull/35

glenndehaan commented 7 months ago

🤣 Wow, yeah you are correct this was indeed a typo. I ever even looked at the README and always used my local script, in there the string was correct.

I have merged the MR and will close this issue.