# How to choose which lights are on

**URL:** <https://community.homey.app/t/how-to-choose-which-lights-are-on/112715>\
**Category:** Questions & Help\
**Tags:** flow\
**Created:** [July 11, 2024, 8:18am UTC](https://community.homey.app/t/how-to-choose-which-lights-are-on/112715 "2024-07-11T08:18:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![LEE\_Tackzun](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/lee_tackzun/32/83692_2.png) [@LEE\_Tackzun](https://community.homey.app/u/LEE_Tackzun)\
**Post date:** [July 11, 2024, 8:18am UTC](https://community.homey.app/t/how-to-choose-which-lights-are-on/112715/1 "2024-07-11T08:18:14Z")

</div>

I have about 80 hue lights.

I want to control which of these lights are turned on.

for example  
Brightness of lights that are turned on  
Color temperature of lights that are turned on  
The color of the lights that are turned on  
I want to control the above action using the hue tap dial.

I think it would be possible if I could specify this “light that is on” with logic. Is there a way?

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [July 11, 2024, 8:25am UTC](https://community.homey.app/t/how-to-choose-which-lights-are-on/112715/2 "2024-07-11T08:25:04Z")

</div>

So…this AND card?

![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/f/6/f6c57f0189a35363133b2557c29da42e0b03d287.png)

---

<div class="post-metadata">

**Author:** ![LEE\_Tackzun](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/lee_tackzun/32/83692_2.png) [@LEE\_Tackzun](https://community.homey.app/u/LEE_Tackzun)\
**Post date:** [July 11, 2024, 8:57am UTC](https://community.homey.app/t/how-to-choose-which-lights-are-on/112715/3 "2024-07-11T08:57:28Z")

</div>

Are there too many cards??

---

<div class="post-metadata">

**Author:** ![DirkH](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkh/32/78952_2.png) [@DirkH](https://community.homey.app/u/DirkH)\
**Post date:** [July 11, 2024, 9:38am UTC](https://community.homey.app/t/how-to-choose-which-lights-are-on/112715/4 "2024-07-11T09:38:49Z")

</div>

Hi @LEE_Tackzun ,  
I guess there is an elegant possibility in Homey Script, which I did not yet started to look at.  
As there are no _FOR_ loops in (advanced) flows, the easy way would be in Advanced Flow.  
\*WHEN… \* started manually or at certain times, eg by CronJob  
_THEN…_ _Set_ _ **MyLightsOn** _ _to_ " "  
_AND…_ _ **Light1** _ is **ON** _THEN…_ _Set_ _ **MyLightsOn** _ _to_ _ **MyLightsOn** _ " , Light1"  
… for every Light you want to check.  
Then you have a text variable with all lights that are on at that specific time.

Hope that helps

---

<div class="post-metadata">

**Author:** ![staeff](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/staeff/32/79712_2.png) [@staeff](https://community.homey.app/u/staeff)\
**Post date:** [July 11, 2024, 10:00am UTC](https://community.homey.app/t/how-to-choose-which-lights-are-on/112715/5 "2024-07-11T10:00:43Z")

</div>

If you really want to control potentially 80 lights probably running a HomeyScript is the easiest solution:

```js
// provide with argument in the format in the default value below
const { dim, color } = JSON.parse(args[0] || '{ "dim": 0.5, "color": null }');

const devices = await Homey.devices.getDevices();

const lights = Object.values(devices).filter(d => d.class === "light");

lights.forEach(async (light) => {
  // ignore lights which are turned off
  if (!light.capabilitiesObj.onoff.value) {
    return;
  }

  // if light is dimmable set to target dim value
  if (dim >= 0 && light.capabilities.includes("dim")) {
    await Homey.devices.setCapabilityValue({
      deviceId: light.id,
      capabilityId: 'dim',
      value: dim
    });
  }

  // TODO: something similar for color
});

```

---

<div class="post-metadata">

**Author:** ![LEE\_Tackzun](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/lee_tackzun/32/83692_2.png) [@LEE\_Tackzun](https://community.homey.app/u/LEE_Tackzun)\
**Post date:** [July 11, 2024, 11:38am UTC](https://community.homey.app/t/how-to-choose-which-lights-are-on/112715/6 "2024-07-11T11:38:07Z")

</div>

For me, scripting is too difficult an approach.

Can you tell me how to apply this?

---

<div class="post-metadata">

**Author:** ![staeff](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/staeff/32/79712_2.png) [@staeff](https://community.homey.app/u/staeff)\
**Post date:** [July 11, 2024, 12:11pm UTC](https://community.homey.app/t/how-to-choose-which-lights-are-on/112715/7 "2024-07-11T12:11:54Z")

</div>

I probably would create a flow like below. This basically adds the brightness for all turned on devices by 10% or sets it to 100% depending on what you are pressing on the remote.

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/a/1/a107cdb4ab9fa0a03cd0f4152541da286758d22f.png)

with the following script:

```auto
// Change dim of on lights
let change = 'absolute';

if (args[0].startsWith("+") || args[0].startsWith("-")) {
  change = 'relative';
}

const dim = Number(args[0]);

const devices = await Homey.devices.getDevices();

const lights = Object.values(devices).filter(d => d.class === "light");

lights.forEach(async (light) => {
  // ignore lights which are turned off
  if (!light.capabilitiesObj.onoff.value) {
    return;
  }

  // if light is dimmable set to target dimvalue
  if (light.capabilities.includes("dim")) {
    if (change === 'absolute') {
      await Homey.devices.setCapabilityValue({
        deviceId: light.id,
        capabilityId: 'dim',
        value: Math.min(Math.max(dim, 0.01), 1)
      });
    } else {
      await Homey.devices.setCapabilityValue({
        deviceId: light.id,
        capabilityId: 'dim',
        value: Math.min(Math.max(light.capabilitiesObj.dim.value + dim, 0.01), 1)
      });
    }
  }
});

```

As an alternative have you thought about just creating different moods in which you define what lights should be in which state (power, brightness, color) and just switch between the moods when pressing on your remote?

[Introducing Moods | Homey News](https://homey.app/en-at/news/introducing-moods/)

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [July 11, 2024, 2:00pm UTC](https://community.homey.app/t/how-to-choose-which-lights-are-on/112715/8 "2024-07-11T14:00:59Z")

</div>

Not a direct solution I think, but worth a try: [Light Triggers](https://homey.app/en-nl/app/com.trigger.lights/Light-Triggers/) app
