How to turn on these dimmed LEDs using one script for all?

I have several lights, grouped as primary and secondary. Some of them are dimmable led spots, and some are regular non-dimmable lights.

Dimmables and non-dimmable are mixed in the groups.

The dimmable spots are connected six in each group, and these led spots need eg. brightness: 50 to make them all light. If turning them on at a lower brightness all will not light properly, only one or two out of the six. This is due to some power technicality this is not related to the Fibaro dimmers or Home Assistant.

To get past this issue, I figured I need a script to turn the lights on, making sure they all turn on properly by putting in a delay of 3 seconds before dimming them down to brightness: 5.

script:
  lys_grunnbelysning_on:
    alias: "[House] - Turn on interior light"
    sequence:
      - service: light.turn_on
        data:
          entity_id: light.lys_grunnbelysning_dimbare
          brightness: 50
          transition: 1
      - delay: 3
      - service: light.turn_on        
        data:
          entity_id: light.lys_grunnbelysning_dimbare
          brightness: 5
          transition: 1

My question is:
How can I make this pattern for turning the dimmable on more flexible, eg. by making a script that would do this or every argument light?

Is it possible to do something along this path?

script.turn_dimmables_on(entity_id)

Maybe appdeamon would be the right direction, except I have no knowlegde of writing appdeamon scripts.

I believe you are looking for this:
Passing variables to scripts

Well, sort of…
I’m looking for a way to make this dimmer script (shown above) work as an entire service, putting the entity_id in as an argument:

script:
  lys_interior_light_on:
    alias: "[House] - Turn on interior light"
    sequence:
      - service: [MyOwnService]   ## The dimming sequence above
        data:
          entity_id: light.dimmable_1
      - service: [MyOwnService]   ## The dimming sequence above
        data:
          entity_id: light.dimmable_2
      - service: [MyOwnService]   ## The dimming sequence above
        data:
          entity_id: light.dimmable_n

I’m not seeing any obstacle to achieving your goal. :man_shrugging: You can pass arguments to a called script.

1 Like

Thank you @123 for helping me out here.

Here is my solution

script:
  lys_dimmable_spots_on:
    alias: "[House] - Turn on dimmable LEDS"
    sequence:
      - service: light.turn_on
        data_template:
          entity_id: "{{ entity }}"
          brightness: 50
          transition: 1
      - delay: 3
      - service: light.turn_on        
        data_template:
          entity_id: "{{ entity }}" ## Entity defined below for each service call
          brightness: 5
          transition: 1

    #### The script below calls the above script, pushing the variable
    #### `entity` to the script above as an argument 

  lys_test_dimmables_on:
    alias: "[House] - TEST Turn on dimmable LEDS"
    sequence:
      - service: script.lys_dimmable_spots_on
        data: 
          entity: light.lys_tilleggslys
      - service: script.lys_dimmable_spots_on
        data: 
          entity: light.lys_grunnbelysning_dimbare

You’re welcome!

BTW, now that I have a better understanding of what you were trying to achieve, I can see how it can be done with a single script using repeat (no need to pass an argument to a script). Anyway, you have already achieved your goal, using your preferred technique, so there’s no need explore alternatives.

1 Like

Sure thing, @123.
Still, but out of curiosity; what would an approach, using repeat look like? Schematically…