forked from wernerhp/ha.integration.load_shedding
-
Notifications
You must be signed in to change notification settings - Fork 0
/
card4.yaml
105 lines (99 loc) · 4.04 KB
/
card4.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
type: vertical-stack
cards:
- type: custom:mushroom-chips-card
chips:
- type: entity
entity: sensor.load_shedding_stage_capetown
icon: ''
- type: entity
entity: sensor.load_shedding_stage_eskom
icon: ''
- type: entity
entity: sensor.load_shedding_area_eskde_14_milnertoncityofcapetownwesterncape
icon: ''
- type: template
content: '{{state_attr(entity, "count")}}/{{state_attr(entity, "limit")}}'
entity: sensor.load_shedding_sepush_quota
icon: mdi:api
tap_action:
action: more-info
alignment: center
- type: markdown
content: >
{% set stage_sensor = "sensor.load_shedding_stage_eskom" %}
{% set area_sensor =
"sensor.load_shedding_area_eskde_14_milnertoncityofcapetownwesterncape"
%}
{% 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")).total_seconds() | int // 60 %}
{% set mins = starts_in % 60 %}
{% set hrs = starts_in // 60 % 24 %}
{% set days = starts_in // 1440 %}
{% set alert = "Load Shedding starts in {d}d {h}h {m}m ({next})".format(d=days, m=mins, h=hrs, next=as_timestamp(start_time) | timestamp_custom("%H:%M", True)) %}
{% if starts_in > 1440 %}
<ha-alert alert-type="success">{{ states(stage_sensor) }}</ha-alert>
{% elif 60 < starts_in <= 1440 %}
<ha-alert alert-type="warning">{{ alert }}</ha-alert>
{% else %}
<ha-alert alert-type="error">{{ alert }}</ha-alert>
{% endif %}
{% else %}
{% set ends_in = timedelta(minutes=state_attr(area_sensor, "ends_in")).total_seconds() | int // 60 %}
{% set mins = ends_in % 60 %}
{% set hrs = ends_in // 60 % 24 %}
{% set days = ends_in // 1440 %}
{% set alert = "Load Shedding ends in {d}d {h}h {m}m ({next})".format(d=days, m=mins, h=hrs, next=as_timestamp(end_time) | timestamp_custom("%H:%M", True)) %}
<ha-alert alert-type="error">{{ alert }}</ha-alert>
{% endif %}
{% else %}
{% set stage = state_attr(stage_sensor, "next_stage") %}
{% set start_time = state_attr(stage_sensor, "next_start_time") %}
{% set end_time = state_attr(stage_sensor, "next_end_time") %}
{% set starts_in = timedelta(minutes=state_attr(stage_sensor, "starts_in")).total_seconds() | int // 60 %}
{% set mins = starts_in % 60 %}
{% set hrs = starts_in // 60 % 24 %}
{% set days = starts_in // 1440 %}
{% if (start_time == 0 or end_time == 0) %}
{% set alert = "No Load Shedding" %}
{% else %}
{% set alert = "Stage {stage} starts in {d}d {h}h {m}m ({next})".format(stage=stage, d=days, m=mins, h=hrs, next=as_timestamp(start_time) | timestamp_custom("%H:%M", True)) %}
{% endif %}
<ha-alert alert-type="success">{{ alert }}</ha-alert>
{% endif %}
- type: custom:atomic-calendar-revive
enableModeChange: true
firstDayOfWeek: 1
refreshInterval: 1800
entities:
- calendar.load_shedding_forecast
showCurrentEventLine: false
showMonth: true
showWeekDay: true
disableEventLink: true
showNoEventsForToday: true
disableLocationLink: true
showFullDayProgress: false
showEventIcon: false
showHiddenText: false
showCalendarName: false
calShowDescription: false
showLastCalendarWeek: true
disableCalEventLink: true
disableCalLocationLink: true
disableCalLink: true
showDescription: false
dateFormat: LL
showDate: false
sortByStartTime: false
showRelativeTime: true
showProgressBar: true
showLocation: true
showDeclined: true
showMultiDayEventParts: false
showMultiDay: false
showLoader: false
maxDaysToShow: 3