-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
nordpool_cheap_prices.yaml
141 lines (141 loc) · 4.76 KB
/
nordpool_cheap_prices.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
blueprint:
name: Nordpool cheap hours
description:
This blueprints uses the nordpool integration and lets you choose how many hours
you will define as cheap, and make automations based on that information.
domain: automation
source_url: https://github.com/kullarkert/ha_nordpool_hours_blueprint/blob/main/nordpool_cheap_prices.yaml
input:
grid_area:
name: Grid area sensor
description: This is your grid area sensor
selector:
entity:
domain:
- sensor
integration: nordpool
multiple: false
cheap_hours:
name: Cheap hours
description: Number of cheap hours
default: 5
selector:
number:
min: 0.0
max: 24.0
mode: slider
step: 1.0
unit_of_measurement: "h"
# sequential:
# name: Sequential order
# description: "find cheap hours in sequential order"
# default: false
# selector:
# boolean:
# start_time:
# name: Start time
# description: "Input which describes the first time when the action should start."
# default: "00:00:00"
# selector:
# time: {}
# end_time:
# name: End time
# description: "Input which describes the last time when the action should end."
# default: "23:59:59"
# selector:
# time: {}
day_monday:
name: Run on Monday
description: Run the action on Monday.
default: true
selector:
boolean:
day_tuesday:
name: Run on Tuesday
description: Run the action on Tuesday.
default: true
selector:
boolean:
day_wednesday:
name: Run on Wednesday
description: Run the action on Wednesday.
default: true
selector:
boolean:
day_thursday:
name: Run on Thursday
description: Run the action on Thursday.
default: true
selector:
boolean:
day_friday:
name: Run on Friday
description: Run the action on Friday.
default: true
selector:
boolean:
day_saturday:
name: Run on Saturday
description: Run the action on Saturday.
default: true
selector:
boolean:
day_sunday:
name: Run on Sunday
description: Run the action on Sunday.
default: true
selector:
boolean:
expensive:
name: Expensive
description: Action to run on expensive hours
default: []
selector:
action: {}
cheap:
name: Cheap
description: Action to run on cheap hours
default: []
selector:
action: {}
variables:
grid_area_var: !input grid_area
cheap_hours_var: !input cheap_hours
# sequential_hours: !input sequential
# start_time: !input start_time
# end_time: !input end_time
day_monday: !input day_monday
day_tuesday: !input day_tuesday
day_wednesday: !input day_wednesday
day_thursday: !input day_thursday
day_friday: !input day_friday
day_saturday: !input day_saturday
day_sunday: !input day_sunday
trigger:
- platform: state
entity_id: !input grid_area
action:
- choose:
- conditions:
- condition: template
value_template: >-
{%- set today = now().weekday() -%}
{%- if (today == 0 and day_monday) or (today == 1 and day_tuesday) or (today == 2 and day_wednesday) or ( today == 3 and day_thursday) or (today == 4 and day_friday) or (today == 5 and day_saturday) or (today == 6 and day_sunday) -%}
{{ state_attr(grid_area_var, 'current_price')|float < (state_attr(grid_area_var,'today')|sort)[cheap_hours_var|int] }}
{%- else -%}
{{ false }}
{%- endif -%}
sequence: !input cheap
- conditions:
- condition: template
value_template: >-
{%- set today = now().weekday() -%}
{%- if (day_monday == false and today == 0) or (day_tuesday == false and today == 1) or (day_wednesday == false and today == 2) or (day_thursday == false and today == 3) or (day_friday == false and today == 4) or (day_thursday == false and today == 3) or (day_friday == false and today == 4) or (day_saturday == false and today == 5) or (day_sunday == false and today == 6) -%}
{{ false }}
{%- elif (today == 0 and day_monday) or (today == 1 and day_tuesday) or (today == 2 and day_wednesday) or ( today == 3 and day_thursday) or (today == 4 and day_friday) or (today == 5 and day_saturday) or (today == 6 and day_sunday) -%}
{{ state_attr(grid_area_var, 'current_price')|float > (state_attr(grid_area_var,'today')|sort)[cheap_hours_var|int] }}
{%- else -%}
{{ false }}
{%- endif -%}
sequence: !input expensive
default: []