Hi all! I’m trying to create a script that adjusts brightness up or down. This will be addressed from a Loxone Miniserver to turn brightness up or down from a switch.
I created this script similar to another one related to volume (Sending Jinja2 templates in an HTTP Request? - #8 by petro), but didn’t work. Probably because there is no “state_attr” called “brightness” for “light”. Anyone know what the “state_attr” would be to detect the brightness of a light bulb?
Thanks.
alias: Step Adjust Brightness
mode: parallel
description: |
step adjust the brightness of any light
fields:
entity_id:
description: The Light Bulb
required: true
selector:
entity:
multiple: true
domain: light
direction:
description: Brightness Up or Brightness Down
required: true
selector:
select:
options:
- label: Brightness Up
value: up
- label: Brightness Down
value: down
brightness_step:
description: Brightness Step (up or down)
default: 0.05
selector:
number:
min: 0
max: 0
step: 0.05
variables:
light: "{{ entity_id if entity_id is list else [entity_id] }}"
current: >-
{{ light | map('state_attr', 'brightness') | select('is_number') | list |
average }}
step: "{{ brightness_step | default(0.05) }}"
brightness: "{{ current + step if direction == 'up' else current - step }}"
sequence:
- action: light.toggle
target:
entity_id: "{{ light }}"
data:
brightness_pct: "{{ brightness_pct }}"
icon: mdi:lightbulb-on-10