Setting dimmer in automation

I currently am running a simple automation for turning lights on at sunset

- id: '1657759695360'
  alias: Lights On At Sunset
  description: ''
  use_blueprint:
    path: CyanAutomation/lights_on_at_sunset.yaml
    input:
      target_light:
        device_id:
        - 4f2d439fe5c4d5d5cbde91cb0345ed24
        - 7977d2a2308226c68b2d330e9a6b6ac0
        - 3ba550a356b34c740da5a9ebeb0b1f2a
        - e481a6a93f8dee39f843d46db98a2c4f
        - ced88b62e5969b32c229eebcb4d6580b
        - 345536450397e4894a8d900cde48d2a7
        - 5633cd48b31e40ffbee5da3b7edbc2d8
        - 863ee64cd60cc9a71b44fcfcf74a8f62
        - 22a73b9403195336189dfbca41a5bd0b
        - 9901382e7241f661f8368e9151d7229f
        - a1439d56078c4d083161336db8b0424f
        - da63baf6e1da043a11e9bfc3e31b5297
        - 45d2dac732b4fac4c6e1d76bbd3ff414
        - 390fb2fd0e54c00f151ed4d95896c778
        - 726af5eb9d6df3632845ae4d7f086f7d
      target_brightness: 100
      elevation_shift: 3

My question is HOW do I set individual dim levels in this automation, Is it simply adding target_brightness: 50 in between each entity/id? examples?

thanks in advance.

What you posted isn’t a self-contained automation, it is associated with a blueprint. We would need to see the blueprint in order to make accurate suggestions. However, based on what I see I assume that the value of target_brightness will be applied to all devices listed under device_id.

Is it simply adding target_brightness: 50 in between each entity/id?

No, you can’t put anything within the device_id option other than a valid device identifier.

so if I changed the device id’s to device/entities, could I put the target_brightness between each device/ entity

Unclear if that is possible.
The only way to know for sure is if you post the complete yaml.

Here’s the original blueprint…

blueprint:
  name: Lights On At Sunset
  description: Turn on the following lights at sunset
  domain: automation
  input:
    target_light:
      name: Lights
      description: This is the light (or lights) that will be activated at sunset
      selector:
        target:
          entity:
            domain: light
    target_brightness:
      name: Brightness
      description: Brightness of the light(s) when they're activated
      default: 50
      selector:
        number:
          min: 5.0
          max: 100.0
          mode: slider
          step: 5.0
          unit_of_measurement: '%'
    elevation_shift:
      name: Elevation Shift
      description: Using an elevation offset (height of sun relative to the horizon)
        to shift the sunset trigger, either earlier or later. Positive values bring
        the automation start time forward, whilst negative values delay the start
        time. To approximate Golden Hour - set the Elevation Offset to 1.
      default: 0.0
      selector:
        number:
          min: -3.0
          max: 3.0
          mode: slider
          step: 1.0
  source_url: https://gist.github.com/CyanAutomation/1b8bafd033f73e3c24e42e8f381ff906
mode: single
variables:
  target_brightness: !input target_brightness
  target_light: !input target_light
trigger:
  platform: numeric_state
  entity_id: sun.sun
  attribute: elevation
  below: !input elevation_shift
condition:
  condition: sun
  after: sunrise
  after_offset: 01:00:00
action:
- service: light.turn_on
  target: !input target_light
  data_template:
    brightness_pct: '{{ target_brightness | int }}'

and here’s my automation code

  #LIGHTS ON AT SUNSET
  
- id: '1657759695360'
  alias: Lights On At Sunset
  description: ''
  use_blueprint:
    path: CyanAutomation/lights_on_at_sunset.yaml
    input:
      target_light:
        device_id:
        - 4f2d439fe5c4d5d5cbde91cb0345ed24
        - 7977d2a2308226c68b2d330e9a6b6ac0
        - 3ba550a356b34c740da5a9ebeb0b1f2a
        - e481a6a93f8dee39f843d46db98a2c4f
        - ced88b62e5969b32c229eebcb4d6580b
        - 345536450397e4894a8d900cde48d2a7
        - 5633cd48b31e40ffbee5da3b7edbc2d8
        - 863ee64cd60cc9a71b44fcfcf74a8f62
        - 22a73b9403195336189dfbca41a5bd0b
        - 9901382e7241f661f8368e9151d7229f
        - a1439d56078c4d083161336db8b0424f
        - da63baf6e1da043a11e9bfc3e31b5297
        - 45d2dac732b4fac4c6e1d76bbd3ff414
        - 390fb2fd0e54c00f151ed4d95896c778
        - 726af5eb9d6df3632845ae4d7f086f7d
      target_brightness: 100
      elevation_shift: 3

hope this helps.

As expected, the blueprint sets all of the listed devices to the value of target_brightness.

Is that what you want or something else?

I’d like to set each device separately and/or have them default to 100% UNLESS otherwise stated.

In that case, the blueprint you are currently using cannot be used for that purpose unless you modify it extensively.

The major obstacle is that your requirements are challenging to implement. You want a blueprint that can accept one or more devices and potentially a different brightness value for each device or possibly only for some devices or even no brightness specified at all.

I don’t know of any selector that can accomodate that requirement.

it does NOT need to be a blueprint. I only used it because I didn’t know where to start.

OK, some time could have been saved had you mentioned that in your first post.

In that case, your automation will require a hard-coded list of devices with a corresponding brightness level specified for each one. I suggest using a dictionary to store that information and then use a repeat to iterate through the dictionary, retrieving the values needed for the light.turn_on service call.

If you look at the debug of the automation, it will show you actual yaml of the automation used(under tab automation config); you can copy that 1:1 into a new automation (so no blue print needed anymore)
From there it is quite easy to alter the automation for you own needs :wink:

way over my head…sorry. I do want to learn though and I have programmed in a few other languages.

Here’s the results of the automation config

mode: single
variables:
  target_brightness: 100
  target_light:
    device_id:
      - 4f2d439fe5c4d5d5cbde91cb0345ed24
      - 7977d2a2308226c68b2d330e9a6b6ac0
      - 3ba550a356b34c740da5a9ebeb0b1f2a
      - e481a6a93f8dee39f843d46db98a2c4f
      - ced88b62e5969b32c229eebcb4d6580b
      - 345536450397e4894a8d900cde48d2a7
      - 5633cd48b31e40ffbee5da3b7edbc2d8
      - 863ee64cd60cc9a71b44fcfcf74a8f62
      - 22a73b9403195336189dfbca41a5bd0b
      - 9901382e7241f661f8368e9151d7229f
      - a1439d56078c4d083161336db8b0424f
      - da63baf6e1da043a11e9bfc3e31b5297
      - 45d2dac732b4fac4c6e1d76bbd3ff414
      - 390fb2fd0e54c00f151ed4d95896c778
      - 726af5eb9d6df3632845ae4d7f086f7d
trigger:
  platform: numeric_state
  entity_id: sun.sun
  attribute: elevation
  below: 3
condition:
  condition: sun
  after: sunrise
  after_offset: '01:00:00'
action:
  - service: light.turn_on
    target:
      device_id:
        - 4f2d439fe5c4d5d5cbde91cb0345ed24
        - 7977d2a2308226c68b2d330e9a6b6ac0
        - 3ba550a356b34c740da5a9ebeb0b1f2a
        - e481a6a93f8dee39f843d46db98a2c4f
        - ced88b62e5969b32c229eebcb4d6580b
        - 345536450397e4894a8d900cde48d2a7
        - 5633cd48b31e40ffbee5da3b7edbc2d8
        - 863ee64cd60cc9a71b44fcfcf74a8f62
        - 22a73b9403195336189dfbca41a5bd0b
        - 9901382e7241f661f8368e9151d7229f
        - a1439d56078c4d083161336db8b0424f
        - da63baf6e1da043a11e9bfc3e31b5297
        - 45d2dac732b4fac4c6e1d76bbd3ff414
        - 390fb2fd0e54c00f151ed4d95896c778
        - 726af5eb9d6df3632845ae4d7f086f7d
    data_template:
      brightness_pct: '{{ target_brightness | int }}'
id: '1657759695360'
alias: Lights On At Sunset
description: ''

So I think I figured it out…


id: '1660856522361'
alias: trial lights on at custom dim
description: ''
trigger:
  - platform: sun
    event: sunset
    offset: '-30:00'
condition: []
action:
  - type: turn_on
    device_id: 726af5eb9d6df3632845ae4d7f086f7d
    entity_id: light.switchlinc_dimmer_3d_ac_8a
    domain: light
    brightness_pct: 50
  - type: turn_on
    device_id: 4f2d439fe5c4d5d5cbde91cb0345ed24
    entity_id: light.lamplinc_dimmer_35_54_23
    domain: light
    brightness_pct: 50
  - type: turn_on
    device_id: 7977d2a2308226c68b2d330e9a6b6ac0
    entity_id: light.lamplinc_dimmer_3a_9f_a9
    domain: light
    brightness_pct: 35
  - type: turn_on
    device_id: 3ba550a356b34c740da5a9ebeb0b1f2a
    entity_id: light.switchlinc_dimmer_3d_10_15
    domain: light
    brightness_pct: 70
  - type: turn_on
    device_id: e481a6a93f8dee39f843d46db98a2c4f
    entity_id: light.switchlinc_dimmer_3d_06_c4
    domain: light
    brightness_pct: 50
  - type: turn_on
    device_id: ced88b62e5969b32c229eebcb4d6580b
    entity_id: light.lamplinc_dimmer_2e_fc_d2
    domain: light
    brightness_pct: 50
  - type: turn_on
    device_id: da63baf6e1da043a11e9bfc3e31b5297
    entity_id: light.led_deck
    domain: light
  - type: turn_on
    device_id: 345536450397e4894a8d900cde48d2a7
    entity_id: light.switchlinc_dimmer_3d_ad_f3
    domain: light
    brightness_pct: 50
  - type: turn_on
    device_id: 5633cd48b31e40ffbee5da3b7edbc2d8
    entity_id: light.lamplinc_dimmer_3a_9c_7d
    domain: light
    brightness_pct: 40
  - type: turn_on
    device_id: 863ee64cd60cc9a71b44fcfcf74a8f62
    entity_id: light.music_torch
    domain: light
  - type: turn_on
    device_id: 45d2dac732b4fac4c6e1d76bbd3ff414
    entity_id: light.pathway_light
    domain: light
  - type: turn_on
    device_id: 390fb2fd0e54c00f151ed4d95896c778
    entity_id: light.step_light
    domain: light
  - type: turn_on
    device_id: a1439d56078c4d083161336db8b0424f
    entity_id: light.lamplinc_dimmer_2e_d8_a0
    domain: light
    brightness_pct: 100
  - type: turn_on
    device_id: f42d9aca52338dc2e35ba15b0845bee3
    entity_id: light.tv_light
    domain: light
    brightness_pct: 100
mode: single

thanks for the inspiration.

Here’s an alternative based on the approach I had suggested.

The repeat - for_each steps through the list of entities and brightness values, turning on each entity and setting its brightness to the specified value.

id: '1660856522361'
alias: trial lights on at custom dim
description: ''
trigger:
  - platform: sun
    event: sunset
    offset: '-30:00'
condition: []
action:
  - repeat:
      for_each:
        - e: switchlinc_dimmer_3d_ac_8a
          b: 50
        - e: lamplinc_dimmer_35_54_23
          b: 50
        - e: lamplinc_dimmer_3a_9f_a9
          b: 35
        - e: switchlinc_dimmer_3d_10_15
          b: 70
        - e: switchlinc_dimmer_3d_06_c4
          b: 50
        - e: lamplinc_dimmer_2e_fc_d2
          b: 50
        - e: led_deck
          b: 100
        - e: switchlinc_dimmer_3d_ad_f3
          b: 50
        - e: lamplinc_dimmer_3a_9c_7d
          b: 40
        - e: music_torch
          b: 100
        - e: pathway_light
          b: 100
        - e: step_light
          b: 100
        - e: lamplinc_dimmer_2e_d8_a0
          b: 100
        - e: tv_light
          b: 100
      sequence:
        - service: light.turn_on
          target:
            entity_id: 'light.{{ repeat.item.e }}'
          data:
            brightness_pct: '{{ repeat.item.b }}'
mode: single
1 Like