Last active
November 4, 2025 16:04
-
-
Save hectorzin/7b8976d9c768de59ef5e781453683ae3 to your computer and use it in GitHub Desktop.
Create lights over IR devices
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| input_boolean: | |
| luz_lagrima_state: | |
| name: Estado Luz IR | |
| initial: false | |
| input_number: | |
| luz_lagrima_level: | |
| name: Luz lágrima – brillo | |
| min: 1 | |
| max: 10 | |
| step: 1 | |
| mode: slider | |
| initial: 10 | |
| input_select: | |
| luz_lagrima_effect: | |
| name: Luz lágrima – efecto | |
| options: | |
| - none | |
| - Flash | |
| - Strobe | |
| - Fade | |
| - Smooth | |
| initial: none | |
| template: | |
| - light: | |
| - name: "Luz lágrima" | |
| unique_id: luz_lagrima | |
| icon: mdi:remote | |
| # Estado ON/OFF "optimista" | |
| state: "{{ is_state('input_boolean.luz_lagrima_state','on') }}" | |
| # ====== EFECTOS ====== | |
| # effect_list debe ser UNA PLANTILLA que devuelva una LISTA | |
| effect_list: >- | |
| {{ ['Flash', 'Strobe', 'Fade', 'Smooth'] }} | |
| # Efecto actual: string o none. Usamos el helper para persistirlo. | |
| effect: >- | |
| {% if is_state('input_boolean.luz_lagrima_state','on') %} | |
| {{ states('input_select.luz_lagrima_effect') }} | |
| {% endif %} | |
| set_effect: | |
| - variables: | |
| e_low: "{{ (effect or '') | lower | trim }}" | |
| - choose: | |
| - conditions: "{{ e_low == 'flash' }}" | |
| sequence: | |
| - action: scene.turn_on | |
| target: { entity_id: scene.luz_lagrima_flash } | |
| - action: input_select.select_option | |
| data: | |
| { | |
| entity_id: input_select.luz_lagrima_effect, | |
| option: "Flash", | |
| } | |
| - conditions: "{{ e_low == 'strobe' }}" | |
| sequence: | |
| - action: scene.turn_on | |
| target: { entity_id: scene.luz_lagrima_strobe } | |
| - action: input_select.select_option | |
| data: | |
| { | |
| entity_id: input_select.luz_lagrima_effect, | |
| option: "Strobe", | |
| } | |
| - conditions: "{{ e_low == 'fade' }}" | |
| sequence: | |
| - action: scene.turn_on | |
| target: { entity_id: scene.luz_lagrima_fade } | |
| - action: input_select.select_option | |
| data: | |
| { | |
| entity_id: input_select.luz_lagrima_effect, | |
| option: "Fade", | |
| } | |
| - conditions: "{{ e_low == 'smooth' }}" | |
| sequence: | |
| - action: scene.turn_on | |
| target: { entity_id: scene.luz_lagrima_smooth } # cámbialo si tu escena se llama distinto | |
| - action: input_select.select_option | |
| data: | |
| { | |
| entity_id: input_select.luz_lagrima_effect, | |
| option: "Smooth", | |
| } | |
| - action: input_boolean.turn_on | |
| target: { entity_id: input_boolean.luz_lagrima_state } | |
| # ====== COLOR (usa tu script de mapeo HS→escena) ====== | |
| set_hs: | |
| - action: script.luz_lagrima_aplicar_color # pon aquí el entity_id real del script creado en la UI | |
| data: | |
| hue: "{{ h }}" | |
| sat: "{{ s }}" | |
| - action: input_boolean.turn_on | |
| target: { entity_id: input_boolean.luz_lagrima_state } | |
| # cambiar color limpia el efecto mostrado | |
| - action: input_select.select_option | |
| data: { entity_id: input_select.luz_lagrima_effect, option: "none" } | |
| # ====== ENCENDIDO / APAGADO ====== | |
| turn_on: | |
| - action: input_boolean.turn_on | |
| target: { entity_id: input_boolean.luz_lagrima_state } | |
| - action: scene.turn_on | |
| target: { entity_id: scene.luz_lagrima_on } | |
| turn_off: | |
| - action: scene.turn_on | |
| target: { entity_id: scene.luz_lagrima_off } | |
| - action: input_boolean.turn_off | |
| target: { entity_id: input_boolean.luz_lagrima_state } | |
| - action: input_select.select_option | |
| data: { entity_id: input_select.luz_lagrima_effect, option: "none" } | |
| # ----- BRILLO (0–255) ----- | |
| # Valor reportado a la UI (leemos del helper) | |
| # ====== BRILLO: 10 niveles (1..10) con OFF aparte ====== | |
| # Lo que la luz reporta (0..255) a partir del nivel guardado (1..10) | |
| level: >- | |
| {{ ((states('input_number.luz_lagrima_level') | int(6) - 1) * 255 / 9) | round(0) | int }} | |
| # Cuando HA pide un brillo concreto (0..255) | |
| set_level: | |
| - variables: | |
| requested: >- | |
| {% if level is defined %} | |
| {{ level | int }} | |
| {% elif brightness is defined %} | |
| {{ brightness | int }} | |
| {% else %} | |
| {{ ((states('input_number.luz_lagrima_level') | int(6) - 1) * 255 / 9) | round(0) | int }} | |
| {% endif %} | |
| - variables: | |
| requested_safe: "{{ requested | default(0, true) | int(0) }}" | |
| target_level: >- | |
| {{ ((requested_safe - 1) * 10 / 254) | round(0) | int + 1 if requested_safe > 0 else 1 }} | |
| current_level: "{{ states('input_number.luz_lagrima_level') | int(6) }}" | |
| diff: "{{ target_level - current_level }}" | |
| clicks: "{{ (diff | abs) | int }}" | |
| direction: "{{ 1 if diff > 0 else (-1 if diff < 0 else 0) }}" | |
| - choose: | |
| - conditions: "{{ requested_safe == 0 }}" | |
| sequence: | |
| - action: scene.turn_on | |
| target: { entity_id: scene.luz_lagrima_off } | |
| - action: input_boolean.turn_off | |
| target: { entity_id: input_boolean.luz_lagrima_state } | |
| - conditions: "{{ direction > 0 and clicks > 0 }}" | |
| sequence: | |
| - repeat: | |
| count: "{{ clicks }}" | |
| sequence: | |
| - action: scene.turn_on | |
| target: { entity_id: scene.luz_lagrima_brillo_mas } | |
| - delay: { milliseconds: 1500 } | |
| - action: input_number.set_value | |
| data: | |
| entity_id: input_number.luz_lagrima_level | |
| value: >- | |
| {% set v = (current_level + clicks) | int %} | |
| {{ 1.0 if v < 1 else (10.0 if v > 10 else v | float) }} | |
| - conditions: "{{ direction < 0 and clicks > 0 }}" | |
| sequence: | |
| - repeat: | |
| count: "{{ clicks }}" | |
| sequence: | |
| - action: scene.turn_on | |
| target: { entity_id: scene.luz_lagrima_brillo_menos } | |
| - delay: { milliseconds: 1500 } | |
| - action: input_number.set_value | |
| data: | |
| entity_id: input_number.luz_lagrima_level | |
| value: >- | |
| {% set v = (current_level - clicks) | int %} | |
| {{ 1.0 if v < 1 else (10.0 if v > 10 else v | float) }} | |
| - action: input_boolean.turn_on | |
| target: { entity_id: input_boolean.luz_lagrima_state } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| alias: Luz lágrima - aplicar color | |
| mode: single | |
| fields: | |
| hue: | |
| description: Hue (0-360) | |
| sat: | |
| description: Saturación (0-100) | |
| sequence: | |
| - choose: | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ (sat | float(0)) < 10 }}" | |
| sequence: | |
| - target: | |
| entity_id: scene.luz_lagrima_blanca | |
| action: scene.turn_on | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ (hue|float) >= 345 or (hue|float) < 10 }}" | |
| sequence: | |
| - target: | |
| entity_id: scene.Luz_lagrima_Rojo | |
| action: scene.turn_on | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ 10 <= (hue|float) < 20 }}" | |
| sequence: | |
| - target: | |
| entity_id: scene.luz_lagrima_narojo | |
| action: scene.turn_on | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ 20 <= (hue|float) < 35 }}" | |
| sequence: | |
| - target: | |
| entity_id: scene.luz_lagrima_naranja | |
| action: scene.turn_on | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ 35 <= (hue|float) < 45 }}" | |
| sequence: | |
| - target: | |
| entity_id: scene.luz_lagrima_namarillo | |
| action: scene.turn_on | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ 45 <= (hue|float) < 65 }}" | |
| sequence: | |
| - target: | |
| entity_id: scene.luz_lagrima_amarillo | |
| action: scene.turn_on | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ 65 <= (hue|float) < 130 }}" | |
| sequence: | |
| - target: | |
| entity_id: scene.luz_lagrima_verde | |
| action: scene.turn_on | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ 130 <= (hue|float) < 155 }}" | |
| sequence: | |
| - target: | |
| entity_id: scene.luz_lagrima_vercyan | |
| action: scene.turn_on | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ 150 <= (hue|float) < 170 }}" | |
| sequence: | |
| - target: | |
| entity_id: scene.luz_lagrima_cyan | |
| action: scene.turn_on | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ 170 <= (hue|float) < 195 }}" | |
| sequence: | |
| - target: | |
| entity_id: scene.luz_lagrima_azucyan | |
| action: scene.turn_on | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ 195 <= (hue|float) < 220 }}" | |
| sequence: | |
| - target: | |
| entity_id: scene.luz_lagrima_azul_claro | |
| action: scene.turn_on | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ 220 <= (hue|float) < 245 }}" | |
| sequence: | |
| - target: | |
| entity_id: scene.luz_lagrima_azul | |
| action: scene.turn_on | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ 245 <= (hue|float) < 255 }}" | |
| sequence: | |
| - target: | |
| entity_id: scene.luz_lagrima_azulila | |
| action: scene.turn_on | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ 255 <= (hue|float) < 285 }}" | |
| sequence: | |
| - target: | |
| entity_id: scene.luz_lagrima_lila | |
| action: scene.turn_on | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ 285 <= (hue|float) < 305 }}" | |
| sequence: | |
| - target: | |
| entity_id: scene.luz_lagrima_lirosa | |
| action: scene.turn_on | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ 305 <= (hue|float) < 345 }}" | |
| sequence: | |
| - target: | |
| entity_id: scene.luz_lagrima_rosa | |
| action: scene.turn_on | |
| default: [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment