-
Notifications
You must be signed in to change notification settings - Fork 8
/
scripts.yaml
245 lines (242 loc) · 7.68 KB
/
scripts.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
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
set_solis_storage_toggles:
alias: Set Solis Storage Toggles
sequence:
- if:
- condition: template
value_template:
"{{states('sensor.solis_energy_storage_control_switch') |
int | bitwise_and(64) == 64}}"
then:
- service: input_boolean.turn_on
data: {}
target:
entity_id:
- input_boolean.solis_storage_mode_feed_in_priority
else:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.solis_storage_mode_feed_in_priority
- if:
- condition: template
value_template:
"{{states('sensor.solis_energy_storage_control_switch') |
int | bitwise_and(32) == 32}}"
then:
- service: input_boolean.turn_on
data: {}
target:
entity_id:
- input_boolean.solis_storage_mode_grid_charge
else:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.solis_storage_mode_grid_charge
- if:
- condition: template
value_template:
"{{states('sensor.solis_energy_storage_control_switch') |
int | bitwise_and(16) == 16}}"
then:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.solis_storage_mode_backup
else:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.solis_storage_mode_backup
- if:
- condition: template
value_template:
"{{states('sensor.solis_energy_storage_control_switch') |
int | bitwise_and(8) == 8}}"
then:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.solis_storage_mode_wake_up
else:
- service: input_boolean.turn_off
data: {}
target:
entity_id:
- input_boolean.solis_storage_mode_wake_up
- if:
- condition: template
value_template:
"{{states('sensor.solis_energy_storage_control_switch') |
int | bitwise_and(4) == 4}}"
then:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.solis_storage_mode_off_grid
else:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.solis_storage_mode_off_grid
- if:
- condition: template
value_template:
"{{states('sensor.solis_energy_storage_control_switch') |
int | bitwise_and(2) == 2}}"
then:
- service: input_boolean.turn_on
data: {}
target:
entity_id:
- input_boolean.solis_storage_mode_timed
else:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.solis_storage_mode_timed
- if:
- condition: template
value_template:
"{{states('sensor.solis_energy_storage_control_switch') |
int | bitwise_and(1) == 1}}"
then:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.solis_storage_mode_spontaneous
else:
- service: input_boolean.turn_off
data: {}
target:
entity_id:
- input_boolean.solis_storage_mode_spontaneous
mode: single
icon: mdi:toggle-switch-off-outline
solis_set_time:
alias: Solis Set Time
sequence:
- service: script.solis_write_holding_register
data:
register_addr: 43003
register_value: '{{now().hour}}'
- service: script.solis_write_holding_register
data:
register_addr: 43004
register_value: '{{now().minute}}'
- service: script.solis_write_holding_register
data:
register_addr: 43005
register_value: '{{now().second}}'
mode: single
solis_set_energy_storage_mode:
alias: Solis Set Energy Storage Mode
fields:
storage_mode:
description: Storage Mode to Set (uint16)
example: 35
sequence:
- service: script.solis_write_holding_register
data:
register_addr: 43110
register_value:
"{{(states('input_boolean.solis_storage_mode_spontaneous')
== 'on') | int + 2 * (states('input_boolean.solis_storage_mode_timed')
== 'on') | int + 4 * (states('input_boolean.solis_storage_mode_off_grid')
== 'on') | int + 8 * (states('input_boolean.solis_storage_mode_wake_up')
== 'on') | int + 16 * (states('input_boolean.solis_storage_mode_backup')
== 'on') | int + 32 * (states('input_boolean.solis_storage_mode_grid_charge')
== 'on') | int }}"
mode: single
solis_set_charge_current:
alias: Solis Set Charge Current
fields:
solis_set_charge_current:
description: Fixed time charge current (A)
example: 50
sequence:
- service: script.solis_write_holding_register
data:
register_addr: 43141
register_value: "{{ charge_current * 10 }}"
mode: single
solis_write_holding_register:
alias: Solis Write Holding Register
fields:
register_addr:
description: Holding address to write to
example: 43141
register_value:
description: Value to write to holding address
example: 500
sequence:
- service: modbus.write_register
data:
address: "{{ register_addr }}"
slave: 1
value: "{{ register_value }}"
hub: solis
- service: logbook.log
data:
message: Send {{register_value}} to {{register_addr}}
name: Solis Write
solis_set_eco7_times:
alias: Solis Set Eco7 Times
sequence:
- service: script.solis_write_holding_register
data:
register_addr: 43143
register_value:
"{{(states('input_datetime.economy_7_start')).split(':')[0]
| int}}"
- service: script.solis_write_holding_register
data:
register_addr: 43144
register_value:
"{{(states('input_datetime.economy_7_start')).split(':')[1]
| int}}"
- service: script.solis_write_holding_register
data:
register_addr: 43145
register_value:
"{{(states('input_datetime.economy_7_end')).split(':')[0]
| int}}"
- service: script.solis_write_holding_register
data:
register_addr: 43146
register_value:
"{{(states('input_datetime.economy_7_end')).split(':')[1]
| int}}"
mode: single
icon: mdi:battery-clock-outline
alias: "Solis Set Discharge Current "
sequence:
- service: script.solis_write_holding_register
data:
register_addr: 43142
register_value: "{{ discharge_current * 10 }}"
fields:
solis_set_charge_current:
description: Fixed time charge current (A)
example: 50
mode: single
alias: Solis Set Discharge Times
sequence:
- service: script.solis_write_holding_register
data:
register_addr: 43147
register_value: "{{(states('input_datetime.flux_discharge_start')).split(':')[0] | int}}"
- service: script.solis_write_holding_register
data:
register_addr: 43148
register_value: "{{(states('input_datetime.flux_discharge_start')).split(':')[1] | int}}"
- service: script.solis_write_holding_register
data:
register_addr: 43149
register_value: "{{(states('input_datetime.flux_discharge_end')).split(':')[0] | int}}"
- service: script.solis_write_holding_register
data:
register_addr: 43150
register_value: "{{(states('input_datetime.flux_discharge_end')).split(':')[1] | int}}"
mode: single
icon: mdi:battery-clock-outline