Hue Binding, Trigger rule when Hue Scene is activated (from outside of openHAB)


is there a way to “know” whenever a Hue scene is activated (from the Hue app, from an API call, etc.)?

What I’m trying to do: I have a Hue Dimmer switch, which I can use to start different scenes (scene 1 on first button1 press, scene 2 on second button1 press etc.). I now also have an IKEA Tradfri Dimmer switch connected via deconz to openHAB. Using a rule I have been able to use the IKEA switch to trigger one of the scenes, and to turn off the group of lights as well:

rule "tradfri remote handling"
   Channel "deconz:switch:098eb93ebf:bc33acfffe2c8fff011000:buttonevent" triggered
    logInfo("TradfriRemote", "Tradfri switch event {} was triggered", receivedEvent)
    switch(receivedEvent) {
        case "1002": {
            var String response;
            response = sendHttpPutRequest("", "application/json", '{"scene": "Y4jV2IW6IqVw82X"}', 3000)

        case "2002": {
            var String response;
             response = sendHttpPutRequest("", "application/json", '{"on": false}', 3000)


I would now like to be able to toggle through the scenes that I configured for the five “button1 presses” for the Hue dimmer switch, but if possible I would like to know which scene is currently “active”, to know which one’s the next scene.

I hope my questions makes some sense. :smiley:

Why not trigger directly on the button-press (1 to 5)?

What do you mean?

You use the Hue switch to activate a scene and then want to catch the scene in OH to do something with it (or do I misunderstood).

Why not use the input from the switch right away?

Ah, ok, I understand.

Yea, but the thing is that if someone uses the Hue app for example to trigger a scene, I won’t know about it in openHAB and therefore can’t act upon that information. I would like for openHAB to know which scene is currently active and when I then use that IKEA switch I would like to be able to trigger “the next scene in line” on the press of that button.

But I guess it might be overkill anyway. I might just start at the first scene when I press the IKEA button and then cycle through the scenes no matter what the current scene is.

I’m guessing you have the Hue Dimmer switch connected to a Hue Hub and set it using the Hue App. I would change this so that the Hue Dimmer Switch is connected to OpenHAB and you use a rule to detect the key presses. You would be triggering the scene using OpenHAB for both dimmer switches and as such can create an Item to hold the current scene name. Your rule can read this value, switch it to the next scene and update the item.

1 Like

Ok, but what about if someone uses the Hue app? openHAB won’t know the scene state then either.

Also what about the dimming feature on the Hue Dimmer, do I get that to work via openHAB as well?

I will make one possible solution by answering your original question

If you are using your Hue lights with a Hue hub, then yes, there is an API, it is built into the hub. It is a REST API that works with normal HTTPS calls. openHAB could be used to poll the API using the HTTP binding/action. I believe I remember learning about using from a thread on this very forum but google Hue API, follow links to Hue developer web site to learn more

I do use the Hue bridge, but haven’t found a way there either.

There is a new API in development which brings push functionality to the Hue API. Maybe it will be easier to get status updates with it.

You would basically stop using the Hue App since everything would be controlled by OpenHAB.

you could link items to the color loop of each bulb and compare them to the numbers of known scenes. could be a stop gap until you get what you really want