Created
July 26, 2021 18:08
-
-
Save GuySie/f1473eb20048b0c9b9da50c30a7a5f47 to your computer and use it in GitHub Desktop.
Home Assistant Apple Watch Buienradar + Buienalarm Complication
This file contains 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
{%- if state_attr("sensor.neerslag_buienradar_regen_data","data") != "" %} | |
{%- set buienradarraw = state_attr("sensor.neerslag_buienradar_regen_data","data").split(' ') %} | |
{%- set raindata = namespace(list=[]) -%} | |
{%- for n in buienradarraw -%} | |
{%- set raindata.list = raindata.list + [n[0:3]] %} | |
{%- endfor -%} | |
{%- for fifteenminutes in raindata.list|batch(3) %} | |
{%- if loop.index > 8 %}{{""}} | |
{%- else %} | |
{%- set rainvalue = fifteenminutes|max|int %} | |
{%- set rainintensity = 10**((rainvalue-109)/32) %} | |
{%- if rainintensity < 0.1 %}{{"▁"}} | |
{%- elif 0.1 <= rainintensity < 0.5 %}{{"▂"}} | |
{%- elif 0.5 <= rainintensity < 1 %}{{"▃"}} | |
{%- elif 1 <= rainintensity < 1.5 %}{{"▄"}} | |
{%- elif 1.5 <= rainintensity < 2 %}{{"▅"}} | |
{%- elif 2 <= rainintensity < 3.5 %}{{"▆"}} | |
{%- elif 3.5 <= rainintensity < 5 %}{{"▇"}} | |
{%- elif 5 <= rainintensity < 10 %}{{"█"}} | |
{%- else %}{{"▓"}} | |
{%- endif %} | |
{%- endif %} | |
{%- endfor %} | |
{%- else %} | |
{%- set raindata = state_attr("sensor.neerslag_buienalarm_regen_data","data")["precip"] %} | |
{%- for fifteenminutes in raindata|batch(3) %} | |
{%- if loop.index > 8 %}{{""}} | |
{%- else %} | |
{%- set rainintensity = fifteenminutes|max %} | |
{%- if rainintensity < 0.1 %}{{"▁"}} | |
{%- elif 0.1 <= rainintensity < 0.5 %}{{"▂"}} | |
{%- elif 0.5 <= rainintensity < 1 %}{{"▃"}} | |
{%- elif 1 <= rainintensity < 1.5 %}{{"▄"}} | |
{%- elif 1.5 <= rainintensity < 2 %}{{"▅"}} | |
{%- elif 2 <= rainintensity < 3.5 %}{{"▆"}} | |
{%- elif 3.5 <= rainintensity < 5 %}{{"▇"}} | |
{%- elif 5 <= rainintensity < 10 %}{{"█"}} | |
{%- else %}{{"▓"}} | |
{%- endif %} | |
{%- endif %} | |
{%- endfor %} | |
{%- endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Happy to hear it works now!