custom-cards / button-card

❇️ Lovelace button-card for home assistant
MIT License
1.93k stars 233 forks source link

Create a button for each (hue) scene for a specific light? #687

Closed GD-Dal closed 1 year ago

GD-Dal commented 1 year ago

Not sure if this is a feature request, or just some error in the configuration. I have several hue lights. Each hue light has hue scenes attached to it. But the amount of scenes, types of scenes, etc varies for every light. The goal here is to create a button card for each light. The card will contain a button for each scene that specific light has. This means that the card has to be populated automatically. Using templates?

I have tried several things but:

I have created a template sensor looking like this:

- platform: template sensors: kontor_hr_scenes: friendly_name: "Kontor HR Scenes" value_template: "{{ state_attr('light.kontor_hr', 'hue_scenes') }}

This produces an output like this: image

So to the card: I have tried this approach:

entity: light.kontor_hr
name: Kontor HR Scenes
show_state: false
show_name: true
state:
  - operator: default
    value: 'unavailable'
  - operator: template
    value: >
      [[[ return states['sensor.kontor_hr_scenes'].state.split(','); ]]]
tap_action:
  action: call-service
  service: hue.activate_scene
  service_data:
    group_name: "Kontor HR"
    scene_name: >
      [[[ return trigger.entity_id.split('_')[-1].strip() ]]]
hold_action:
  action: more-info

But it produces just one button. and that button does nothing.

Is it possible to achieve this? Or is it necessary to create a sensor template first?

Thanks

Mariusthvdb commented 1 year ago

please close and move to the community. this not an issue/bug.