Advertisement
314ma

gorsza jakość powietrza

Oct 21st, 2020 (edited)
485
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 0.95 KB | None | 0 0
  1. # Rozbite dla czytelności
  2.  
  3. {{ {
  4.   "a":"bardzo dobra",
  5.   "b":"dobra",
  6.   "c":"umiarkowana",
  7.   "d": "dostateczna",
  8.   "e":"zła",
  9.   "f":"bardzo zła"
  10.   }[[
  11.     states("sensor.syngeos_pm10_grade") | replace("grade-",""),
  12.     states("sensor.syngeos_pm2_5_grade") | replace("grade-","")
  13.   ] | max] }}
  14.  
  15.  
  16. # W jednej linijce
  17.  
  18. {{ {"a":"bardzo dobra", "b":"dobra", "c":"umiarkowana", "d": "dostateczna", "e":"zła", "f":"bardzo zła"}[[states("sensor.syngeos_pm10_grade") | replace("grade-",""),states("sensor.syngeos_pm2_5_grade") | replace("grade-","")] | max] }}
  19.  
  20. # Wersja if-else
  21.  
  22. {% set worse = [states("sensor.syngeos_pm10_grade"), states("sensor.syngeos_pm2_5_grade")] | max %}
  23. {% if worse == "grade-a" -%}
  24.   bardzo dobra
  25. {% elif worse == "grade-b" -%}
  26.   dobra
  27. {% elif worse == "grade-c" -%}
  28.   umiarkowana
  29. {% elif worse == "grade-d" -%}
  30.   dostateczna
  31. {% elif worse == "grade-e" -%}
  32.   zła
  33. {% elif worse == "grade-f" -%}
  34.   bardzo zła
  35. {% endif %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement