Skip to content

Commit

Permalink
Update status_alert.yaml
Browse files Browse the repository at this point in the history
Add check and set default
  • Loading branch information
wernerhp authored Nov 21, 2023
1 parent 3b5b61b commit b534366
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions examples/dashboards/status_alert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ content: >-
{%- endif -%}
{%- if is_state(area_sensor, "off") and starts_in and next_start and next_end -%}
{%- set next_in = starts_in -%}
{%- set next_in = starts_in if starts_in else 0 -%}
{%- if next_start == 0 or next_end == 0 -%}
{%- set next_time = as_timestamp(next_start, default=0.0) -%}
{%- set alert = "Stage {stage}".format(stage=next_stage) + " starts in {d}d {h}h {m}m ({next})" -%}
Expand All @@ -38,7 +38,7 @@ content: >-
{% endif %}
{%- elif is_state(area_sensor, "on") and ends_in -%}
{%- set next_time = as_timestamp(next_end, default=0.0) -%}
{%- set next_in = ends_in -%}
{%- set next_in = ends_in if ends_in else 0 -%}
{%- set alert = "Load Shedding ends in {d}d {h}h {m}m ({next})" -%}
{%- set alert_type = "error" -%}
{%- endif -%}
Expand All @@ -49,4 +49,4 @@ content: >-
{%- set days = next_in_sec // 1440 -%}
{%- set alert = alert.format(d=days, m=mins, h=hrs, next=next_time | timestamp_custom("%H:%M", True)) -%}
<ha-alert alert-type="{{ alert_type }}">{{ alert }}</ha-alert>
<ha-alert alert-type="{{ alert_type }}">{{ alert }}</ha-alert>

0 comments on commit b534366

Please sign in to comment.