bokub / rgb-light-card

💡 A Home Assistant card for RGB lights
MIT License
419 stars 24 forks source link

Add support for multiple lights #16

Closed Fabenissimo closed 4 years ago

Fabenissimo commented 4 years ago

Hi!

I'm using your custom card since you've released it in HACS and it's great! I've got an idea I'd like to share with you.

Currently, I have three different lights in my entities-card. For each light I've got a row with my colour-presets below it. It looks something like this: image

In order to control the lights seperately I have to use your card for each of my lights - I could group them into a light group entity in HA but that would come with a drawback: If I would select a colour and only one light of that group is currently on it would turn on the other two lights as well.

The goal would be to only apply the colour to the lights that are currently on. That would mean to add support for multiple lights in the first place.

The configuration could look something like this:

type: 'custom:rgb-light-card'
justify: between
entities: 
  - light.stehlampe_zimmer_fabian
  - light.ambientebeleuchtung_fabian
colors:
  - rgb_color:
      - 255
      - 255
      - 255
  - rgb_color:
      ...

Second, it would be necessary to add an additional option that would control if the selected colour only should apply to the lights currently on or if it should apply to all lights that are configured under entites - alternatively you could assume the behaviour if one light entity is configured (apply the new colour to the light) or multiple light entites are configured (apply only to the entities that are on).

Third, I hide your card if the light is off but I assume many people use it to turn on their lights if they click on the card. Therefore it may be required if no lights of the configured entites are on to turn on all the configured lights uppon a press on the coulour presets.

I guess this would all be possible with a script, that I could call if I press on a button, but hey, you might want to add this to the core functionality of the card.

Let me know what you think of this feature request!

Fabian

bokub commented 4 years ago

Hi @Fabenissimo ,

I understand your need, but it's really too specific for that card

What my code currently does is nothing more than calling the light.turn_on service. It's really that dumb, and isn't even aware of the state of the lights

Adding your suggestion in the card would make it a lot more complex and it's not something that I want.

What I would do is, as you said, create a script that accept variables

Good luck 👍

casenjo commented 4 years ago

Hey @bokub I ran into this same issue just now. I wanted to add a panel to change the warmth of a group of lights. I ended up commenting out the following if statement from card.js:

        // If root entity is defined, it can only be a light
        if (config.entity && config.entity.indexOf('light.') !== 0) {
            throw new Error(`Entity '${config.entity}' must be a light`);
        }

This allowed me to set the entity as group.living_room_lights. As long as the group is entirely composed of lights, you're still able to use the light.turn_on service with it. @Fabenissimo this workaround could be useful for you :)

bokub commented 4 years ago

@casenjo You can also create a light group so it starts with light.