Adapting brightness of Hue lights after physical switch button press

Dear community,

I am trying to dim my hue lights using openHab on a Synology based on the time of day.

What I did was:

  1. Creating an astro binding
  2. Creating a bulb switch in the items
  3. Saving a DAY and NIGHT state according to this pattern
  4. writing a rule like this:

rule "Hue DG switched on"
    Item FlurDG_Toggle changed from OFF to ON
    logInfo(filename, "Hue DG was switched ON")

    if(vTimeOfDay.state == "DAY"){
        // turn on usual bright light
        logInfo(filename, "Hue DG was switched on and it is currently DAY")


    if(vTimeOfDay.state == "NIGHT"){
        // dimm the light to Nightlight
        logInfo(filename, "Hue DG was switched on and it is currently NIGHT")


Now, the logic works perfectly fine if I do all the action using the WebInterface were I trigger the switch directly to turn the light ‘on’ and ‘off’. Depending on the DAY or NIGHT String it dimms the light to 10% or 65%.


My problem now is that this does not work at all using the physical switch for the light.

My understanding is this - starting with the light off

  1. I switch on the physical switch to power the light
  2. It takes around 3 seconds until the hue bridge shows the light as ‘on’ in the hue app
  3. after some additional seconds (3-6) the switch in the openHab UI is updated even though the pollingInterval on the bridge setup is set to 1s.
  4. afterwards the rule executes and dimms down

Now the first problem ist that it takes very long for the rule to execute taking all these things into account.
But the bigger problem is that it only works once. Because when I shut down the lights using the physical switch again: the light is off of course because there’s no power. The Hue bridge still shows the light as ‘on’ but ‘not reachable’. Therefore the openHab switch does not get the correct state. Activating the power again therefore has no effect because the openHab switch is still in state ‘on’.

Any ideas how to “map the physical switch to a real time virtual switch” using the Hue bridge?

You might monitor thing-based-triggers to set your bulb item to OFF when the bulb-thing goes offline, see:

When yor bulbs are re-appearing online, then you might send the desired dim level.
Sure, the HUE bulbs will light up with 100% after power up before they receive your dim command resulting in some flicker.

Btw.: I use Ikea TRADFRI bulbs in such cases for a simple reason: They store the last dim level at power down and restore that dim level at next power up. I use them with the native Zigbee binding but they should work with the HUE bridge too…

1 Like


You partially can solve you problem with the Hue APP.

Go to Hue APP --> settings --> “switch-on behavior”
–> choose your bulb --> either --> “Power failure behavior” or “User defined”.

Does this include dim level and color temperature?
Can you set it to “restore level/color as it was on power loss”?

No, you are able to set this behavior with the Hue APP. See post above.

Yes, you can.


EDIT: If you have original Hue bulbs, or other manufacturers are supporting this feature, (e.g. the latest firmware?).

1 Like

Good to know :wink:

This power on behaviour must be stored in the bulbs since the bulb “has to know” it immediately after power up and before it has established it’s connection to the bridge.
I guess, this setting gets lost when deleting it from the bridge and joining to the native Zigbee binding -unfortunately :frowning:

I’ve tried this one day with OSRAM bulbs on the Lightify gateway. At least with them the power on setting did not “survive” the re-join. Should try this with my HUE’s too…

Since I prefer the Zigbee binding to get rid of the zoo of bridges, the IKEA bulbs seem to fit my needs in that corner case best at the moment…

Well, that’s OT. Sorry for that.
Anyway: Thank’s for making me aware of the power-on-behaviour feature at HUE :+1:

1 Like

Do you in general think that it might speed up if I remove the Hue bridge and instead add a Zigbee USB Stick to my Synology NAS?

I am going to check that.

yes partially that is true. The problem about the “Power failure behavior” is that the bulb needs 7 sec to remember its state. If you shut it down before it will simply shine in 100% brightness again after turning it on.

The problem about the “User defined” setting is that it only solves 50% of my problem. Either I have dimmed light at night or bright light at day time.


What about setting up two routines in Hue App. One for DAY and one for NIGHT. The duration 1 minute, in the beginning of each period?
But you have to create two scenes also. One for 10% dimming and one for 65% dimming.

I thought routines are just time based triggers assuming the power supply is on at the bulb. Would this really work switching on and off the physical switch so that it, depending on time, applies the choosen scene?

I‘ll try that tomorrow.


If you ALWAYS switch on/off your bulb with the physical switch, then it would not work with duration 1 minute. But you can try the following. Set up two routines, one for DAY (e.g. 12 hours, 65 %) and one for NIGHT (e.g. 12 hours, 10%). Then switch off/on your physical switch and wait if Hue Brigde is remembering the routines.

sadly not working. Doesn’t matter what I configure in the routine. It does not apply it when I turn on the physical switch.

ok that solves my first problem. I am able to have the status of the bulb in sync with my switch Item.

Therefore the only problem remaining is the huge delay in the status updates.
Does somebody have experience with a Synology openHab setup using a Zigbee Stick?
Maybe skipping the HUE bridge and connecting directly with the Stick improves performance?

I just did a quick test: Switching on a OSRAM Lightify Surface (Zigbee ceiling lamp) and observed the thing status.

It needed aprx. 4 seconds until the thing changed to ONLINE.

Zigbee binding 2.5M2
Coordinator EM35x (Bitron Video 902010/26)

Not sure, if this “quick enough” for your need…

The best way to solve the problem once and for all would be to leave the light bulb power always on by bypassing the switch and replace the physical switch with a hue or other remote (openHAB linkable) switch.

This way your light bulb is always online and will aboy an openHAB command almost instantly and you instruct openHAB to turn the light bulb on of off with a rule a bit like this:

rule "Living Room Wall Switch"
    Item LivingRoom_WallSwitch changed
    if (LivingRoom_CeilingLight.state == OFF) {  // if OFF then turn ON
    else if (LivingRoom_CeilingLight.state == ON) { // if ON then turn OFF
    else { // if changed to UNDEF or NULL then turn OFF - Safety feature

Of course this is for a simple ON/OFF bulb but you can adapt the code to a dimmable light

1 Like

that sounds pretty good for the long term setup.

I am a bit confused because the 1s pollingInterval might not have an impact at all in my setup or I am doing it wrong.

Bridge hue:bridge:1 [ ipAddress="x.x.x.x", userName="x", pollingInterval=1] {

If I just do the naive and ugly approach of adding a 1s cron to my rule I am close to instant rule execution with correct status of my bulbs and correct dimming.

rule "Hue hall Things status change - update related switches and dimm lights according to day time"
    Thing "hue:0100:1:bulb_hall_keg2" changed or
    Thing "hue:0100:1:bulb_hall_egog1" changed or
    Thing "hue:0100:1:bulb_hall_egog2" changed or
    Thing "hue:0100:1:bulb_hall_ogdg1" changed or
    Thing "hue:0100:1:bulb_hall_ogdg2" changed or
    Thing "hue:0100:1:bulb_hall_dg" changed or
    Time cron "* * * * * ? *"
// do the dimming and updates of switches

EDIT: that was just a lucky timeframe - it is not very responsive doing further tests. The Hue bridge seems to be a bottleneck here definitely. The “unreachable” status in the Hue app is also delayed hard.

Yes, and you will never be able to shorten this delay.

What about my proposal, setting up a “switch-on behavior” in Hue APP? --> Power Failure = restore last color and brightness.
If it’s not stored in the bulb and it also needs a connection to the Hue Brigde, then the bottleneck will be the same. If it’s stored in the bulb, then it could be quicker. Did you try out?

@Celaeno1 tried that yes but without success. As mentioned it takes 7 seconds to “save and remember” the state. I would need to shutdown the bridge to identify where the info is stored I guess. Not at home right now.

Greetings from upper bavaria :stuck_out_tongue:

Greetings back from Lower Franconia :smile: