Hi,
I’m a noob writing templates and I configured this light template for a RF light that works with switches for control the brightness:
# Luz indirecta Salacomedor con manejo de dimmer
- platform: template
lights:
luz_indirecta_salacomedor:
friendly_name: "Luz Indirecta Salacomedor"
level_template: "{{ states('input_number.brillo_luz_indirecta_salacomedor') }}"
value_template: "{{ states('input_boolean.luz_indirecta_salacomedor_estado') }}"
turn_on:
service: script.ajustar_brillo_luz_indirecta_salacomedor
data:
nivel: "{{ 255 }}"
turn_off:
service: script.ajustar_brillo_luz_indirecta_salacomedor
data:
nivel: "{{ 0 }}"
set_level:
service: script.ajustar_brillo_luz_indirecta_salacomedor
data:
nivel: "{{ nivel }}"
supports_transition_template: "{{ false }}"
# Scripts
alias: Ajustar Brillo Luz Indirecta Salacomedor
fields:
nivel:
description: Brightness level
example: 99
variables:
brillo: >
{%- set nivel = (nivel | int(0) / 256 * 100) | int %}
{% if nivel == 0 %}
0.0
{% elif nivel > 0 and nivel <= 25 %}
25.0
{% elif nivel > 25 and nivel <= 50 %}
50.0
{% elif nivel > 50 and nivel <= 75 %}
75.0
{% else %}
100.0
{% endif %}
{{- brillo }}
sequence:
- service: input_number.set_value
target:
entity_id: input_number.brillo_luz_indirecta_salacomedor
data:
value: '{{ brillo }}'
- service: script.principal_luz_indirecta_salacomedor
data: {}
mode: single
alias: Principal Luz Indirecta Salacomedor
sequence:
- choose:
- conditions:
- condition: state
entity_id: input_number.brillo_luz_indirecta_salacomedor
state: '0.0'
sequence:
- service: switch.turn_off
data: {}
target:
entity_id: switch.luz_indirecta_salacomedor
- service: input_boolean.turn_off
target:
entity_id: input_boolean.luz_indirecta_salacomedor_estado
data: {}
- conditions:
- condition: state
entity_id: input_number.brillo_luz_indirecta_salacomedor
state: '25.0'
sequence:
- service: switch.turn_on
data: {}
target:
entity_id: switch.luz_indirecta_salacomedor
- delay:
hours: 0
minutes: 0
seconds: 2
milliseconds: 0
- service: switch.toggle
data: {}
target:
entity_id: switch.brillo_luz_indirecta_al_25
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.luz_indirecta_salacomedor_estado
- conditions:
- condition: state
entity_id: input_number.brillo_luz_indirecta_salacomedor
state: '50.0'
sequence:
- service: switch.turn_on
data: {}
target:
entity_id: switch.luz_indirecta_salacomedor
- delay:
hours: 0
minutes: 0
seconds: 2
milliseconds: 0
- service: switch.toggle
data: {}
target:
entity_id: switch.brillo_luz_indirecta_al_50
- service: input_boolean.turn_on
target:
entity_id: input_boolean.luz_indirecta_salacomedor_estado
data: {}
- conditions:
- condition: state
entity_id: input_number.brillo_luz_indirecta_salacomedor
state: '75.0'
sequence:
- service: switch.turn_on
data: {}
target:
entity_id: switch.luz_indirecta_salacomedor
- delay:
hours: 0
minutes: 0
seconds: 2
milliseconds: 0
- service: switch.toggle
target:
entity_id: switch.brillo_luz_indirecta_al_75
data: {}
- service: input_boolean.turn_on
target:
entity_id: input_boolean.luz_indirecta_salacomedor_estado
data: {}
- conditions:
- condition: state
entity_id: input_number.brillo_luz_indirecta_salacomedor
state: '100.0'
sequence:
- service: switch.turn_on
data: {}
target:
entity_id: switch.luz_indirecta_salacomedor
- delay:
hours: 0
minutes: 0
seconds: 2
milliseconds: 0
- service: switch.toggle
target:
entity_id: switch.brillo_luz_indirecta_al_100
data: {}
- service: input_boolean.turn_on
target:
entity_id: input_boolean.luz_indirecta_salacomedor_estado
data: {}
default: []
mode: single
I can not get the input slider sets the value, the light doesn’t turn on when I move the brightness control slider and when it is on, if I move the brightness control slider the light turn off. What I’m doing wrong (if not is everything)?
Maybe, there is a way to create a light template with minus (-) plus (+) switches that controls the brightness one step at a time?