Different "Light-Scenes" using a Hue Dimmining Switch

Hello Community,

for my daughters room I am trying to create some flows for different “light scenes”. Well, the scenes are not really the problem, of cause. I want to trigger these flows by using a Hue dimming switch.

The Setup:
1x Dimming Switch
3x White Ambiance lights

The Plan:
Power on pressed for the first time: first bulb goes on with 1% dimmlevel
Power on pressed the second time: first and second bulb are on with 1% dimmlevel
Power on pressed the third time: first, second and third bulb are on with 1% dimmlevel
Power on pressed the fourth time: all three bulbs go on dimmlevel 25%
Power on pressed the fifth time: all three bulbs go on dimmlevel 50%
Power on pressed the sixth time: all three bulbs go on dimmlevel 100%
Power of pressed: all bulbs go off

I have tried to realise this with Better Logic. Each time the power on button is pressed I increment a variable by 1.
For each state of the variable I created a flow.

E.g.:
If variable = 1 than power on bulb 1
If variable = 2 than power on bulb 1 + 2
and so on.

Problem:
If I press power on 4 times (variable = 4) Homey tries to work on what I told him in state 1, 2 and 3 (for sure he does because the variable had 1, 2 and 3 when the variable changed or was set) while he is working on state 4. So, I have a litte mess in the lighting.

Do someone has a similar issue and found a solution for that? Or simply could help with the error in my logic?

Regards
Andreas

Are you saying u want to press 4 times without homey running the scenes no. 1 to 3?

Maybe you can set the first flow
Dimmer switch - increment variable + start countdown timer (example called dimmer.light to 2sec)

Then a few flows for each variable, trigger by dimmer.light countdown is 0?

So when dimmer.light countdown is zero, and variable is 2, set 2 bulbs to 1%

It will work but u need to wait 2 secs for light to come on.

Hello Viix,

I also thought about such a solution but waiting up to two seconds for light could be a long time (especially in a kids room), so I stopped thinking about this.

Thank you

WHEN POWER ON = pressed AND first bulb = on with 1% dimmlevel THEN Second bulb on with 1%DIM lvl

If you do this for every press i think it should work.

For the 4th time The check AND should be If first second and third bulb are on 1% dimlvl, and the THEN: set all three bulbs at 25%, grouped in a virual device so you can send 1 command to all three at once.

For the 5 th and 6 th same but with other AND statements

Good luck!

In the old forum I posted my flows ‘hacking a Fibaro fgs-222’ which you might find helpful to create yours.

It allows me to select various Hue scenes with one button of the switch, using a timer and some variables.

Please read the entire post, as I added some comments later on.

Hello Herman_Andersen,

thanks for your hint. The logic itself worked, but there are some big delays using this in a flow, so I had to program it in HomeyScript, now it works really fantastic. Thanks once more.

Regards
Andreas

Care to share your HomeyScript?

Hello Jamie,

please find my script attached. It’s not a perfect one, but it works for me.

HomeyScript for Light in KidsRoom

Regards
Andreas

glad i could help, that script looks complicated! But i think i have to go learn that if it speeds up things, the faster the better not?
Thx for sharing that.
:slight_smile:

:slight_smile:

Good morning Herman_Andersen,

Cause it’s your logic you should understand it really fast and if you did so it’s not really complicated.

Step1: Fetch the devices you want to talk to.
let DGKZHWAB101Decke = await Homey.devices.getDevice({id: ‘baaddfce-166e-446c-afed-413dc55d1ae9’});

let DKZ… names the variable
await Homey.dev… fetches the device with the ID in the brackets. (here you have to put in your device ID)

Do this for all devices you want to control with your script.

Step2: Start your If-Then-Else
if (DGKZHWAB101Decke.state.onoff==false && DGKZHWAB102Decke.state.onoff==false && DGKZHWAB103Decke.state.onoff==false) {

the first thing happening is to check the state of the devices to declared with a variable.
In my case I checked if they are on or off

If they are all off I started this one:
DGKZHWAB101Decke.setCapabilityValue(‘dim’, 0.01);
DGKZHWAB101Decke.setCapabilityValue(‘light_temperature’, 0.86);

Dim first light to 0.01 and set the light_temperature to 0.86

Step3: Go on with your If-Then-Else for all states you different devices could have.
else if(DGKZHWAB101Decke.state.onoff==true && DGKZHWAB101Decke.state.dim==0.01 && DGKZHWAB102Decke.state.onoff==false && DGKZHWAB103Decke.state.onoff==false) {
DGKZHWAB102Decke.setCapabilityValue(‘dim’, 0.01);
DGKZHWAB102Decke.setCapabilityValue(‘light_temperature’, 0.86);

In this part the dim level of the first light is checked, too.
From this point it’s a simple copy an paste thing.

There may be a much more elegant way to write this script (maybe with Switch-Case, and with a more automated fetching of the devices by room and type) but this worked for me and was written in a few minutes.

Regards
Andreas

2 Likes

THx for the explanation,!