Hello,
I need a help with the following script. The idea is that when you hold down a button, the intensity of a led strip will increase and when it detects that it has reached its maximum value (255), it will decrease the intensity.
fade_the_light:
alias: Kitchen Brightness Decrease Button
sequence:
- repeat:
while:
- condition: template
value_template: >-
{{ is_state('binary_sensor.touch_espejo_larga', 'on') }}
sequence:
- service: light.turn_on
data_template:
entity_id: light.luz_espejo_rgbw
brightness: >
{% set ct = state_attr('light.luz_espejo_rgbw', 'brightness')|int %}
{% if (is_state('input_boolean.prueba', 'off')) and (ct < 255) %}
{{ ct + 2 }}
{% endif %}
{% if ct == 255 %}
turn_on:
- service: input_boolean.toggle
data:
entity_id: input_boolean.prueba
{% endif %}
{% if (is_state('input_boolean.prueba', 'on')) and (ct > 0) %}
{{ ct - 2 }}
{% endif %}
{% if ct == 0 %}
turn_off:
- service: input_boolean.toggle
data:
entity_id: input_boolean.prueba
{% endif %}
- delay: 00:00:00.02