Non, ce n’est pas une automatisation, c’est bien un template trigger. C’est comme une automatisation, mais pour un sensor.
Oui, c’est possible. J’utilisais ce template pour un ESP à la base pour me faciliter les données. Je l’ai réutilisé pour openhasp.
Exemple de mon openhasp.yaml :
- obj: "p2b149" # Current weather icon j0
properties:
"text": >
{% if states('sensor.meteo_xxxx_j0') == "clear-night" -%}
{{ "\uE594" }}
{% elif states('sensor.meteo_xxxx_j0') == 'cloudy' -%}
{{ "\uE590" }}
{% elif states('sensor.meteo_xxxx_j0') == 'fog' -%}
{{ "\uE591" }}
{% elif states('sensor.meteo_xxxx_j0') == 'hail' -%}
{{ "\uE592" }}
{% elif states('sensor.meteo_xxxx_j0') == 'lightning' -%}
{{ "\uE593" }}
{% elif states('sensor.meteo_xxxx_j0') == 'lightning-rainy' -%}
{{ "\uE67E" }}
{% elif states('sensor.meteo_xxxx_j0') == 'partlycloudy' -%}
{{ "\uE595" }}
{% elif states('sensor.meteo_xxxx_j0') == 'pouring' -%}
{{ "\uE596" }}
{% elif states('sensor.meteo_xxxx_j0') == 'rainy' -%}
{{ "\uE597" }}
{% elif states('sensor.meteo_xxxx_j0') == 'snowy' -%}
{{ "\uE598" }}
{% elif states('sensor.meteo_xxxx_j0') == 'snowy-rainy' -%}
{{ "\uE67F" }}
{% elif states('sensor.meteo_xxxx_j0') == 'sunny' -%}
{{ "\uE5A8" }}
{% elif states('sensor.meteo_xxxx_j0') == 'windy' -%}
{{ "\uE59D" }}
{% elif states('sensor.meteo_xxxx_j0') == 'windy-variant' -%}
{{ "\uE59E" }}
{% elif states('sensor.meteo_xxxx_j0') == 'unavailable' -%}
{{ "\uE156" }}
{% else -%}
{{ "\uE5A8" }}
{% endif -%}
- obj: "p2b150" # Current weather icon j1
properties:
"text": >
{% if states('sensor.meteo_xxxx_j1') == "clear-night" -%}
{{ "\uE594" }}
{% elif states('sensor.meteo_xxxx_j1') == 'cloudy' -%}
{{ "\uE590" }}
{% elif states('sensor.meteo_xxxx_j1') == 'fog' -%}
{{ "\uE591" }}
{% elif states('sensor.meteo_xxxx_j1') == 'hail' -%}
{{ "\uE592" }}
{% elif states('sensor.meteo_xxxx_j1') == 'lightning' -%}
{{ "\uE593" }}
{% elif states('sensor.meteo_xxxx_j1') == 'lightning-rainy' -%}
{{ "\uE67E" }}
{% elif states('sensor.meteo_xxxx_j1') == 'partlycloudy' -%}
{{ "\uE595" }}
{% elif states('sensor.meteo_xxxx_j1') == 'pouring' -%}
{{ "\uE596" }}
{% elif states('sensor.meteo_xxxx_j1') == 'rainy' -%}
{{ "\uE597" }}
{% elif states('sensor.meteo_xxxx_j1') == 'snowy' -%}
{{ "\uE598" }}
{% elif states('sensor.meteo_xxxx_j1') == 'snowy-rainy' -%}
{{ "\uE67F" }}
{% elif states('sensor.meteo_xxxx_j1') == 'sunny' -%}
{{ "\uE5A8" }}
{% elif states('sensor.meteo_xxxx_j1') == 'windy' -%}
{{ "\uE59D" }}
{% elif states('sensor.meteo_xxxx_j1') == 'windy-variant' -%}
{{ "\uE59E" }}
{% elif states('sensor.meteo_xxxx_j1') == 'unavailable' -%}
{{ "\uE156" }}
{% else -%}
{{ "\uE5A8" }}
{% endif -%}
- obj: "p2b151"
properties:
"text": "{{ state_attr('sensor.meteo_xxxx_j0','temperature') }}°C"
- obj: "p2b152"
properties:
"text": "{{ state_attr('sensor.meteo_xxxx_j0','templow') }}°C"
- obj: "p2b155"
properties:
"text": "{{ state_attr('sensor.meteo_xxxx_j0','humidite') }}%"
- obj: "p2b157"
properties:
"text": "{{ state_attr('sensor.meteo_xxxx_j0','precipitation') |float(0) |round(0)}}mm"
- obj: "p2b159"
properties:
"text": "{{ state_attr('sensor.meteo_xxxx_j1','temperature') }}°C"
- obj: "p2b160"
properties:
"text": "{{ state_attr('sensor.meteo_xxxx_j1','templow') }}°C"
- obj: "p2b163"
properties:
"text": "{{ state_attr('sensor.meteo_xxxx_j1','humidite') }}%"
- obj: "p2b165"
properties:
"text": "{{ state_attr('sensor.meteo_xxxx_j1','precipitation') |float(0) |round(0) }}mm"
exemple du page.jsonl:
{"page":2,"id":102,"obj":"label","x":575,"y":45,"w":140,"h":25,"text":"Aujourd'hui","text_font":16,"align":1,"text_color":"#2C3E50"}
{"page":2,"id":103,"obj":"label","x":695,"y":45,"w":100,"h":25,"text":"Demain","text_font":16,"align":1,"text_color":"#2C3E50"}
{"page":2,"id":149,"obj":"btn","x":615,"y":75,"w":58,"h":60,"toggle":false,"text":"\uE5A8","text_font":50,"border_side":0,"bg_color":"#2C3E50","text_color":"#FFFFFF"}
{"page":2,"id":150,"obj":"btn","x":715,"y":75,"w":58,"h":60,"toggle":false,"text":"\uE5A8","text_font":50,"border_side":0,"bg_color":"#2C3E50","text_color":"#FFFFFF"}
{"page":2,"id":151,"obj":"label","x":625,"y":145,"w":70,"h":22,"text":"00.0°C","text_font":22,"align":0,"text_color":"#ff0000"}
{"page":2,"id":152,"obj":"label","x":625,"y":169,"w":70,"h":22,"text":"00.0°C","text_font":22,"align":0,"text_color":"#0000ff"}
{"page":2,"id":153,"obj":"label","x":596,"y":142,"w":24,"h":26,"text":"\uE50F","text_font":24,"align":0,"text_color":"#ff0000"}
{"page":2,"id":154,"obj":"label","x":596,"y":166,"w":24,"h":26,"text":"\uE50F","text_font":24,"align":0,"text_color":"#0000ff"}
{"page":2,"id":155,"obj":"label","x":625,"y":194,"w":70,"h":22,"text":"00%","text_font":22,"align":0,"text_color":"#0000ff"}
{"page":2,"id":156,"obj":"label","x":596,"y":191,"w":24,"h":26,"text":"\uE58E","text_font":24,"align":0,"text_color":"#0000ff"}
{"page":2,"id":157,"obj":"label","x":625,"y":218,"w":75,"h":22,"text":"00.0mm","text_font":22,"align":0,"text_color":"#2C3E50"}
{"page":2,"id":158,"obj":"label","x":596,"y":215,"w":24,"h":26,"text":"\uE58C","text_font":24,"align":0,"text_color":"#2C3E50"}
{"page":2,"id":159,"obj":"label","x":725,"y":145,"w":70,"h":22,"text":"00.0°C","text_font":22,"align":0,"text_color":"#ff0000"}
{"page":2,"id":160,"obj":"label","x":725,"y":169,"w":70,"h":22,"text":"00.0°C","text_font":22,"align":0,"text_color":"#0000ff"}
{"page":2,"id":161,"obj":"label","x":696,"y":142,"w":24,"h":26,"text":"\uE50F","text_font":24,"align":0,"text_color":"#ff0000"}
{"page":2,"id":162,"obj":"label","x":696,"y":166,"w":24,"h":26,"text":"\uE50F","text_font":24,"align":0,"text_color":"#0000ff"}
{"page":2,"id":163,"obj":"label","x":725,"y":194,"w":70,"h":22,"text":"00%","text_font":22,"align":0,"text_color":"#0000ff"}
{"page":2,"id":164,"obj":"label","x":696,"y":191,"w":24,"h":26,"text":"\uE58E","text_font":24,"align":0,"text_color":"#0000ff"}
{"page":2,"id":165,"obj":"label","x":725,"y":218,"w":75,"h":22,"text":"00.0mm","text_font":22,"align":0,"text_color":"#2C3E50"}
Résultat sur l’écran :
Après, tu adaptes à ton besoin 