IKEA Tradfri Color Changing bulb on Hue Bridge no control of colors

The Problem is, the IKEA RGB Bulb accept no CIE Color Mode… only XY Color Mode … :wink:
And the HUE Binding use CIE Color Mode :wink:

1 Like

I have the same problem, but if it works in Hue App it should be possible to get it to work in Hue binding.

/Mike

No … the Code of Hue App and the Code of Binding is different … the Maintainer or any one other … must create some code for the Binding … or adopt it from the Tradfri Binding… without Code changes it will not work.

That was what i meant.
I understand that we have to change the code in the binding, but it should not be an technical issue that stops the possibility to get it to work.

/Mike

1 Like

Okay :slight_smile:

Please note my comment in the other thread. If nobody does that you’ll never see a result. Thanks.

I add a Issue here… feel free to comment this Issue … and explain your Problems :slight_smile:

Kay answered that the hue bridge should handle the conversion. But why is the binding not just sending everything as XY for max compatibility? Is there any downsite?

Is the problem not caused by the recognition of the bulb. If I remember well my bulb was recognised as type 200 and not 210. I think the recognition is done by the binding and something is working not correctly there…

My Work A Round for the Moment is …

Setting Color by Command Line :wink:

Getting a User:

https://www.developers.meethue.com/documentation/getting-started

Set Color by the Command:

curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [1,1]}' http://<HUE_BRIDGE_IP>/api/<YOUR_USER_HASH>/lights/<HUE-BULB-ID>/state

Here my complete Work A Round

Item

Number colorpicker_wohnzimmer_schrank "Colorpicker Wohnzimmer Schrank"

Sitemap

Selection item=colorpicker_wohnzimmer_schrank label="Farbe:" icon="colorpicker" visibility=[Stehlampe_Wohnzimmer_Schrank_Switch==ON] mappings=[
            0="  Warmes Licht  ",
            1="  Tageslicht  ",
            2="  Nachtlicht  ",
            3="  Sonnenuntergang  ",
            4="  Gelb  ",
            5="  Helles Gelb  ",
            6="  Helles Grün  ",
            7="  Orange  ",
            8="  Helles Orange  ",
            9="  Rot  ",
            10="  Pink  ",
            11="  Helles Lila  ",
            12="  Blau  "
          ]

Rule

//################################//
//RGB Stehlampe Wohnzimmer Schrank//
//################################//

rule "RGB Farbe Wohnzimmer Schrank"
when
  Item colorpicker_wohnzimmer_schrank changed
then
  executeCommandLine("/etc/openhab2/scripts/hue_tradfri_color.sh 3 Stehlampe_Wohnzimmer_Schrank_Brightness " + colorpicker_wohnzimmer_schrank.state)
end

BashScript

#!/bin/bash

# -- $1 = Bulb ID -- $2 = Bulb Brightness Item -- $3 = Color Command

openhab_ip="192.168.1.100"
hue_brigde_ip="192.168.1.101"
#HUE_Bridge_User erstellen -> https://www.developers.meethue.com/documentation/getting-started
hue_bridge_user="<HUE_Bridge_User>"

case $3 in
    0)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.5234,0.4023]}' http://$hue_brigde_ip/api/$hue_bridge_user/lights/$1/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://$openhab_ip:8080/rest/items/$2"
        ;;
    1)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.3812,0.3385]}' http://$hue_brigde_ip/api/$hue_bridge_user/lights/$1/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://$openhab_ip:8080/rest/items/$2"
        ;;
    2)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.5918,0.399]}' http://$hue_brigde_ip/api/$hue_bridge_user/lights/$1/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "1" "http://$openhab_ip:8080/rest/items/$2"
        ;;
    3)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.6409,0.3332]}' http://$hue_brigde_ip/api/$hue_bridge_user/lights/$1/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://$openhab_ip:8080/rest/items/$2"
        ;;
    4)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.5465,0.4405]}' http://$hue_brigde_ip/api/$hue_bridge_user/lights/$1/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://$openhab_ip:8080/rest/items/$2"
        ;;
    5)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.2642,0.6641]}' http://$hue_brigde_ip/api/$hue_bridge_user/lights/$1/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://$openhab_ip:8080/rest/items/$2"
        ;;
    6)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.5049,0.4509]}' http://$hue_brigde_ip/api/$hue_bridge_user/lights/$1/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://$openhab_ip:8080/rest/items/$2"
        ;;
    7)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.6566,0.3396]}' http://$hue_brigde_ip/api/$hue_bridge_user/lights/$1/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://$openhab_ip:8080/rest/items/$2"
        ;;
    8)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.6289,0.34]}' http://$hue_brigde_ip/api/$hue_bridge_user/lights/$1/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://$openhab_ip:8080/rest/items/$2"
        ;;
    9)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.6944,0.2986]}' http://$hue_brigde_ip/api/$hue_bridge_user/lights/$1/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://$openhab_ip:8080/rest/items/$2"
        ;;
    10)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.434,0.1777]}' http://$hue_brigde_ip/api/$hue_bridge_user/lights/$1/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://$openhab_ip:8080/rest/items/$2"
        ;;
    11)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.2454,0.0903]}' http://$hue_brigde_ip/api/$hue_bridge_user/lights/$1/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://$openhab_ip:8080/rest/items/$2"
        ;;
    12)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.1538,0.051]}' http://$hue_brigde_ip/api/$hue_bridge_user/lights/$1/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://$openhab_ip:8080/rest/items/$2"
        ;;
    *)
        echo "Kommando nicht vorhanden!"
        ;;
esac
1 Like

Thank you very much … Works great.

1 Like

Hello, i have one question :frowning:
Where do I have to put the BashScript?
Or what do I have to do with it?

Here you see the place of the Script :slight_smile:

Hello, I made the whole afternoon and did not manage it.

Inside my item:

Switch Schl_Bambus_bu             "Schlafzimmer Bambus"             <light>                   (gSchl,gLicht,gLicht0,gLicht2) ["Lighting"] {channel="hue:0200:00178821c409:6:color"}
Color  Schl_Bambus_bu_Color       "Schlafzimmer Bambus Farbe" 	                              (gSchl,gLicht,gColor_schl)                ["Lighting"] {channel="hue:0200:00178821c409:6:color"}
Dimmer Schl_Bambus_bu_brightness "Schlafzimmer Bambus Helligkeit" <qualityofservice>         (gSchl,gLicht,gBrightnes_schl,gBrightnes_all)                ["Lighting"] {channel="hue:0200:00178821c409:6:color"}
Switch Schl_Bambus_bu_Effect      "Schlafzimmer Bambus Color Loop"                            (gSchl,gLicht)                ["Lighting"] {channel="hue:0200:00178821c409:6:effect"}
String Schl_Bambus_bu_Alert       "Schlafzimmer Bambus Alert"                                 (gSchl,gLicht)                             {channel="hue:0200:00178821c409:6:alert"}

Then i created a file called hue_tradfri_color.sh

/etc/openhab2/scripts/hue_tradfri_color.sh
hue Brige user i have a little bit alienated, but the rest is original

openhab_ip="192.168.100.35"
hue_brigde_ip="192.168.100.20"
#HUE_Bridge_User erstellen -> https://www.developers.meethue.com/documentation/getting-started
hue_bridge_user="mO9LfyqD0SFDzznPWnKaQYod......"

case $3 in
    0)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.5234,0.4023]}' http://192.168.100.20/api/mO9LfyqD0SFDzznPWnKaQYodK0JiO......./lights/6/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://192.168.100.35:8080/rest/items/Schl_Bambus_bu_brightness"
        ;;
    1)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.3812,0.3385]}' http://192.168.100.20/api/mO9LfyqD0SFDzznPWnKaQYodK0JiOG......./lights/6/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://192.168.100.35:8080/rest/items/Schl_Bambus_bu_brightness"
        ;;
    2)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.5918,0.399]}' http://192.168.100.20/api/mO9LfyqD0SFDzznPWnKaQYodK0...../lights/6/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "1" "http://192.168.100.35:8080/rest/items/Schl_Bambus_bu_brightness"
        ;;
    3)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.6409,0.3332]}' http://192.168.100.20/api/mO9LfyqD0SFDzznPWnKaQYodK0......../lights/6/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://192.168.100.35:8080/rest/items/Schl_Bambus_bu_brightness"
        ;;
    4)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.5465,0.4405]}' http://192.168.100.20/api/mO9LfyqD0SFDzznPWnKaQYodK0......./lights/6/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://192.168.100.35:8080/rest/items/Schl_Bambus_bu_brightness"
        ;;
    5)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.2642,0.6641]}' http://192.168.100.20/api/mO9LfyqD0SFDzznPWnKaQYodK0JiO....../lights/6/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://192.168.100.35:8080/rest/items/Schl_Bambus_bu_brightness"
        ;;
    6)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.5049,0.4509]}' http://192.168.100.20/api/mO9LfyqD0SFDzznPWnKaQYodK0JiOG......./lights/6/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://192.168.100.35:8080/rest/items/Schl_Bambus_bu_brightness"
        ;;
    7)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.6566,0.3396]}' http://192.168.100.20/api/mO9LfyqD0SFDzznPWnKaQYodK0JiO...../lights/6/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://192.168.100.35:8080/rest/items/Schl_Bambus_bu_brightness"
        ;;
    8)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.6289,0.34]}' http://192.168.100.20/api/mO9LfyqD0SFDzznPWnKaQYodK0JiOG....../lights/6/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://192.168.100.35:8080/rest/items/Schl_Bambus_bu_brightness"
        ;;
    9)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.6944,0.2986]}' http://192.168.100.20/api/mO9LfyqD0SFDzznPWnKaQYodK0JiOGP......./lights/6/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://192.168.100.35:8080/rest/items/Schl_Bambus_bu_brightness"
        ;;
    10)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.434,0.1777]}' http://192.168.100.20/api/mO9LfyqD0SFDzznPWnKaQYodK0JiOGP....../lights/6/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://192.168.100.35:8080/rest/items/Schl_Bambus_bu_brightness"
        ;;
    11)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.2454,0.0903]}' http://192.168.100.20/api/mO9LfyqD0SFDzznPWnKaQYodK0JiOGP......./lights/6/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://192.168.100.35:8080/rest/items/Schl_Bambus_bu_brightness"
        ;;
    12)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.1538,0.051]}' http://192.168.100.20/api/mO9LfyqD0SFDzznPWnKaQYodK0JiOGP......./lights/6/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://192.168.100.35:8080/rest/items/Schl_Bambus_bu_brightness"
        ;;
    *)
        echo "Kommando nicht vorhanden!"
        ;;
esac

here is the content of my
/etc/openhab2/scripts/rules/ikea.rules

//################################//
//RGB Stehlampe Wohnzimmer Schrank//
//################################//

rule "Schlafzimmer Kugel"
when
  Item Schl_Bambus_bu_Color  changed
then
  executeCommandLine("/etc/openhab2/scripts/hue_tradfri_color.sh 3 Schl_Bambus_bu_brightness"+ Schl_Bambus_bu_Color.state)

end

and this i added to my sitemap

  }
Frame label="Bambus" {
Selection item=Schl_Bambus_bu_Color  label="Farbe:" icon="colorpicker" visibility=[Schl_Bambus_bu==ON] mappings=[
            0="  Warmes Licht  ",
            1="  Tageslicht  ",
            2="  Nachtlicht  ",
            3="  Sonnenuntergang  ",
            4="  Gelb  ",
            5="  Helles Gelb  ",
            6="  Helles Gr¸n  ",
            7="  Orange  ",
            8="  Helles Orange  ",
            9="  Rot  ",
            10="  Pink  ",
            11="  Helles Lila  ",
            12="  Blau  "
          
          ]
          }

Unfortunately it does not work yet. If I enter the content from the bash individually, he already changes the colors.
What do you mean with this? --> 3 Stehlampe_Wohnzimmer_Schrank_Brightness " + colorpicker_wohnzimmer_schrank.state)

Sorry for my bad englisch ;-( And thank you for your support

I’m not sure, why you have modified the bash script. But don’t replace the params $1, $2 and $3 with a static content. Otherwise you could use the script only once for one bulb and executing with 3 Schl_Bambus_bu_brightness"+ Schl_Bambus_bu_Color.state doesn’t make any sense

According to your example, I have the following suggestions:

items file should look like this … it makes actually no sense to implement the other channels for a colored tradfri bulb at the moment, because they don’t work (as expected).

Number Schl_Bambus_bu_brightness   "Helligkeit [%.0f %%]" <bulb>
Number Schl_Bambus_bu_colorpicker  "Farbwahl"
Color Schl_Bambus_bu_color         "Farbwahl" { channel="hue:0200:00178821c409:6:color" }

rules files should look like this

// RGB Workaround Schlafzimmer Kugel
rule "RGB Workaround Schlafzimmer Kugel"
	when
		Item Schl_Bambus_bu_colorpicker changed
	then
		executeCommandLine("/etc/openhab2/scripts/hue_tradfri_color.sh 6 Schl_Bambus_bu_brightness " + Schl_Bambus_bu_colorpicker.state)
	end

Where <6> is the number of your bulb (e.g. from hue:0200:00178821c409:6:color)

So use the script hue_tradfri_color.sh as provided by @ei_Gelb_Geek.
The only things, that have to be changed are:

openhab_ip -> set it to your openhab ip
hue_bridge_ip -> set it to your hue bridge ip
hue_bridge_user -> the user hash / secret, you’ll have already

#!/bin/bash

# -- $1 = Bulb ID -- $2 = Bulb Brightness Item -- $3 = Color Command

openhab_ip="192.168.1.10"
hue_brigde_ip="192.168.1.11"
#HUE_Bridge_User erstellen -> https://www.developers.meethue.com/documentation/getting-started
hue_bridge_user="zaishiyahl8eemee1aengud7zeikihe6aeDu"

case $3 in
    0)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.5234,0.4023]}' http://$hue_brigde_ip/api/$hue_bridge_user/lights/$1/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://$openhab_ip:8080/rest/items/$2"
        ;;
    1)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.3812,0.3385]}' http://$hue_brigde_ip/api/$hue_bridge_user/lights/$1/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://$openhab_ip:8080/rest/items/$2"
        ;;
    2)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.5918,0.399]}' http://$hue_brigde_ip/api/$hue_bridge_user/lights/$1/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "1" "http://$openhab_ip:8080/rest/items/$2"
        ;;
    3)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.6409,0.3332]}' http://$hue_brigde_ip/api/$hue_bridge_user/lights/$1/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://$openhab_ip:8080/rest/items/$2"
        ;;
    4)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.5465,0.4405]}' http://$hue_brigde_ip/api/$hue_bridge_user/lights/$1/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://$openhab_ip:8080/rest/items/$2"
        ;;
    5)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.2642,0.6641]}' http://$hue_brigde_ip/api/$hue_bridge_user/lights/$1/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://$openhab_ip:8080/rest/items/$2"
        ;;
    6)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.5049,0.4509]}' http://$hue_brigde_ip/api/$hue_bridge_user/lights/$1/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://$openhab_ip:8080/rest/items/$2"
        ;;
    7)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.6566,0.3396]}' http://$hue_brigde_ip/api/$hue_bridge_user/lights/$1/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://$openhab_ip:8080/rest/items/$2"
        ;;
    8)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.6289,0.34]}' http://$hue_brigde_ip/api/$hue_bridge_user/lights/$1/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://$openhab_ip:8080/rest/items/$2"
        ;;
    9)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.6944,0.2986]}' http://$hue_brigde_ip/api/$hue_bridge_user/lights/$1/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://$openhab_ip:8080/rest/items/$2"
        ;;
    10)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.434,0.1777]}' http://$hue_brigde_ip/api/$hue_bridge_user/lights/$1/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://$openhab_ip:8080/rest/items/$2"
        ;;
    11)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.2454,0.0903]}' http://$hue_brigde_ip/api/$hue_bridge_user/lights/$1/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://$openhab_ip:8080/rest/items/$2"
        ;;
    12)
        curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.1538,0.051]}' http://$hue_brigde_ip/api/$hue_bridge_user/lights/$1/state
        sleep 1
        curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://$openhab_ip:8080/rest/items/$2"
        ;;
    *)
        echo "Kommando nicht vorhanden!"
        ;;
esac

Copy this script to /etc/openhab2/scripts/hue_tradfri_color.sh and make it executable

chown openhab.openhab /etc/openhab2/scripts/hue_tradfri_color.sh
chmod 770 /etc/openhab2/scripts/hue_tradfri_color.sh

So check if everything is working as expected by calling that script with

bash /etc/openhab2/scripts/hue_tradfri_color.sh 6 Schl_Bambus_bu_brightness " + Schl_Bambus_bu_colorpicker.state

for debugging use

bash -x /etc/openhab2/scripts/hue_tradfri_color.sh 6 Schl_Bambus_bu_brightness " + Schl_Bambus_bu_colorpicker.state

In the script $1 is replaced with the bulb id (6), $2 is replaced with the (dummy) brightness item, $3 with the number from the dummy colorpicker (0 - 12).

The script will do a http request to the hue bridge

curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.5234,0.4023]}' http://$hue_brigde_ip/api/$hue_bridge_user/lights/$1/state

like

curl -s -H "Accept: application/json" -X PUT --data '{"on": true,"xy": [0.5234,0.4023]}' http://192.168.1.11/api/zaishiyahl8eemee1aengud7zeikihe6aeDu/lights/6/state

and the color of the bulb will change.

Afterwards a rest call is done to the openhab api to update the dummy brightness item from the item definition. This has nothing to do with the “real” brightness state of the bulb. If you change the brightness of the bulb through the app, the item will not be updated.
I’m not sure, why @ei_Gelb_Geek has done this, maybee he wants a feedback in the sitemap and / or can tell more about that feature.

From

curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://$openhab_ip:8080/rest/items/$2"

to

curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "50" "http://192.168.1.10:8080/rest/items/Schl_Bambus_bu_brightness"

Sitemap code should look something like this

				Frame label="Ambiente" {
					Switch item=Schl_Bambus_bu_color label="Farbkugel" icon=crystalball
					Text item=Schl_Bambus_bu_brightness
					Selection item=Schl_Bambus_bu_colorpicker label="Farbe:" mappings=[
						0="  Warmes Licht  ",
						1="  Tageslicht  ",
						2="  Nachtlicht  ",
						3="  Sonnenuntergang  ",
						4="  Gelb  ",
						5="  Helles Gelb  ",
						6="  Helles Grün  ",
						7="  Orange  ",
						8="  Helles Orange  ",
						9="  Rot  ",
						10="  Pink  ",
						11="  Helles Lila  ",
						12="  Blau  "
					]
				}

The real color item of the bulb (Schl_Bambus_bu_color) is mapped to a switch, because ON/OFF is actually the only command that works like expected.

Hope this helps to understand the workaround solution.!

The sitemap looks like that …

Hello Jens. Thanks alot. unfortunately it does not work yet. I do not know why. In fact, I have adopted and aligned everything, such as the hue_bridge_user and ip addresses. The api debug tool (hue) is the color change correct :face_with_raised_eyebrow:

Try this Commands in your Shell …

bash /etc/openhab2/scripts/hue_tradfri_color.sh 6 Schl_Bambus_bu_brightness 1

or 

bash -x /etc/openhab2/scripts/hue_tradfri_color.sh 6 Schl_Bambus_bu_brightness 1

if this not work, post a Screenshot from the Response …

Hello, Kevin.
this is the response and it didnt work.

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Tue Mar  6 21:47:25 2018 from 192.168.100.22

###############################################################################
################# openHABianPi ################################################
###############################################################################
##             Ip = 192.168.100.35
##        Release = Raspbian GNU/Linux 9 (stretch)
##         Kernel = Linux 4.9.59-v7+
##       Platform = Raspberry Pi 3 Model B Rev 1.2
##         Uptime = 0 day(s). 9:12:52
##      CPU Usage = 0.5 % avg over 4 cpu(s)  (4 core(s) x 1 socket(s))
##       CPU Load = 1m: 0.08, 5m: 0.09, 15m: 0.03
##         Memory = Free: 0.34GB (36%), Used: 0.61GB (64%), Total: 0.95GB
##           Swap = Free: 0.09GB (100%), Used: 0.00GB (0%), Total: 0.09GB
##           Root = Free: 11.66GB (86%), Used: 1.87GB (14%), Total: 14.14GB
##        Updates = 14 apt updates available.
##       Sessions = 1 sessions
##      Processes = 136 running processes of 32768 maximum processes
###############################################################################

              Welcome to            __  _____    ____  _
            ____  ____  ___  ____  / / / /   |  / __ )(_)___ _____
           / __ \/ __ \/ _ \/ __ \/ /_/ / /| | / __  / / __ `/ __ \
          / /_/ / /_/ /  __/ / / / __  / ___ |/ /_/ / / /_/ / / / /
          \____/ .___/\___/_/ /_/_/ /_/_/  |_/_____/_/\__,_/_/ /_/
              /_/
                  openHAB 2.2.0-1 (Release Build)


Looking for a place to get started? Check out 'sudo openhabian-config' and the
documentation at http://docs.openhab.org/installation/openhabian.html
The openHAB dashboard can be reached at http://openHABianPi:8080
To interact with openHAB on the command line, execute: 'openhab-cli --help'

[06:51:20] Snop007@openHABianPi:~$ bash /etc/openhab2/scripts/hue_tradfri_color.sh 6 Schl_Bambus_bu_brightness 1
/etc/openhab2/scripts/hue_tradfri_color.sh: Zeile 1: $'\r': Kommando nicht gefunden.
/etc/openhab2/scripts/hue_tradfri_color.sh: Zeile 4: $'\r': Kommando nicht gefunden.
/etc/openhab2/scripts/hue_tradfri_color.sh: Zeile 6: $'\r': Kommando nicht gefunden.
/etc/openhab2/scripts/hue_tradfri_color.sh: Zeile 7: Syntaxfehler beim unerwarteten Wort `$'in\r''
'etc/openhab2/scripts/hue_tradfri_color.sh: Zeile 7: `case $3 in
[06:51:26] Snop007@openHABianPi:~$ bash -x /etc/openhab2/scripts/hue_tradfri_color.sh 6 Schl_Bambus_bu_brightness 1
+ $'\r'
/etc/openhab2/scripts/hue_tradfri_color.sh: Zeile 1: $'\r': Kommando nicht gefunden.
+ openhab_ip=$'192.168.100.35\r'
+ hue_brigde_ip=$'192.168.100.20\r'
+ $'\r'
/etc/openhab2/scripts/hue_tradfri_color.sh: Zeile 4: $'\r': Kommando nicht gefunden.
+ hue_bridge_user=$'mO9LfyqD0SFDzznPWnKaQYodK0JiOGPEnix-LPrM\r'
+ $'\r'
/etc/openhab2/scripts/hue_tradfri_color.sh: Zeile 6: $'\r': Kommando nicht gefunden.
/etc/openhab2/scripts/hue_tradfri_color.sh: Zeile 7: Syntaxfehler beim unerwarteten Wort `$'in\r''
'etc/openhab2/scripts/hue_tradfri_color.sh: Zeile 7: `case $3 in
[06:52:10] Snop007@openHABianPi:~$ 

The file has the wrong format. I assume, you’ve created it on Windows (or Mac).
Try

sudo apt install dos2unix

and

dos2unix /etc/openhab2/scripts/hue_tradfri_color.sh

Otherwise try

file /etc/openhab2/scripts/hue_tradfri_color.sh

and post the output here.

1 Like