Skip to content

Instantly share code, notes, and snippets.

@charno
Last active October 13, 2023 17:13
Show Gist options
  • Save charno/70801e2e21a5df5b360027fd93ba7aa1 to your computer and use it in GitHub Desktop.
Save charno/70801e2e21a5df5b360027fd93ba7aa1 to your computer and use it in GitHub Desktop.
dim down lights
# Blueprint metadata
blueprint:
name: Dim down active lamps
description: |
# Only dim down lamps that are currently on
source_url: https://gist.github.com/charno/
domain: script
input:
target_light:
name: Lights
description: The lights to dim down
selector:
entity:
multiple: true
filter:
- domain: light
brightness_step:
name: Step
description: How much should each step be dimming down?
default: 25
selector:
number:
min: 1
max: 254
min_brightness:
name: Minimum brightness
default: 10
selector:
number:
min: 1
max: 254
variables:
target_light: !input target_light
min_brightness: !input min_brightness
brightness_step: !input brightness_step
sequence:
- repeat:
for_each: >-
{{ expand(target_light) | selectattr('state', 'eq',
'on') | map(attribute='entity_id') | list }}
sequence:
- alias: "Decrease brightness by step"
service: light.turn_on
data_template:
entity_id: '{{ repeat.item }}'
brightness: >
{% set bri = state_attr(repeat.item, 'brightness') | int %}
{{ [bri-brightness_step, min_brightness] | max }}
transition: 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment