Advertisement
energywave

Prove sensore quantità pioggia di fallback

May 25th, 2022
1,072
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.02 KB | None | 0 0
  1. [MAX STYLE]
  2. {% set rain =
  3.    [
  4.      {'state': 'rainy', 'value': 1},
  5.      {'state': 'lightning-rainy', 'value': 1},
  6.      {'state': 'pouring', 'value': 0.5},
  7.      {'state': 'snowy', 'value': 1},
  8.      {'state': 'snowy-rainy', 'value': 1},
  9.      {'state': 'exceptional', 'value': 2},
  10.      {'state': 'default', 'value': 0}
  11.    ]
  12. %}
  13. {% set weather = states('weather.casa') if (rain | selectattr('state', 'eq', states('weather.casa')) | list | count) > 0 else 'default' %}
  14. {{ rain | selectattr('state', 'eq', weather) | map(attribute='value') | first | float(0)}}
  15.  
  16. [DEBUG]
  17. weather.casa = {{ states('weather.casa') }}
  18. variabile weather = {{ weather }}
  19.  
  20. [VITO STYLE]
  21. {% if is_state('weather.casa', 'rainy') %}
  22.   1.0
  23. {% elif is_state('weather.casa', 'lightning-rainy') %}
  24.   1.0
  25. {% elif is_state('weather.casa', 'pouring') %}
  26.   0.5
  27. {% elif is_state('weather.casa', 'snowy') %}
  28.   1.0
  29. {% elif is_state('weather.casa', 'snowy-rainy') %}
  30.   1.0
  31. {% elif is_state('weather.casa', 'exceptional') %}
  32.   2.0
  33. {% else %}
  34.   0.0
  35. {% endif %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement