custom-cards / decluttering-card

🧹 Declutter your lovelace configuration with the help of this card
MIT License
386 stars 30 forks source link

Support the Entity card Toggle Header #23

Closed soloam closed 2 years ago

soloam commented 4 years ago

Hello I have created a decluttering card to simplify my RGB lights:

light_rgb_template:
  card:
    type: custom:slider-entity-row
    entity: light.[[light_name]]
    style: |
      :host {
        color: {% if is_state('binary_sensor.[[light_name]]_autoon', 'on') %} green {% endif %};
      }
    toggle: true
    min: 1
    max: 100
    step: 1 

Also tried the variant

light_rgb_template:
  card:
    type: custom:slider-entity-row
    entity: '[[entity]]'
    style: |
      :host {
        color: {% if is_state('binary_sensor.[[light_name]]_autoon', 'on') %} green {% endif %};
      }
    toggle: true
    min: 1
    max: 100
    step: 1

It works ok, but the "entities" card toggle header does not detect the entity and keeps the header switch off when the entity in the "decluttering-card" is on:

image

Is this possible?

Thamk You

RomRider commented 4 years ago

There's an ugly trick that should work (I checked how the code works on the entities card):

type: custom:decluttering-card
entity: light.test_light #this would be used by the entities card header
variables:
  - entity: light.test_light # this is for decluttering-card card
soloam commented 4 years ago

Thank you that solved it

Side question: I see that you are the maintainer of the Button-Card and Decluttering-Card, what is your road map? Do you plan to keep them side by side, or do you plan to merge them? The Button-Card contains a lot more features, even to templates (like for example the inline javascript), do you plan to bring them to Decluttering-Card?

Thank You

RomRider commented 4 years ago

The purpose of those 2 cards are not the same. I don't plan to merge them together. This card's purpose is to reduce the config size. An alternative is lovelace-gen though. I don't plan to add support for javascript template on this card, there's config-template-card for that.