I am trying to dim my hue lights using openHab on a Synology based on the time of day.
What I did was:
Creating an astro binding
Creating a bulb switch in the items
Saving a DAY and NIGHT state according to this pattern
writing a rule like this:
rule "Hue DG switched on"
when
Item FlurDG_Toggle changed from OFF to ON
then
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")
FlurDG_Dimmer.sendCommand(65);
}
if(vTimeOfDay.state == "NIGHT"){
// dimm the light to Nightlight
logInfo(filename, "Hue DG was switched on and it is currently NIGHT")
FlurDG_Dimmer.sendCommand(10);
}
end
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%.
Perfect.
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
I switch on the physical switch to power the light
It takes around 3 seconds until the hue bridge shows the light as âonâ in the hue app
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.
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âŠ
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
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
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?
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?
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"
when
Item LivingRoom_WallSwitch changed
then
if (LivingRoom_CeilingLight.state == OFF) { // if OFF then turn ON
LivingRoom_CeilingLight.sendCommand(ON)
}
else if (LivingRoom_CeilingLight.state == ON) { // if ON then turn OFF
LivingRoom_CeilingLight.sendCommand(OFF)
}
else { // if changed to UNDEF or NULL then turn OFF - Safety feature
LivingRoom_CeilingLight.sendCommand(OFF)
}
end
Of course this is for a simple ON/OFF bulb but you can adapt the code to a dimmable light
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"
when
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 "* * * * * ? *"
then
// do the dimming and updates of switches
end
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.