# Different "Light-Scenes" using a Hue Dimmining Switch

**URL:** <https://community.homey.app/t/different-light-scenes-using-a-hue-dimmining-switch/1545>\
**Category:** Questions & Help\
**Created:** [September 11, 2018, 5:52pm UTC](https://community.homey.app/t/different-light-scenes-using-a-hue-dimmining-switch/1545 "2018-09-11T17:52:40Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Seraphim](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/seraphim/32/8879_2.png) [@Seraphim](https://community.homey.app/u/Seraphim)\
**Post date:** [September 11, 2018, 5:52pm UTC](https://community.homey.app/t/different-light-scenes-using-a-hue-dimmining-switch/1545/1 "2018-09-11T17:52:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![viix](https://avatars.discourse-cdn.com/v4/letter/v/4af34b/32.png) [@viix](https://community.homey.app/u/viix)\
**Post date:** [September 11, 2018, 6:42pm UTC](https://community.homey.app/t/different-light-scenes-using-a-hue-dimmining-switch/1545/2 "2018-09-11T18:42:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Seraphim](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/seraphim/32/8879_2.png) [@Seraphim](https://community.homey.app/u/Seraphim)\
**Post date:** [September 11, 2018, 6:47pm UTC](https://community.homey.app/t/different-light-scenes-using-a-hue-dimmining-switch/1545/3 "2018-09-11T18:47:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Herman\_Andersen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/herman_andersen/32/11526_2.png) [@Herman\_Andersen](https://community.homey.app/u/Herman_Andersen)\
**Post date:** [September 12, 2018, 10:46am UTC](https://community.homey.app/t/different-light-scenes-using-a-hue-dimmining-switch/1545/4 "2018-09-12T10:46:47Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Eternity](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/eternity/32/102113_2.png) [@Eternity](https://community.homey.app/u/Eternity)\
**Post date:** [September 12, 2018, 11:20am UTC](https://community.homey.app/t/different-light-scenes-using-a-hue-dimmining-switch/1545/5 "2018-09-12T11:20:36Z")

</div>

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.

> **[Hacking a Fibaro double relay switch (FGS-222) =\> multiple tapping](https://forum.athom.com/discussion/4140/hacking-a-fibaro-double-relay-switch-fgs-222-multiple-tapping)**
>
> Sorry for the weird discussion title, hope my explanation makes my question more clear!

---

<div class="post-metadata">

**Author:** ![Seraphim](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/seraphim/32/8879_2.png) [@Seraphim](https://community.homey.app/u/Seraphim)\
**Post date:** [September 12, 2018, 8:29pm UTC](https://community.homey.app/t/different-light-scenes-using-a-hue-dimmining-switch/1545/6 "2018-09-12T20:29:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jamie](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jamie/32/5274_2.png) [@Jamie](https://community.homey.app/u/Jamie)\
**Post date:** [September 13, 2018, 2:27am UTC](https://community.homey.app/t/different-light-scenes-using-a-hue-dimmining-switch/1545/7 "2018-09-13T02:27:03Z")

</div>

Care to share your HomeyScript?

---

<div class="post-metadata">

**Author:** ![Seraphim](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/seraphim/32/8879_2.png) [@Seraphim](https://community.homey.app/u/Seraphim)\
**Post date:** [September 13, 2018, 4:47am UTC](https://community.homey.app/t/different-light-scenes-using-a-hue-dimmining-switch/1545/8 "2018-09-13T04:47:35Z")

</div>

Hello Jamie,

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

[HomeyScript for Light in KidsRoom](https://www.dropbox.com/s/tt0mtb9p5097pab/HomeyScript%20-%20Light%20-%20KidsRoom%20-%20HDS%20Pressed%2C%20on.txt?dl=0)

Regards  
Andreas

---

<div class="post-metadata">

**Author:** ![Herman\_Andersen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/herman_andersen/32/11526_2.png) [@Herman\_Andersen](https://community.homey.app/u/Herman_Andersen)\
**Post date:** [September 13, 2018, 6:22am UTC](https://community.homey.app/t/different-light-scenes-using-a-hue-dimmining-switch/1545/9 "2018-09-13T06:22:41Z")

</div>

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.  
🙂

---

<div class="post-metadata">

**Author:** ![Seraphim](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/seraphim/32/8879_2.png) [@Seraphim](https://community.homey.app/u/Seraphim)\
**Post date:** [September 13, 2018, 6:55am UTC](https://community.homey.app/t/different-light-scenes-using-a-hue-dimmining-switch/1545/10 "2018-09-13T06:55:56Z")

</div>

🙂

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

---

<div class="post-metadata">

**Author:** ![Herman\_Andersen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/herman_andersen/32/11526_2.png) [@Herman\_Andersen](https://community.homey.app/u/Herman_Andersen)\
**Post date:** [September 13, 2018, 1:30pm UTC](https://community.homey.app/t/different-light-scenes-using-a-hue-dimmining-switch/1545/11 "2018-09-13T13:30:49Z")

</div>

THx for the explanation,!
