Rule for dimmer when physical button is pushed


I have an IHC system, where I control one Hue bulb.
I have a physical button wired with to the IHC system, so when I push this, the Hue bulb turn off or turn on.
I have implemented this, with a code block in the IHC system (to update the status for IHC etc.) and a rule in OH. This is working well and is pretty simple.

But with my normal dimmers in IHC, it is possible to push and hold the button and the light begins to increase or decrease in brightness. I have prepared a code block in the IHC system, which will set an item (light_increase) state = 1, when the bulb has to increase brightness and when button is release the increase in brightness will stop, because the item state change to 0. If you push and hold the button again, another item (light_decrease) will change state = 1 and when button is release it would change to state = 0.

So I need to configure two rules (one for increase and one for decrease), that while an item state = 1, it should adjust the hue bulb brightness 2% (increase or decease) each 0.2 seconds (or something like this - depends on the reaction time with hue etc).

The bulb is a color bulb (0210)

Looking forward to hints, which can help me get started with this rule.

Best Regards,

Your best bet is to repeatedly send the 1 states while the button is pressed. OH doesn’t have the concept of “keep running this rule while an Item is in a given state”. Instead, rules trigger based on events.

So the easiest would be if you can cause your IHC to send the 1 to OH say every half second while the button is pressed. On each event OH can increase/decrease the brightness by a set amount.

Otherwise, you will need to implement a rule that runs every second no matter what and checks if the dimmer up or dimmer down Item is 1 and if so increase/decrease as appropriate.

Okay - that makes sense - thanks!

I need to get the current brightness every time I OH receive a pulse to increase brightness. This pulse will happen every 0.2 second, so is there something smart I can do, to save the current state in the “rule” and not needing to get it every time from the Hue bulb or will this not be a problem?

That isn’t how OH works. It doesn’t have to “ask” the Hue bulb what it’s current dimmer value is. When OH tells the bulb to change OH remembers what it changed to. When the Hue bulb is changes some other way (e.g. a phone app or a wall switch) the bulb tells OH about the change. The Item stores the state. If it had to ask the bulb itself every time an Item is used the whole system would come to a halt waiting for wireless messages to be processed. So this isn’t a problem.

However, 0.2 seconds is going to be really fast for OH and definitely too fast for the Hue bulb to respond to. You risk losing lots of messages and potentially crashing your Hub with commands at that rate. I wouldn’t try anything faster than .5 seconds with 1 second being more reasonable when dealing with any sort of wireless tehcnology that isn’t wifi.

1 Like

Thanks for a good explanation to a rookie.

I will do some testing and update later regarding delay time etc!

Hi Kristoffer,
I’m a newbie in openhab…
I’m trying to doing the same rules, with the only difference being my physical button is wired with a DI of ModBus device.
Please, would you be so kind to share your solution?
Thank you very much,
Best regards

Please don’t multiple copies of same question.