-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscripts.yaml
More file actions
278 lines (272 loc) · 8.13 KB
/
scripts.yaml
File metadata and controls
278 lines (272 loc) · 8.13 KB
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
'1581685010172':
alias: Turn off all lights
sequence:
- data:
entity_id: all
action: light.turn_off
description: ''
toggle_dnd:
alias: Toggle DND
sequence:
- service: input_boolean.toggle
target:
entity_id: input_boolean.do_not_disturb
mode: single
icon: mdi:volume-off
fade_volume:
alias: Fade the volume of a media player
mode: parallel
fields:
target_player:
name: Target media player
description: Target media player of volume fade.
required: true
example: media_player.lounge_sonos
selector:
entity:
domain: media_player
target_volume:
name: Target volume
description: Volume the media play will be at the end of the fade duration.
required: true
default: 0.5
example: '0.5'
selector:
number:
max: 1
min: 0
step: 0.01
mode: slider
duration:
name: Fade duration
description: Length of time in seconds the fade should take.
required: true
default: 5
example: '5'
selector:
number:
mode: box
min: 0
max: 100000
unit_of_measurement: s
curve:
name: Fade curve algorithm
description: Shape of the fade curve to apply.
required: true
default: logarithmic
example: logarithmic
selector:
select:
options:
- logarithmic
- bezier
- linear
variables:
steps_per_second: 10
total_steps: '{{ (steps_per_second * duration) | int(0) }}'
start_volume: '{{ state_attr(target_player, ''volume_level'') | float(0) }}'
start_diff: '{{ (target_volume - start_volume) | float(0) }}'
sequence:
- repeat:
while:
- condition: template
value_template: '{{ repeat.index < total_steps }}'
- condition: template
value_template: '{{ ((state_attr(target_player, "volume_level") - target_volume)
| abs) > 0.001 }}'
sequence:
- service: media_player.volume_set
data_template:
entity_id: '{{ target_player }}'
volume_level: "{% set t = repeat.index / total_steps %} {% if curve == 'logarithmic'
%}\n {{ (start_volume + (t / (1 + (1 - t))) * start_diff) | float(0)
}}\n{% elif curve == 'bezier' %}\n {{ (start_volume + (t * t * (3 - 2
* t)) * start_diff) | float(0) }}\n{% else %}\n {{ (start_volume + t
* start_diff) | float(0) }}\n{% endif %}\n"
- delay: '00:00:00.1'
- service: media_player.volume_set
data_template:
entity_id: '{{ target_player }}'
volume_level: '{{ target_volume }}'
icon: mdi:tune-vertical
nudge_blind_open:
alias: nudge_blind_open
fields:
target_blind:
name: Target blind
description: Target blind to nudge.
required: true
example: cover.office_blind
selector:
entity:
domain: cover
sequence:
- target:
entity_id: '{{target_blind}}'
data_template:
position: '{{ min([100,state_attr(''cover.office_blind'',''current_position'')
| int + 10]) }}'
action: cover.set_cover_position
mode: single
icon: mdi:archive-arrow-up
nudge_blind_closed:
alias: nudge_blind_closed
fields:
target_blind:
name: Target blind
description: Target blind to nudge.
required: true
example: cover.office_blind
selector:
entity:
domain: cover
sequence:
- target:
entity_id: '{{target_blind}}'
data_template:
position: '{{ max([0, state_attr(''cover.office_blind'',''current_position'')
| int - 10]) }}'
action: cover.set_cover_position
mode: single
icon: mdi:archive-arrow-down
nudge_light_brighter:
alias: nudge_light_brighter
fields:
target_light:
name: Target light
description: Target light to nudge.
required: true
example: light.office_ceiling
selector:
entity:
domain: light
sequence:
- service: light.turn_on
data:
entity_id: '{{ target_light }}'
brightness: '{{ min([255,states.light.second_bedroom_ceiling.attributes.brightness
| int + 25]) }}'
mode: single
icon: mdi:upload
nudge_light_dimmer:
alias: nudge_light_dimmer
fields:
target_light:
name: Target light
description: Target light to nudge.
required: true
example: light.office_ceiling
selector:
entity:
domain: light
sequence:
- service: light.turn_on
data:
entity_id: '{{ target_light }}'
brightness: '{{ max([0,states.light.second_bedroom_ceiling.attributes.brightness
| int - 25]) }}'
mode: single
icon: mdi:upload
kitchen_dashboard:
sequence:
- service: cast.show_lovelace_view
data:
entity_id: media_player.kitchen_display
dashboard_path: live-energy
view_path: cast
mode: single
icon: mdi:home-battery-outline
energy_dashboard:
alias: EnergyDashboard
sequence:
- service: cast.show_lovelace_view
data:
entity_id: media_player.living_room_display
dashboard_path: live-energy
view_path: cast
mode: single
icon: mdi:home-battery-outline
solax_force_charge:
alias: Force Charge Solax Battery
sequence:
- action: input_number.set_value
data:
value: '{{now().hour + now().minute * 256}}
'
target:
entity_id: input_number.solax_forced_charge_start
- repeat:
sequence:
- data:
level: '{{states(''input_number.solax_battery_soc_target'') | int}}
'
action: rest_command.solax_local_charge_battery_from_grid
- delay:
seconds: 10
- data:
value: '{{states(''input_number.solax_forced_charge_start'') | int}}
'
action: rest_command.solax_local_set_forced_charge_start
- data:
message: 'Home battery set to charge from grid to {{states(''input_number.solax_battery_soc_target'')}}%
for {{states(''input_number.solax_force_charge_duration_mins'')}} minutes.
Attempt: {{repeat.index}}'
title: "\U0001F324 Solar"
action: notify.mobile_app_toms_phone
- delay:
seconds: 10
- data: {}
target:
entity_id: sensor.solax_rest_local_settings
action: homeassistant.update_entity
- delay:
seconds: 10
until:
- condition: template
value_template: '{{((states(''sensor.solax_local_battery_setting_start_charge'').split(":")[0]|int
+ states(''sensor.solax_local_battery_setting_start_charge'').split(":")[1]|int
* 256) == states(''input_number.solax_forced_charge_start'') | int) or repeat.index==3}}'
- wait_template: '{{states(''sensor.solax_local_battery_soc'')|int >= states(''input_number.solax_battery_soc_target'')|int}}'
timeout:
minutes: '{{states(''input_number.solax_force_charge_duration_mins'') | int}}'
- data:
level: '{{10 if now().hour > 16 else 100}}
'
action: rest_command.solax_local_charge_battery_from_grid
- delay:
seconds: 10
- data:
value: "{{5 + 30 * 256}} \n"
action: rest_command.solax_local_set_forced_charge_start
mode: restart
solax_reset_force_charge:
sequence:
- repeat:
sequence:
- data:
level: '{{10 if now().hour > 16 else 100}}
'
action: rest_command.solax_local_charge_battery_from_grid
- delay:
seconds: 10
- data:
value: '{{5 + 30 * 256}}
'
action: rest_command.solax_local_set_forced_charge_start
- delay:
seconds: 10
- data: {}
target:
entity_id:
- sensor.solax_rest_local_settings
action: homeassistant.update_entity
- delay:
seconds: 10
until:
- condition: template
value_template: '{{states(''sensor.solax_local_battery_charge_from_grid_to'')
| int == (10 if now().hour > 16 else 100)}}'
- condition: template
value_template: '{{(states(''sensor.solax_local_battery_setting_start_charge'').split('':'')[0]|int
+ states(''sensor.solax_local_battery_setting_start_charge'').split('':'')[1]|int
* 256) == (5 + 30 * 256)}}'