Using Hue ONLINE / OFFLINE Events in rules

Recent updates (Spring 2017) have allowed using Thing Status Info changes in rules. I was able to use these new features to fix a lighting problem in my Frankenhouse (the light switch only controlled 1 electrical outlet, the others are always on). Using hue lights with the below rules, I now have lights responding to the physical switch (where they weren’t responding before).

Note: that there can be a delay of about a minute between flipping the switch, and having all the lights turn on / off.
Note: You’ll need to pull the thing’s id from Paper UI (or from /userdata/logs/events.log).

rule "Turn on/off Library light"
		Thing "hue:0210:288baea3:6" changed
		var status = ThingAction.getThingStatusInfo("hue:0210:288baea3:6").getStatus()
		//logError("Debug", "Library Rules | " + status)
		if (status.toString() == 'OFFLINE')
			//logError("Debug", "Attempting to turn off light")
		else {

Further reference:


that is awesome - thank you.

Is it possible to use this approach to check all the Things for any that are offline, without having to list them individually?


The Thing status is detected but it is not working all the time :frowning:

In the stable OH version I was able yo follow the Online/Offline status in the Thing section and it worked very responsive … doing the same now in the latest Snapshot I have delays in the Online/Offline status in the Thing section.

Its a step in the right direction but not working reliable :wink:

Anybody with similar experience ?

I am using this with my Z-Wave bulb and here the Thing is only going OFFLINE if the gateway tries to contact the bulb but it didn’t answer within 10 seconds.

If I don’t send any commands at all to the bulb after cutting the power, it stays ONLINE until the gateway tries to pull a status from it (which is every 10 minutes in my setup). So this is very expected and correct behaviour IMHO.

I have a dimmable Z-Wave bulb in a simple relay-microwave-lamp, so it will cut the power when there is nobody in the room. I use the ONLINE OFFLINE state to detect presence in that room and power on/off the wall panels.

1 Like

I haven’t looked into that use case at all. If there is a way to get all of your thing’s ids then I suppose you could do it in a loop. Note that I’m still relatively new to openHab, and am hacking my way through problems as I run into them.

There is definitely a delay between the online/offline switch, and the responsiveness of the rule. In my brief testing I’ve seen it take up to 1 minute before the second light responds … which was good enough for my purposes.

Hi there,

not sure if it’s the right place to post this question, but I can’t get this to work.

The rule is triggered whenever the Thing status changes, which if fine, however as soon as I try to read the status via

var status = ThingAction.getThingStatusInfo(...)

it results in a null reference error…

Is there anything I need to import?

I tried several import statements but the Designer rejects all of them.

Any help is appreciated!


One reason why it’s null is because the thing got removed. Thus it doesn’t exist and there is not status.

Hi Markus,

I am not sure if you have to prepend the ThingAction part in front of the getThingStatusInfo(...) method call. The documentation doesn’t use it (see It is also recommended to check for null on the getThingStatusInfo(...) result before trying to access the real status value.

I did an in-depth analysis of the reliability of the Thing status of hue bulbs by comparing the Thing status with a regular call of the Hue bridge. From the Hue bridge, I got the JSON description of the bulbs and their status. Of the 26 bulbs I have installed, at least two or three have a wrong status: the Thing shows online, while according to the Hue Bridge / JSON the bulb is not reachable. Given this, I am not sure how I could help solving the problem. Maybe with the script I created for this analysis?

were you able to solve the delay problem in the meanwhile?

I am trying to dim my hues after turning them on using the physical switch. Using your ruleset I am able to have my physical switches in sync with the virtual switch Items.
But the delay is a problem. Turning the lights on at night in full brightness and having to wait ages until the rules are executed and the lights dimmed down is pretty useless.