Skip to content

Instantly share code, notes, and snippets.

@hectorzin
Created June 4, 2025 15:42
Show Gist options
  • Save hectorzin/b5152d6a5c1d47a0109622028e8a2848 to your computer and use it in GitHub Desktop.
Save hectorzin/b5152d6a5c1d47a0109622028e8a2848 to your computer and use it in GitHub Desktop.
Home Assistant automations to create Ulanzi Awtrix Apps
alias: Aviso calidad aire exterior PM2.5 Awtrix
description: Muestra calidad del aire exterior PM2.5 en Awtrix
triggers:
- entity_id: sensor.ws2900_v2_02_03_pm2_5_1
trigger: state
- minutes: /15
trigger: time_pattern
conditions: []
actions:
- variables:
pm: "{{ states('sensor.ws2900_v2_02_03_pm2_5_1') | float(0) }}"
nivel: |-
{% if pm <= 12.0 %}
Bueno
{% elif pm <= 35.4 %}
Moderado
{% elif pm <= 55.4 %}
Nocivo (sensibles)
{% elif pm <= 150.4 %}
Insalubre
{% elif pm <= 250.4 %}
Muy insalubre
{% else %}
Peligroso
{% endif %}
icono: |-
{% if pm <= 12.0 %}
4743
{% elif pm <= 35.4 %}
27600
{% elif pm <= 55.4 %}
52538
{% elif pm <= 150.4 %}
45290
{% elif pm <= 250.4 %}
36141
{% else %}
2772
{% endif %}
color: |-
{% if pm <= 12.0 %}
[0,228,0]
{% elif pm <= 35.4 %}
[255,255,0]
{% elif pm <= 55.4 %}
[255,126,0]
{% elif pm <= 150.4 %}
[255,0,0]
{% elif pm <= 250.4 %}
[153,0,76]
{% else %}
[126,0,35]
{% endif %}
- choose:
- conditions:
- condition: numeric_state
entity_id: sensor.ws2900_v2_02_03_pm2_5_1
above: 150.4
sequence:
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
text: |
Calidad del aire: {{ nivel }} — {{ pm | round(0) }} µg/m³
icon: "{{ icono }}"
app: PM2_5
color: "{{ color }}"
effect: SwirlOut
effectSettings:
speed: 10
palette: Heat
action: awtrix.custom_app
default:
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
text: |
Calidad del aire: {{ nivel }} — {{ pm | round(0) }} µg/m³
icon: "{{ icono }}"
app: PM2_5
effect: none
color: "{{ color }}"
action: awtrix.custom_app
- choose:
- conditions:
- condition: template
value_template: "{{ pm <= 12 }}"
sequence:
- action: awtrix.delete_custom_app
metadata: {}
data:
device: 46f7de6ece2c1000d30f840b31d60be8
app: PM2_5
mode: single
alias: Próximo evento calendario Awtrix
description: Muestra el próximo evento aunque no esté activo
triggers:
- minutes: /15
trigger: time_pattern
conditions:
- condition: template
value_template: >
{{ state_attr('calendar.hector_mjuste_gmail_com', 'start_time') is not
none }}
actions:
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
text: >
{{ (state_attr('calendar.hector_mjuste_gmail_com', 'start_time') |
as_datetime | as_local).strftime('%H:%M') }} {{
state_attr('calendar.hector_mjuste_gmail_com', 'message') }}
icon: "36514"
app: Calendario
color: |
{% if is_state('calendar.hector_mjuste_gmail_com', 'on') %}
[255,0,0] {# Rojo si el evento está en curso #}
{% else %}
[0,150,255] {# Azul si aún no ha empezado #}
{% endif %}
action: awtrix.custom_app
enabled: false
- target:
entity_id: calendar.hector_mjuste_gmail_com
data:
start_date_time: "{{ now().replace(hour=0, minute=0, second=0).isoformat() }}"
end_date_time: >-
{{ (now() + timedelta(days=1)).replace(hour=0, minute=0,
second=0).isoformat() }}
response_variable: lista_eventos
action: calendar.get_events
- variables:
eventos: |
{{ lista_eventos['calendar.hector_mjuste_gmail_com']['events'] }}
eventos_con_hora: >
{% set ahora = now() %} {% set ns = namespace(lista=[]) %} {% for ev in
eventos %}
{% if ev.start is string and 'T' in ev.start %}
{% set dt = ev.start | as_datetime | as_local %}
{% if dt > ahora %}
{% set ns.lista = ns.lista + [ev] %}
{% endif %}
{% endif %}
{% endfor %} {{ ns.lista }}
evento_con_hora_1: |
{% if eventos_con_hora | length > 0 %}
{{ eventos_con_hora[0] }}
{% else %} {{ {} }} {% endif %}
evento_con_hora_2: |
{% if eventos_con_hora | length > 1 %}
{{ eventos_con_hora[1] }}
{% else %} {{ {} }} {% endif %}
evento_con_hora_3: |
{% if eventos_con_hora | length > 2 %}
{{ eventos_con_hora[2] }}
{% else %} {{ {} }} {% endif %}
- choose:
- conditions:
- condition: template
value_template: >-
{{ evento_con_hora_1 is mapping and 'start' in evento_con_hora_1
and 'summary' in evento_con_hora_1 }}
sequence:
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
text: >
{{ (evento_con_hora_1.start | as_datetime |
as_local).strftime('%H:%M') }} {{ evento_con_hora_1.summary }}
icon: "36514"
app: Calendario1
color:
- 255
- 0
- 0
action: awtrix.custom_app
default:
- action: awtrix.delete_custom_app
metadata: {}
data:
device: 46f7de6ece2c1000d30f840b31d60be8
app: Calendario1
- choose:
- conditions:
- condition: template
value_template: >-
{{ evento_con_hora_2 is mapping and 'start' in evento_con_hora_2
and 'summary' in evento_con_hora_2 }}
sequence:
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
text: >
{{ (evento_con_hora_2.start | as_datetime |
as_local).strftime('%H:%M') }} {{ evento_con_hora_2.summary }}
icon: "36514"
app: Calendario2
color:
- 255
- 165
- 0
action: awtrix.custom_app
default:
- action: awtrix.delete_custom_app
metadata: {}
data:
device: 46f7de6ece2c1000d30f840b31d60be8
app: Calendario2
- choose:
- conditions:
- condition: template
value_template: >-
{{ evento_con_hora_3 is mapping and 'start' in evento_con_hora_3
and 'summary' in evento_con_hora_3 }}
sequence:
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
text: >
{{ (evento_con_hora_3.start | as_datetime |
as_local).strftime('%H:%M') }} {{ evento_con_hora_3.summary }}
icon: "36514"
app: Calendario3
color:
- 0
- 120
- 255
action: awtrix.custom_app
default:
- action: awtrix.delete_custom_app
metadata: {}
data:
device: 46f7de6ece2c1000d30f840b31d60be8
app: Calendario3
mode: single
alias: Aviso Calidad Aire Habitación CO2 Awtrix
description: Muestra aviso visual en Awtrix según calidad del aire (CO2)
triggers:
- entity_id: sensor.healthy_home_coach_carbon_dioxide_sensor
trigger: state
conditions: []
actions:
- choose:
- conditions:
- condition: numeric_state
entity_id: sensor.healthy_home_coach_carbon_dioxide_sensor
above: 1500
sequence:
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
text: >
MUY alto: {{
states('sensor.healthy_home_coach_carbon_dioxide_sensor') | int
}} ppm ¡Ventilar habitación YA!
icon: "8460"
app: Calidad Aire
effect: SwirlOut
action: awtrix.custom_app
- conditions:
- condition: numeric_state
entity_id: sensor.healthy_home_coach_carbon_dioxide_sensor
above: 1000
sequence:
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
text: >
alto: {{
states('sensor.healthy_home_coach_carbon_dioxide_sensor') | int
}} ppm Ventilar habitación
icon: "8459"
app: Calidad Aire
action: awtrix.custom_app
default:
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
text: >
Aire saludable: {{
states('sensor.healthy_home_coach_carbon_dioxide_sensor') | int
}}ppm ✅
icon: "8458"
app: Calidad Aire
action: awtrix.custom_app
enabled: false
- action: awtrix.delete_custom_app
metadata: {}
data:
device: 46f7de6ece2c1000d30f840b31d60be8
app: Calidad Aire
mode: single
alias: Aplicación Energía Awtrix
description: Muestra en el reloj Ulanzi T001 estado energético del hogar
triggers:
- minutes: /1
trigger: time_pattern
conditions: []
actions:
- choose:
- conditions:
- condition: numeric_state
entity_id: sensor.ingeteam_external_meter_ac_active_power
above: 500
sequence:
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
text: >
{{ states('sensor.ingeteam_external_meter_ac_active_power') }} W
icon: "58687"
color: >
{% set power =
states('sensor.ingeteam_external_meter_ac_active_power') | float
%} {% if power > 3500 %}
[255,0,0] {# Rojo #}
{% elif power > 2000 %}
[255,120,0] {# Naranja #}
{% elif power > 1000 %}
[255,220,0] {# Amarillo #}
{% else %}
[0,200,0] {# Verde #}
{% endif %}
app: Energia
action: awtrix.custom_app
- conditions:
- condition: numeric_state
entity_id: sensor.ingeteam_pv_internal_total_power
above: 3500
sequence:
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
text: >
Producción solar alta: {{
states('sensor.ingeteam_pv_internal_total_power') }} W
icon: "27283"
app: Energia
action: awtrix.custom_app
- conditions:
- condition: numeric_state
entity_id: sensor.ingeteam_battery_charging_power
above: 500
sequence:
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
text: >
{{ states('sensor.ingeteam_battery_charging_power') }}W {{
states('sensor.ingeteam_battery_state_of_charge') }}%
icon: "1095"
app: Energia
progress: "{{ states('sensor.ingeteam_battery_state_of_charge') }}"
action: awtrix.custom_app
- conditions:
- condition: numeric_state
entity_id: sensor.ingeteam_battery_discharging_power
above: 500
sequence:
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
text: >
{{ states('sensor.ingeteam_battery_discharging_power') }} W {{
states('sensor.ingeteam_battery_state_of_charge') }}%
progress: "{{ states('sensor.ingeteam_battery_state_of_charge') }}"
icon: "640"
app: Energia
action: awtrix.custom_app
- conditions:
- condition: numeric_state
entity_id: sensor.ingeteam_total_loads_power
above: 3500
sequence:
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
text: >
Consumo alto en casa: {{
states('sensor.ingeteam_total_loads_power') }}W
icon: "55267"
app: Energia
action: awtrix.custom_app
- conditions:
- condition: numeric_state
entity_id: sensor.consumo_coche
above: 500
sequence:
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
text: |
Cargando coche: {{ states('sensor.consumo_coche') }}W 🚗🔌
icon: "7281"
app: Energia
action: awtrix.custom_app
default:
- action: awtrix.delete_custom_app
metadata: {}
data:
device: 46f7de6ece2c1000d30f840b31d60be8
app: Energia
mode: single
alias: Aviso Meteorológico Awtrix
description: Muestra avisos visuales de la estación Ecowitt WS2900 en reloj Ulanzi T001
triggers:
- minutes: /1
trigger: time_pattern
conditions: []
actions:
- choose:
- conditions:
- condition: numeric_state
entity_id: sensor.ws2900_v2_02_03_uv_index
above: 6
sequence:
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
text: |
UV alto: {{ states('sensor.ws2900_v2_02_03_uv_index') }}
icon: "61542"
app: UV
color: >
{% set uv = states('sensor.ws2900_v2_02_03_uv_index') | float %}
{% if uv >= 11 %}[255,0,0] {% elif uv >= 8 %}[255,100,0] {%
elif uv >= 6 %}[255,180,0] {% elif uv >= 3 %}[0,200,0] {% else
%}[0,150,255] {% endif %}
action: awtrix.custom_app
default:
- action: awtrix.delete_custom_app
metadata: {}
data:
device: 46f7de6ece2c1000d30f840b31d60be8
app: UV
- choose:
- conditions:
- condition: numeric_state
entity_id: sensor.ws2900_v2_02_03_rain_rate
above: 5
sequence:
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
text: >
Lluvia intensa: {{ states('sensor.ws2900_v2_02_03_rain_rate') }}
mm/h
icon: "2416"
app: Meteorología
action: awtrix.custom_app
- conditions:
- condition: numeric_state
entity_id: sensor.ws2900_v2_02_03_wind_speed
above: 30
sequence:
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
text: >
Viento fuerte: {{ states('sensor.ws2900_v2_02_03_wind_speed') }}
km/h
icon: "3363"
app: Meteorología
action: awtrix.custom_app
- conditions:
- condition: numeric_state
entity_id: sensor.ws2900_v2_02_03_outdoor_temperature
above: 30
sequence:
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
text: |
{{ states('sensor.ws2900_v2_02_03_outdoor_temperature') }}°C
icon: "22293"
app: Meteorología
action: awtrix.custom_app
- conditions:
- condition: numeric_state
entity_id: sensor.ws2900_v2_02_03_outdoor_temperature
below: 5
sequence:
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
text: >
Temperatura baja: {{
states('sensor.ws2900_v2_02_03_outdoor_temperature') }}°C
icon: "14969"
app: Meteorología
action: awtrix.custom_app
- conditions:
- condition: numeric_state
entity_id: sensor.ws2900_v2_02_03_humidity
above: 85
sequence:
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
text: >
Alta: {{ states('sensor.ws2900_v2_02_03_humidity') }}% ({{
states('sensor.ws2900_v2_02_03_outdoor_temperature') }}°C)
icon: "22157"
app: Meteorología
action: awtrix.custom_app
- conditions:
- condition: numeric_state
entity_id: sensor.ws2900_v2_02_03_solar_radiation
above: 1000
enabled: true
sequence:
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
text: >
Radiación solar: {{
states('sensor.ws2900_v2_02_03_solar_radiation') | round(0) }}
W/m²
icon: "56958"
app: Meteorología
color: >
{% set rad = states('sensor.ws2900_v2_02_03_solar_radiation') |
float %} {% if rad > 800 %}[255,0,0] {# Rojo intenso #}
{% elif rad > 600 %}[255,120,0] {# Naranja #} {% elif rad >
400 %}[255,220,0] {# Amarillo #} {% elif rad > 200
%}[0,200,100] {# Verde suave #} {% else
%}[0,150,255] {# Azul claro #} {% endif %}
action: awtrix.custom_app
enabled: true
default:
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
text: |
{{ states('sensor.ws2900_v2_02_03_outdoor_temperature') }}°C
icon: >
{% set weather = states('weather.forecast_casa') %} {% if weather ==
'sunny' %}
2282
{% elif weather == 'partlycloudy' %}
22160
{% elif weather == 'cloudy' %}
21907
{% elif weather in ['rainy', 'pouring'] %}
2284
{% elif weather == 'lightning' %}
56675
{% elif weather in ['snowy', 'snowy-rainy'] %}
4702
{% elif weather == 'fog' %}
12196
{% elif weather == 'clear-night' %}
18433
{% else %}
52176
{% endif %}
overlay: |
{% if weather == 'sunny' %}
clear
{% elif weather == 'rainy' %}
rain
{% elif weather == 'pouring' %}
drizzle
{% elif weather == 'lightning' %}
thunder
{% elif weather in ['snowy', 'snowy-rainy'] %}
snow
{% elif weather == 'hail' %}
frost
{% else %}
none
{% endif %}
app: Meteorología
action: awtrix.custom_app
mode: single
alias: Estado cortacesped Landroid en Ulanzi (Awtrix)
description: >
Muestra estado del robot cortacésped Landroid en Awtrix según su estado, y lo
borra cuando no está ni en error, ni mowing, ni idle.
triggers:
- entity_id: lawn_mower.landroid
trigger: state
- entity_id: sensor.landroid_battery
trigger: state
conditions: []
actions:
- variables:
estado: "{{ states('lawn_mower.landroid') }}"
battery: "{{ states('sensor.landroid_battery') | int }}"
battery_color: |-
{% if battery >= 20 %}
#00FF00
{% elif battery >= 10 %}
#FFFF00
{% else %}
#FF0000
{% endif %}
battery_heght: |-
{% if battery < 15 %}
1
{% else %}
{{ ((battery + 10) / 25) | int }}
{% endif %}
- choose:
- conditions:
- condition: state
entity_id: lawn_mower.landroid
state: error
sequence:
- variables:
error: "{{ states('sensor.landroid_error') }}"
error_texto: >-
{% set traducciones = {
'outside_wire': 'Fuera del cable',
'outside_working_area': 'Fuera del área de trabajo',
'tilted': 'Inclinado',
'lifted': 'Levantado',
'trapped': 'Atrapado',
'battery_low': 'Batería baja',
'no_signal': 'Sin señal',
'collision_sensor_error': 'Error sensor de colisión',
'mower_motor_blocked': 'Motor bloqueado'
} %} {{ traducciones[error] if error in traducciones else error
}}
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
app: Cortacesped
icon: "56282"
color:
- 255
- 0
- 0
text: "{{ error_texto }}"
effect: Ripple
effectSettings:
speed: 10
palette: Heat
action: awtrix.custom_app
- conditions:
- condition: template
value_template: >-
{{ estado in ['mowing', 'returning', 'docked'] and not (estado ==
'docked' and battery == 100) }}
sequence:
- variables:
app_icon: >-
{% if estado == 'mowing' %} 44376 {% elif estado == 'returning'
%} 56282 {% elif estado == 'docked' %} 33126 {% endif %}
app_text: >-
{% if estado == 'mowing' %} {{ battery }}% {% elif estado ==
'returning' %} Base 100% {% elif estado == 'docked' %} {{
battery }}% {% endif %}
app_progress: >-
{% if estado == 'mowing' %} {{ 100 - battery }} {% elif estado
== 'returning' %} 100 {% elif estado == 'docked' %} {{ battery
}} {% endif %}
- data:
effect: none
device: 46f7de6ece2c1000d30f840b31d60be8
app: Cortacesped
icon: "{{ app_icon }}"
text: "{{ app_text }}"
progress: "{{ app_progress }}"
draw:
- dr:
- 10
- 1
- 4
- 6
- "#808080"
- dl:
- 11
- 0
- 12
- 0
- "#808080"
- df:
- 11
- "{{ 6 - battery_heght }}"
- 2
- "{{ battery_heght }}"
- "{{ battery_color }}"
progressC:
- 0
- 255
- 0
progressBC:
- 0
- 64
- 0
textOffset: 2
color:
- 0
- 255
- 255
action: awtrix.custom_app
- conditions:
- condition: state
entity_id: lawn_mower.landroid
state: idle
sequence:
- data:
effect: Ripple
effectSettings:
speed: 4
palette: Forest
device: 46f7de6ece2c1000d30f840b31d60be8
app: Cortacesped
icon: "68030"
color:
- 128
- 128
- 128
text: Detenido {{ battery }}%
action: awtrix.custom_app
default:
- action: awtrix.delete_custom_app
metadata: {}
data:
device: 46f7de6ece2c1000d30f840b31d60be8
app: Cortacesped
mode: single
alias: Mostrar métricas YouTube en Awtrix
description: Muestra suscriptores y visualizaciones con color especial en hitos
triggers:
- minutes: /5
trigger: time_pattern
conditions: []
actions:
- choose:
- conditions:
- condition: template
value_template: >
{% set subs =
states('sensor.hectorzin_domotica_y_home_assistant_suscriptores')
| int %} {{ subs % 500 < 10 }}
sequence:
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
text: >
{{
states('sensor.hectorzin_domotica_y_home_assistant_suscriptores')
}}
icon: "10247"
app: Suscriptores
rainbow: true
effect: Fireworks
action: awtrix.custom_app
- conditions: []
sequence:
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
text: >
{{
states('sensor.hectorzin_domotica_y_home_assistant_suscriptores')
}}
icon: "10247"
app: Suscriptores
color:
- 0
- 150
- 255
effect: none
action: awtrix.custom_app
- choose:
- conditions:
- condition: template
value_template: >
{% set views =
states('sensor.hectorzin_domotica_y_home_assistant_vistas') | int
%} {{ views % 50000 < 1000 }}
sequence:
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
text: |2
{{ (states('sensor.hectorzin_domotica_y_home_assistant_vistas') | float / 1000) | round(0) }} K
icon: "29056"
app: Visualizaciones
rainbow: true
effect: Fireworks
action: awtrix.custom_app
default:
- data:
device: 46f7de6ece2c1000d30f840b31d60be8
text: >
Visualizaciones: {{
(states('sensor.hectorzin_domotica_y_home_assistant_vistas') |
float / 1000) | round(0) }} K
icon: "29056"
app: Visualizaciones
color:
- 200
- 200
- 200
effect: none
action: awtrix.custom_app
enabled: false
- action: awtrix.delete_custom_app
metadata: {}
data:
device: 46f7de6ece2c1000d30f840b31d60be8
app: Visualizaciones
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment