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

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

Follow the Instruction of Jens … another solution is:

sudo rm /etc/openhab2/scripts/hue_tradfri_color.sh
sudo nano /etc/openhab2/scripts/hue_tradfri_color.sh

Paste my Script and Save it with Strg + O and exit with STRG + X

Is Curl installed on your System ?

which curl

If not install it with

sudo apt-get install curl

That has already worked. The script seems to work. However, the rule does not seem to work yet. If I change the color in the Basic UI, it will not change. Do I have to convert the rule to another format as well? I work with a Mac and Visual Studio code. Thank you very much for your efforts.

###############################################################################
################# 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). 23:4:29
##      CPU Usage = 1 % avg over 4 cpu(s)  (4 core(s) x 1 socket(s))
##       CPU Load = 1m: 0.00, 5m: 0.02, 15m: 0.05
##         Memory = Free: 0.29GB (31%), Used: 0.65GB (69%), 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 = 137 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'

[20:42:57] Snop007@openHABianPi:~$ bash /etc/openhab2/scripts/hue_tradfri_color.sh 6 Schl_Bambus_bu_brightness 1
[{"success":{"/lights/6/state/on":true}},{"success":{"/lights/6/state/xy":[0.3812,0.3385]}}][20:43:40] Snop007@openHABianPi:~$ bash -x /etc/openhab2/scripts/hueor.sh 6 Schl_Bambus_bu_brightness 1
+ openhab_ip=192.168.100.35
+ hue_brigde_ip=192.168.100.20
+ hue_bridge_user=mO9LfyqD0SFDzznPWnKaQYodK0JiOGPEnix-LPrM
+ case $3 in
+ curl -s -H 'Accept: application/json' -X PUT --data '{"on": true,"xy": [0.3812,0.3385]}' http://192.168.100.20/api/mO9LfyqD0SFDzznPWnKaQYodK0JiOGPEnix-LPrM/lights/6/state
[{"success":{"/lights/6/state/on":true}},{"success":{"/lights/6/state/xy":[0.3812,0.3385]}}]+ 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
[20:43:53] Snop007@openHABianPi:~$ 

[20:43:53] Snop007@openHABianPi:~$ file /etc/openhab2/scripts/hue_tradfri_color.sh
/etc/openhab2/scripts/hue_tradfri_color.sh: ASCII text
[20:45:14] Snop007@openHABianPi:~$

Hier meine rules.rules


// 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

Please have a look in /var/log/openhab2/openhab.log or wherever the openhab.log is located on openHABian.
First, try to extend the rule with a logging entry:


// RGB Workaround Schlafzimmer Kugel
rule "RGB Workaround Schlafzimmer Kugel"
	when
		Item Schl_Bambus_bu_colorpicker changed
	then
        logInfo("rules.rules", "RGB Workaround Schlafzimmer Kugel auf <" + Schl_Bambus_bu_colorpicker.state + " > gesetzt")
		executeCommandLine("/etc/openhab2/scripts/hue_tradfri_color.sh 6 Schl_Bambus_bu_brightness " + Schl_Bambus_bu_colorpicker.state)
	end

then execute the following in a terminal over ssh

tail -500lf /var/log/openhab2/openhab.log

Please select a number in the in the web ui and have a look, what happens in the logfile.
There should be a log entry similar to

… RGB Workaround Schlafzimmer Kugel auf < 5 > gesetzt …

Addiotionally, you could do something like

tail -500lf /var/log/openhab2/events.log | grep Schl_Bambus

to provide more informations, what happens in openhab.

Please read also the complete post #37
As I’ve seen a few seconds, you also use the old items-file, which is wrong.
Please update all your files as mentioned in post #37 and it should work.

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" }

Don’t bind the Number items to a hue channel. The only item which should be bind to a hue thing, is the Color channel. This channel only supports ON and OFF at the moment and is used in my sitemap to switch on and off the bulb. All other functions won’t work at the moment, so please update the items file as I suggested before.

Ah ok. I did it.
But it still does not work. Here the Loog of
tail -500lf /var/log/openhab2/openhab.log
tail -500lf /var/log/openhab2/events.log | grep Schl_Bambus

Can you recognize something unusual?


[21:06:38] Snop007@openHABianPi:~$ tail -500lf /var/log/openhab2/events.log | grep Schl_Bambus
2018-03-07 20:38:11.759 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_colorpicker' received command 4
2018-03-07 20:38:11.772 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_colorpicker changed from 2 to 4
2018-03-07 20:43:40.987 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_brightness' received command 50
2018-03-07 20:43:53.912 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_brightness' received command 50
2018-03-07 20:52:28.960 [temChannelLinkRemovedEvent] - Link 'Schl_Bambus_bu_Effect => hue:0200:00178821c409:6:effect' has been removed.
2018-03-07 20:52:28.966 [temChannelLinkRemovedEvent] - Link 'Schl_Bambus_bu => hue:0200:00178821c409:6:color' has been removed.
2018-03-07 20:52:28.973 [temChannelLinkRemovedEvent] - Link 'Schl_Bambus_bu_color => hue:0200:00178821c409:6:color' has been removed.
2018-03-07 20:52:28.981 [temChannelLinkRemovedEvent] - Link 'Schl_Bambus_bu_Alert => hue:0200:00178821c409:6:alert' has been removed.
2018-03-07 20:52:28.990 [temChannelLinkRemovedEvent] - Link 'Schl_Bambus_bu_brightness => hue:0200:00178821c409:6:color' has been removed.
2018-03-07 20:52:29.013 [temChannelLinkRemovedEvent] - Link 'Schl_Bambus_bu_colorpicker => hue:0200:00178821c409:6:color' has been removed.
2018-03-07 20:52:29.036 [temChannelLinkRemovedEvent] - Link 'Schl_Bambus_bu_Color => hue:0200:00178821c409:6:color' has been removed.
2018-03-07 20:52:29.769 [.ItemChannelLinkAddedEvent] - Link 'Schl_Bambus_bu_brightness-hue:0200:00178821c409:6:color' has been added.
2018-03-07 20:52:29.771 [.ItemChannelLinkAddedEvent] - Link 'Schl_Bambus_bu_colorpicker-hue:0200:00178821c409:6:color' has been added.
2018-03-07 20:52:29.781 [.ItemChannelLinkAddedEvent] - Link 'Schl_Bambus_bu_color-hue:0200:00178821c409:6:color' has been added.
2018-03-07 20:52:30.354 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_colorpicker changed from NULL to 0.71000000
2018-03-07 20:52:30.487 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_brightness changed from NULL to 0.71000000
2018-03-07 20:52:30.495 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_color changed from NULL to 54,100,71
2018-03-07 20:52:35.923 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_colorpicker' received command 9
2018-03-07 20:52:35.944 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_colorpicker changed from 0.71000000 to 9
2018-03-07 20:52:38.725 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_color' received command ON
2018-03-07 20:52:38.736 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_color changed from 54,100,71 to 54,100,100
2018-03-07 20:52:39.593 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_color' received command ON
2018-03-07 20:52:41.159 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_color' received command ON
2018-03-07 20:52:42.222 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_color' received command OFF
2018-03-07 20:52:42.235 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_color changed from 54,100,100 to 54,100,0
2018-03-07 20:52:43.773 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_color' received command ON
2018-03-07 20:52:43.784 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_color changed from 54,100,0 to 54,100,100
2018-03-07 20:52:46.399 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_color' received command ON
2018-03-07 20:52:48.976 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_colorpicker' received command 7
2018-03-07 20:52:48.991 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_colorpicker changed from 9 to 7
2018-03-07 20:52:53.426 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_colorpicker' received command 4
2018-03-07 20:52:53.442 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_colorpicker changed from 7 to 4
2018-03-07 20:55:33.260 [temChannelLinkRemovedEvent] - Link 'Schl_Bambus_bu_color => hue:0200:00178821c409:6:color' has been removed.
2018-03-07 20:55:33.272 [temChannelLinkRemovedEvent] - Link 'Schl_Bambus_bu_brightness => hue:0200:00178821c409:6:color' has been removed.
2018-03-07 20:55:33.306 [temChannelLinkRemovedEvent] - Link 'Schl_Bambus_bu_colorpicker => hue:0200:00178821c409:6:color' has been removed.
2018-03-07 20:55:33.756 [.ItemChannelLinkAddedEvent] - Link 'Schl_Bambus_bu-hue:0200:00178821c409:6:color' has been added.
2018-03-07 20:55:33.776 [.ItemChannelLinkAddedEvent] - Link 'Schl_Bambus_bu_Color-hue:0200:00178821c409:6:color' has been added.
2018-03-07 20:55:33.783 [.ItemChannelLinkAddedEvent] - Link 'Schl_Bambus_bu_brightness-hue:0200:00178821c409:6:color' has been added.
2018-03-07 20:55:33.786 [.ItemChannelLinkAddedEvent] - Link 'Schl_Bambus_bu_Effect-hue:0200:00178821c409:6:effect' has been added.
2018-03-07 20:55:33.790 [.ItemChannelLinkAddedEvent] - Link 'Schl_Bambus_bu_Alert-hue:0200:00178821c409:6:alert' has been added.
2018-03-07 20:55:33.792 [.ItemChannelLinkAddedEvent] - Link 'Schl_Bambus_bu_colorpicker-hue:0200:00178821c409:6:color' has been added.
2018-03-07 20:55:33.796 [.ItemChannelLinkAddedEvent] - Link 'Schl_Bambus_bu_color-hue:0200:00178821c409:6:color' has been added.
2018-03-07 20:55:34.204 [vent.ItemStateChangedEvent] - Schl_Bambus_bu changed from NULL to ON
2018-03-07 20:55:34.209 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_colorpicker changed from NULL to 0.71000000
2018-03-07 20:55:34.212 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_color changed from NULL to 54,100,71
2018-03-07 20:55:34.215 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_Alert changed from NULL to NONE
2018-03-07 20:55:34.233 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_brightness changed from NULL to 0.71000000
2018-03-07 20:55:34.243 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_Color changed from NULL to 54,100,71
2018-03-07 21:03:53.967 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_colorpicker' received command 9
2018-03-07 21:03:53.994 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_colorpicker changed from 0.71000000 to 9
2018-03-07 21:04:13.950 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_colorpicker' received command 5
2018-03-07 21:04:13.975 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_colorpicker changed from 9 to 5
2018-03-07 21:04:21.417 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_colorpicker' received command 6
2018-03-07 21:04:21.448 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_colorpicker changed from 5 to 6
2018-03-07 21:05:42.499 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_colorpicker' received command 4
2018-03-07 21:05:42.537 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_colorpicker changed from 6 to 4
2018-03-07 21:06:56.984 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_colorpicker' received command 3
2018-03-07 21:06:57.009 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_colorpicker changed from 4 to 3
2018-03-07 21:07:08.475 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_colorpicker' received command 5
2018-03-07 21:07:08.538 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_colorpicker changed from 3 to 5
2018-03-07 21:07:19.033 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_colorpicker' received command 7
2018-03-07 21:07:19.045 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_colorpicker changed from 5 to 7
2018-03-07 21:12:54.710 [temChannelLinkRemovedEvent] - Link 'Schl_Bambus_bu_Effect => hue:0200:00178821c409:6:effect' has been removed.
2018-03-07 21:12:54.715 [temChannelLinkRemovedEvent] - Link 'Schl_Bambus_bu => hue:0200:00178821c409:6:color' has been removed.
2018-03-07 21:12:54.726 [temChannelLinkRemovedEvent] - Link 'Schl_Bambus_bu_color => hue:0200:00178821c409:6:color' has been removed.
2018-03-07 21:12:54.738 [temChannelLinkRemovedEvent] - Link 'Schl_Bambus_bu_Alert => hue:0200:00178821c409:6:alert' has been removed.
2018-03-07 21:12:54.741 [temChannelLinkRemovedEvent] - Link 'Schl_Bambus_bu_brightness => hue:0200:00178821c409:6:color' has been removed.
2018-03-07 21:12:54.776 [temChannelLinkRemovedEvent] - Link 'Schl_Bambus_bu_colorpicker => hue:0200:00178821c409:6:color' has been removed.
2018-03-07 21:12:54.792 [temChannelLinkRemovedEvent] - Link 'Schl_Bambus_bu_Color => hue:0200:00178821c409:6:color' has been removed.
2018-03-07 21:16:32.301 [.ItemChannelLinkAddedEvent] - Link 'Schl_Bambus_bu_color-hue:0200:00178821c409:6:color' has been added.
2018-03-07 21:16:32.321 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_color changed from NULL to 54,100,71
2018-03-07 21:16:39.163 [temChannelLinkRemovedEvent] - Link 'Schl_Bambus_bu_color => hue:0200:00178821c409:6:color' has been removed.
2018-03-07 21:16:39.224 [.ItemChannelLinkAddedEvent] - Link 'Schl_Bambus_bu_color-hue:0200:00178821c409:6:color' has been added.
2018-03-07 21:16:39.237 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_color changed from NULL to 54,100,71
2018-03-07 21:17:03.971 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_colorpicker' received command 4
2018-03-07 21:17:03.996 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_colorpicker changed from NULL to 4
2018-03-07 21:17:08.457 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_colorpicker' received command 8
2018-03-07 21:17:08.466 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_colorpicker changed from 4 to 8
2018-03-07 21:17:12.451 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_colorpicker' received command 3
2018-03-07 21:17:12.469 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_colorpicker changed from 8 to 3
2018-03-07 21:17:13.937 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_color' received command ON
2018-03-07 21:17:13.951 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_color changed from 54,100,71 to 54,100,100
2018-03-07 21:17:14.459 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_color' received command ON
2018-03-07 21:17:16.314 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_color' received command ON
2018-03-07 21:17:17.088 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_color' received command OFF
2018-03-07 21:17:17.107 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_color changed from 54,100,100 to 54,100,0
2018-03-07 21:17:19.335 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_color' received command ON
2018-03-07 21:17:19.342 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_color changed from 54,100,0 to 54,100,100
2018-03-07 21:17:23.039 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_colorpicker' received command 6
2018-03-07 21:17:23.058 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_colorpicker changed from 3 to 6
2018-03-07 21:19:18.112 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_colorpicker' received command 4
2018-03-07 21:19:18.134 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_colorpicker changed from 6 to 4
2018-03-07 21:19:24.448 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_colorpicker' received command 9
2018-03-07 21:19:24.471 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_colorpicker changed from 4 to 9
2018-03-07 21:19:25.626 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_color' received command ON
2018-03-07 21:19:26.201 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_color' received command OFF
2018-03-07 21:19:26.219 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_color changed from 54,100,100 to 54,100,0
2018-03-07 21:19:27.290 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_color' received command ON
2018-03-07 21:19:27.299 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_color changed from 54,100,0 to 54,100,100
2018-03-07 21:19:28.221 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_color' received command ON
2018-03-07 21:19:29.237 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_color' received command OFF
2018-03-07 21:19:29.255 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_color changed from 54,100,100 to 54,100,0
2018-03-07 21:19:30.386 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_color' received command ON
2018-03-07 21:19:30.409 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_color changed from 54,100,0 to 54,100,100

Output of

tail -500lf /var/log/openhab2/openhab.log

is missing.

As you see in the event.log, the items are updated with the values from the channel, which is wrong. I assume, you have removed the channels from the items now?

2018-03-07 20:52:30.354 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_colorpicker changed from NULL to 0.71000000
2018-03-07 20:52:30.487 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_brightness changed from NULL to 0.71000000
2018-03-07 20:52:30.495 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_color changed from NULL to 54,100,71

This indicates, that the dummy item “Schl_Bambus_bu_colorpicker” receives a number and the rule should be triggered

2018-03-07 21:17:23.039 [ome.event.ItemCommandEvent] - Item 'Schl_Bambus_bu_colorpicker' received command 6
2018-03-07 21:17:23.058 [vent.ItemStateChangedEvent] - Schl_Bambus_bu_colorpicker changed from 3 to 6

So it’s necessary, that you update the rules-file with the log entry to show, what happens and if the rule is triggered.

I have removed the channels. But was that it?
Thats the look of tail -500lf /var/log/openhab2/openhab.log

2018-03-07 22:09:25.137 [ERROR] [lipse.smarthome.io.net.exec.ExecUtil] - couldn't execute commandLine '/etc/openhab2/scripts/hue_tradfri_color.sh 6 Schl_Bambus_bu_brightness 9'
java.io.IOException: Cannot run program "/etc/openhab2/scripts/hue_tradfri_color.sh": error=13, Keine Berechtigung
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) ~[?:?]
	at java.lang.Runtime.exec(Runtime.java:620) ~[?:?]
	at java.lang.Runtime.exec(Runtime.java:450) ~[?:?]
	at java.lang.Runtime.exec(Runtime.java:347) ~[?:?]
	at org.eclipse.smarthome.io.net.exec.ExecUtil.executeCommandLine(ExecUtil.java:65) ~[?:?]
	at org.eclipse.smarthome.model.script.actions.Exec.executeCommandLine(Exec.java:43) ~[?:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeOperation(XbaseInterpreter.java:1085) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeOperation(XbaseInterpreter.java:1060) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._invokeFeature(XbaseInterpreter.java:1046) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeFeature(XbaseInterpreter.java:991) ~[?:?]
	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.invokeFeature(ScriptInterpreter.java:141) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:901) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:864) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:223) ~[?:?]
	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:215) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:203) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:446) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:227) ~[?:?]
	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:215) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:203) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.evaluate(XbaseInterpreter.java:189) ~[?:?]
	at org.eclipse.smarthome.model.script.runtime.internal.engine.ScriptImpl.execute(ScriptImpl.java:82) ~[?:?]
	at org.eclipse.smarthome.model.rule.runtime.internal.engine.RuleEngineImpl.lambda$2(RuleEngineImpl.java:343) ~[?:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
	at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: java.io.IOException: error=13, Keine Berechtigung
	at java.lang.UNIXProcess.forkAndExec(Native Method) ~[?:?]
	at java.lang.UNIXProcess.<init>(UNIXProcess.java:247) ~[?:?]
	at java.lang.ProcessImpl.start(ProcessImpl.java:134) ~[?:?]
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) ~[?:?]
	... 33 more


It works​:+1::ok_hand:. Thank you very much!!!

I assume, it was a missing executable flag?

After I executed these commands, it went now

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

Hello, I would add a second lamp now. Do I have to supplement the rules.rules only with the second lamp?

Does a second script have to be made from hue_tradfri_color.sh as hue_tradfri_color1.sh?

Can you recommend a script editor for Mac?

Thanks a lot

Hello,
based on the workaround from ei_Gelb_Geek I created a script where it is possible to use the colorpicker. It’s not perfect, but in many cases the bulb takes on the color I picked in OH.
The script takes the HSB value as input, translates it into RGB, then XYZ and finally into xy.

#!/bin/bash

# -- $1 = Bulb ID -- $2 = HSB Value           

openhab_ip="192.168.xxx.xxx:80"
rest_api="yyy"     --api key 

#Functions
function round_down {
    echo $(printf %.$2f $(echo "scale=$2;(((10^$2)*$1))/(10^$2)" | bc))
};

function inverse_rgb {
    if (( $(echo "$1 < 0.04045" | bc -l) ));
    then
        echo $(bc <<< "scale=9; $1/12.92")
    else
        echo $(bc -l <<< "scale=9; e(2.4*l(($1+0.055)/1.055))")
    fi
};


#1 convert HSB to RGB
IFS=',' read -r -a HSBarray <<< "$2"

H=${HSBarray[0]}
S=${HSBarray[1]}
B=${HSBarray[2]}
    #echo "HSB:"$H, $S, $B

H=$(bc <<< "scale=9; $H/360")
B=$(bc <<< "scale=9; $B/100")
S=$(bc <<< "scale=9; $S/100")
    #echo "HSB:"$H, $S, $B

i=$(bc <<< "scale=9; $H*6")
i=$(round_down $i 0);
    #echo $i
f=$(bc <<< "scale=9; $H*6-$i")
    #echo $f
p=$(bc <<< "scale=9; $B*(1-$S)")
    #echo $p
q=$(bc <<< "scale=9; $B*(1-$f*$S)")
    #echo $q
t=$(bc <<< "scale=9; $B*(1-(1-$f)*$S)")
    #echo $t
icase=$(bc <<< "scale=0; $i%6")
    #echo $icase
case "$icase" in
"0")
    r=$B
    g=$t
    b=$p
    ;;
"1")
    r=$q
    g=$B
    b=$p
    ;;
"2")
    r=$p
    g=$B
    b=$t
    ;;
"3")
    r=$p
    g=$q
    b=$B
    ;;
"4")
    r=$t
    g=$p
    b=$B
    ;;
"5")
    r=$B
    g=$p
    b=$q
    ;;
esac
    #echo $r, $g, $b
R=$(bc <<< "scale=9; $r*255")
G=$(bc <<< "scale=9; $g*255")
B=$(bc <<< "scale=9; $b*255")
    #echo $R, $G, $B

#2 convert RGB to XYZ
    #2a Inverse sRGB Companding
r=`inverse_rgb $r`
g=`inverse_rgb $g`
b=`inverse_rgb $b`
#echo $r, $g, $b

    #2b RGB Matrix Calculation
m1[0]=0.4124564
m1[1]=0.3575761
m1[2]=0.1804375
m2[0]=0.2126729
m2[1]=0.7151522
m2[2]=0.072175
m3[0]=0.0193339
m3[1]=0.119192
m3[2]=0.9503041
rgb[0]=$r
rgb[1]=$g
rgb[2]=$b

X=0
for (( c=0; c<3; c++ ));
do
   X=$(bc <<< "scale=9; $X+${m1[$c]}*${rgb[$c]}")
done
Y=0
for (( c=0; c<3; c++ ));
do
   Y=$(bc <<< "scale=9; $Y+${m2[$c]}*${rgb[$c]}")
done
Z=0
for (( c=0; c<3; c++ ));
do
   Z=$(bc <<< "scale=9; $Z+${m3[$c]}*${rgb[$c]}")
done
    #echo $X, $Y, $Z

#3 convert XYZ to xy
x=$(bc <<< "scale=9; $X/($X+$Y+$Z)")
y=$(bc <<< "scale=9; $Y/($X+$Y+$Z)")
    #echo $x, $y
x="0"$x
y="0"$y

#4 Send via RestAPI
curl -s -H  "Accept: application/json" -X PUT --data '{ "on": true, "xy": ['"$x"','"$y"']}' http://$openhab_ip/api/$rest_api/lights/$1/state

2 Likes

Visual Studio Code is also for Mac btw … :wink:

I’m experiencing another issue, please, owners of the same Tradfri colour bulb + Hue hub, confirm.

If I change colors via Hue app, the Philips bulb maintains the selected color forever, the Tradfri bulb after a while changes automatically to white (as the bulb at a certain point in time from colour bulb becomes white bulb only … but if you change again the color via Hue app, no issues at all … till next “reset”).

Can you please double-check? idea is to set both Tradfri colour bulb and one Hue product with a color, then leave both lamps ON for a while.

Please let me know if you have the same issue.
thanks

Andrea

Hi,

yes I faced the exact same behaviour.

I always thought this was some kind of “power cut” that happenes in my electricity environment.
It is like you would just really shortly turn off the light.
When turning it off and on it is always just white.

Could someone check if this also happens with the tradfri bridge?

I didn’t see the same behavior with Tradfri bridge before … Actually, today I’ve tested again the issue, and never happened (at least in the last 5 hours).

mmm … :slight_smile:

I can confirm this behavior.

Just bought three Tradfri bulbs. The two color bulbs do not work with Hue. Firmware is 1.3.002

Hi guys,

now i bought a tradfri gatewa and a remote control and another new bulb. Now i am running OH 2.5 M2 and my bulbs are upgraded to firmware 1.3.009 and color control is working now.

Thomas