forked from wernerhp/ha.integration.load_shedding
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcard3.yaml
70 lines (57 loc) · 2.89 KB
/
card3.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
type: vertical-stack
cards:
- type: markdown
content: >
{% set stage_sensor = "sensor.load_shedding_stage_eskom" %}
{% set area_sensor = "sensor.load_shedding_area_eskde_14_milnertoncityofcapetownwesterncape" %}
{% set start_time = state_attr(stage_sensor, "start_time") %} {% set
end_time = state_attr(stage_sensor, "end_time") %}
{% set area_schedule = state_attr(area_sensor, "forecast") %}
{% if area_schedule %}
{% set start_time = area_schedule[0].start_time %}
{% set end_time = area_schedule[0].end_time %}
{% if is_state(area_sensor, "off") %}
{% set starts_in = timedelta(minutes=state_attr(area_sensor, "starts_in")) %}
{% if is_state_attr(stage_sensor, "stage", 0) or starts_in.seconds > 86400 %}
<ha-alert alert-type="success">{{ states(stage_sensor) }}</ha-alert>
{% elif not is_state_attr(stage_sensor, "stage", 0) and 0 < starts_in.seconds <= 86400 %}
<ha-alert alert-type="warning">Load Shedding starts in {{ starts_in.seconds // 3600 }}h{{ (starts_in.seconds // 60) - (starts_in.seconds // 3600 * 60) }}m ({{ as_timestamp(start_time) | timestamp_custom("%H:%M", True) }})</ha-alert>
{% endif %}
{% else %}
{% set ends_in = timedelta(minutes=state_attr(area_sensor, "ends_in")) %}
{% if is_state_attr(stage_sensor, "stage", 0) or ends_in.seconds > 86400 %}
<ha-alert alert-type="success">{{ states(stage_sensor) }}</ha-alert>
{% elif not is_state_attr(stage_sensor, "stage", 0) and 0 < ends_in.seconds <= 86400 %}
<ha-alert alert-type="error">Load Shedding ends in {{ ends_in.seconds // 3600 }}h{{ (ends_in.seconds // 60) - (ends_in.seconds // 3600 * 60) }}m ({{ as_timestamp(end_time) | timestamp_custom("%H:%M", True) }})</ha-alert>
{% endif %}
{% endif %}
{% endif %}
{% set area_forecast = state_attr(area_sensor, "forecast" )%}
{% if area_forecast %}
<table width="100%" border=0>
<tbody>
{% for forecast in area_forecast[:3] %}
<tr>
<td align="left">
{{ as_timestamp(forecast.start_time) | timestamp_custom("%-d %B", True) }}
</td>
<td align="left">
{{ as_timestamp(forecast.start_time) | timestamp_custom("%H:%M", True) }} - {{ as_timestamp(forecast.end_time) | timestamp_custom("%H:%M", True) }}
</td>
<td align="right">Stage {{ forecast.stage }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
- type: custom:mushroom-template-card
primary: Quota {{state_attr(entity, "count")}}/{{state_attr(entity, "limit")}}
secondary: ''
icon: mdi:lightning-bolt
entity: sensor.load_shedding_sepush_quota
tap_action:
action: more-info
icon_color: ''
badge_icon: ''
fill_container: false
multiline_secondary: false