Skip to content

Instantly share code, notes, and snippets.

@oldgitdaddy
Last active May 22, 2021 10:00
Show Gist options
  • Select an option

  • Save oldgitdaddy/a65eacd0205b1f9ef1f20548da71fdcf to your computer and use it in GitHub Desktop.

Select an option

Save oldgitdaddy/a65eacd0205b1f9ef1f20548da71fdcf to your computer and use it in GitHub Desktop.
Sensor informing you if there is a DWD warning NOW!
{% set dwd_warning = namespace(found=false)%}
{% if state_attr('sensor.dwd_weather_warnings_current_warning_level', 'warning_count') > 0 %}
{% for i in range(1, state_attr('sensor.dwd_weather_warnings_current_warning_level', 'warning_count')+1) %}
{% set start = as_timestamp(state_attr('sensor.dwd_weather_warnings_current_warning_level', 'warning_'~i~'_start'))%}
{% set end = as_timestamp(state_attr('sensor.dwd_weather_warnings_current_warning_level', 'warning_'~i~'_end'))%}
{% if start < as_timestamp(now()) < as_timestamp(now()) < end %}
{% set dwd_warning.found = true %}
{%endif%}
{%endfor%}
{%endif%}
{{dwd_warning.found}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment