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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
| [
{
"id": "f7b2e0570b221e3c",
"type": "group",
"z": "cb9c080ed8873949",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"c66b3c6f61b0160e",
"d62cbbd33270e356",
"57dad89654eaa85f",
"01cd1d97c2dcc50e",
"970ffdaf75ad1a51",
"1e83eb87e2842a33",
"760e461295eae34e",
"7725695c1d13fb23",
"48fa89296ecae3b1",
"fe3d814d58b6d03e",
"826266e6ab1f05f5",
"de4f5338376f8573",
"a3a362f7f62045cf",
"7f18bf94cc62c44b",
"f6b0956158deeb6b"
],
"x": 34,
"y": 539,
"w": 1492,
"h": 362
},
{
"id": "c66b3c6f61b0160e",
"type": "victron-output-pvinverter",
"z": "cb9c080ed8873949",
"g": "f7b2e0570b221e3c",
"service": "com.victronenergy.pvinverter/20",
"path": "/Ac/PowerLimit",
"serviceObj": {
"service": "com.victronenergy.pvinverter/20",
"name": "SolarEdge SE7K",
"communityTag": "pvinverter"
},
"pathObj": {
"path": "/Ac/PowerLimit",
"type": "float",
"name": "Power limit (W)",
"mode": "both"
},
"name": "",
"onlyChanges": false,
"roundValues": "no",
"rateLimit": 0,
"outputs": 0,
"conditionalMode": false,
"condition1Operator": ">",
"condition2Enabled": false,
"condition2Service": "",
"condition2Path": "",
"condition2Operator": ">",
"logicOperator": "AND",
"outputTrue": "true",
"outputFalse": "false",
"outputOnChange": false,
"debounce": 2000,
"x": 1360,
"y": 800,
"wires": []
},
{
"id": "d62cbbd33270e356",
"type": "victron-input-pvinverter",
"z": "cb9c080ed8873949",
"g": "f7b2e0570b221e3c",
"service": "com.victronenergy.pvinverter/20",
"path": "/Ac/PowerLimit",
"serviceObj": {
"service": "com.victronenergy.pvinverter/20",
"name": "SolarEdge SE7K",
"communityTag": "pvinverter"
},
"pathObj": {
"path": "/Ac/PowerLimit",
"type": "float",
"name": "Power limit (W)",
"mode": "both"
},
"name": "Current limit",
"onlyChanges": false,
"roundValues": "1",
"rateLimit": 0,
"outputs": 1,
"conditionalMode": false,
"outputTrue": "true",
"outputFalse": "false",
"debounce": "2000",
"x": 1290,
"y": 860,
"wires": [
[]
]
},
{
"id": "57dad89654eaa85f",
"type": "vrm-api",
"z": "cb9c080ed8873949",
"g": "f7b2e0570b221e3c",
"vrm": "3eeec71798d41402",
"name": "VRM-API",
"api_type": "installations",
"idUser": "",
"usersQuery": "me",
"idSite": "123456",
"installations": "stats",
"attribute": "dynamic_ess",
"stats_interval": "hours",
"show_instance": false,
"stats_start": "bod",
"stats_end": "eod",
"use_utc": false,
"gps_start": "",
"gps_end": "",
"widgets": "",
"instance": "",
"store_in_global_context": false,
"verbose": false,
"transform_price_schedule": false,
"outputs": 1,
"x": 320,
"y": 760,
"wires": [
[
"1e83eb87e2842a33",
"760e461295eae34e"
]
]
},
{
"id": "01cd1d97c2dcc50e",
"type": "debug",
"z": "cb9c080ed8873949",
"g": "f7b2e0570b221e3c",
"name": "Check output",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 760,
"y": 700,
"wires": []
},
{
"id": "970ffdaf75ad1a51",
"type": "inject",
"z": "cb9c080ed8873949",
"g": "f7b2e0570b221e3c",
"name": "Trigger",
"props": [
{
"p": "payload"
}
],
"repeat": "300",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 140,
"y": 760,
"wires": [
[
"57dad89654eaa85f"
]
]
},
{
"id": "1e83eb87e2842a33",
"type": "function",
"z": "cb9c080ed8873949",
"g": "f7b2e0570b221e3c",
"name": "Get Current Price",
"func": "// Pak records uit de VRM API response\nconst records = msg.payload?.records;\n\nif (!records || !Array.isArray(records.deGb)) {\n node.status({\n fill: \"red\",\n shape: \"ring\",\n text: \"Geen deGb prijsdata gevonden\"\n });\n return null;\n}\n\n// deGb = grid buy prijs / inkoopprijs\nconst prices = records.deGb;\nconst now = Date.now();\n\nlet current = null;\n\n// Zoek de laatste prijs waarvan timestamp <= nu\nfor (const [ts, price] of prices) {\n if (ts <= now) {\n current = { ts, price };\n } else {\n break;\n }\n}\n\nif (!current) {\n node.status({\n fill: \"yellow\",\n shape: \"ring\",\n text: \"Geen actuele prijs gevonden\"\n });\n return null;\n}\n\n// Alleen de huidige prijs als payload\nmsg.payload = Number(current.price.toFixed(4));\n\n// Status voor controle\nnode.status({\n fill: \"green\",\n shape: \"dot\",\n text: `${msg.payload} €/kWh`\n});\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 530,
"y": 760,
"wires": [
[
"01cd1d97c2dcc50e",
"7725695c1d13fb23"
]
]
},
{
"id": "760e461295eae34e",
"type": "debug",
"z": "cb9c080ed8873949",
"g": "f7b2e0570b221e3c",
"name": "Check output",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 520,
"y": 700,
"wires": []
},
{
"id": "7725695c1d13fb23",
"type": "function",
"z": "cb9c080ed8873949",
"g": "f7b2e0570b221e3c",
"name": "Beslissen",
"func": "// Config\nconst NEGATIVE_LIMIT_W = 0;\nconst NORMAL_LIMIT_W = 7400; // SolarEdge SE7K normale limiet / vrijgave\n\n// Komt dit bericht van de virtual switch?\nconst isSwitchMsg = msg.pv_negative_switch_msg === true;\n\n// Laatste bekende prijs ophalen\nlet price = Number(flow.get(\"last_dynamic_price_eur_kwh\"));\n\n// Alleen bij prijsberichten payload als prijs behandelen\nif (!isSwitchMsg) {\n const incomingPrice = Number(msg.payload);\n\n if (!Number.isFinite(incomingPrice)) {\n node.status({\n fill: \"red\",\n shape: \"ring\",\n text: \"Geen geldige prijs\"\n });\n return [null, null, null];\n }\n\n price = incomingPrice;\n flow.set(\"last_dynamic_price_eur_kwh\", price);\n}\n\n// Stand van de virtuele switch\nconst enabled = flow.get(\"pv_to_0_when_negative_price\") === true;\n\n// Vorige negatieve toestand onthouden\nconst wasNegative = flow.get(\"pv_price_was_negative\") === true;\nconst isNegative = Number.isFinite(price) && price < 0;\n\n// Switch uit\nif (!enabled) {\n flow.set(\"pv_price_was_negative\", false);\n\n node.status({\n fill: \"grey\",\n shape: \"ring\",\n text: Number.isFinite(price)\n ? `OFF, prijs ${price.toFixed(4)} €/kWh → PV vrij`\n : \"OFF → PV vrij\"\n });\n\n // Alleen bij switchbericht direct herstellen en trigger resetten\n if (isSwitchMsg) {\n return [\n null,\n {\n reset: true,\n reason: \"manual disabled\"\n },\n {\n payload: NORMAL_LIMIT_W,\n topic: \"solar/powerlimit\",\n reason: \"manual disabled\"\n }\n ];\n }\n\n return [null, null, null];\n}\n\n// Switch aan, maar nog geen geldige prijs bekend\nif (!Number.isFinite(price)) {\n node.status({\n fill: \"yellow\",\n shape: \"ring\",\n text: \"ON, nog geen prijs bekend\"\n });\n\n return [null, null, null];\n}\n\n// Switch aan en prijs negatief: alleen bij overgang starten\nif (isNegative && !wasNegative) {\n flow.set(\"pv_price_was_negative\", true);\n\n node.status({\n fill: \"red\",\n shape: \"dot\",\n text: `ON, prijs ${price.toFixed(4)} €/kWh → PV 0 W`\n });\n\n return [\n {\n payload: NEGATIVE_LIMIT_W,\n topic: \"solar/powerlimit\",\n price: price\n },\n null,\n null\n ];\n}\n\n// Switch aan en prijs niet meer negatief: alleen bij overgang herstellen\nif (!isNegative && wasNegative) {\n flow.set(\"pv_price_was_negative\", false);\n\n node.status({\n fill: \"green\",\n shape: \"dot\",\n text: `ON, prijs ${price.toFixed(4)} €/kWh → PV vrij`\n });\n\n return [\n null,\n {\n reset: true,\n price: price,\n reason: \"price no longer negative\"\n },\n {\n payload: NORMAL_LIMIT_W,\n topic: \"solar/powerlimit\",\n price: price\n }\n ];\n}\n\n// Geen overgang, dus niets sturen\nnode.status({\n fill: isNegative ? \"red\" : \"green\",\n shape: \"ring\",\n text: isNegative\n ? `ON, negatief ${price.toFixed(4)} €/kWh`\n : `ON, prijs ${price.toFixed(4)} €/kWh`\n});\n\nreturn [null, null, null];",
"outputs": 3,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 740,
"y": 760,
"wires": [
[
"48fa89296ecae3b1",
"fe3d814d58b6d03e"
],
[
"48fa89296ecae3b1",
"fe3d814d58b6d03e"
],
[
"c66b3c6f61b0160e"
]
]
},
{
"id": "48fa89296ecae3b1",
"type": "trigger",
"z": "cb9c080ed8873949",
"g": "f7b2e0570b221e3c",
"name": "Repeat PV limit 0 while negative",
"op1": "",
"op2": "",
"op1type": "pay",
"op2type": "nul",
"duration": "-1",
"extend": false,
"overrideDelay": false,
"units": "s",
"reset": "",
"bytopic": "all",
"topic": "topic",
"outputs": 1,
"x": 1050,
"y": 760,
"wires": [
[
"c66b3c6f61b0160e",
"f6b0956158deeb6b"
]
]
},
{
"id": "fe3d814d58b6d03e",
"type": "debug",
"z": "cb9c080ed8873949",
"g": "f7b2e0570b221e3c",
"name": "Check",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 930,
"y": 840,
"wires": []
},
{
"id": "826266e6ab1f05f5",
"type": "victron-virtual-switch",
"z": "cb9c080ed8873949",
"g": "f7b2e0570b221e3c",
"name": "PV to 0 when negative price",
"outputs": 2,
"switch_1_type": 1,
"switch_1_initial": 0,
"switch_1_label": "",
"switch_1_customname": "PV to 0 when negative price",
"switch_1_group": "Nerdswitches",
"switch_1_include_measurement": false,
"switch_1_rgb_color_wheel": false,
"switch_1_cct_wheel": false,
"switch_1_rgb_white_dimmer": false,
"x": 200,
"y": 640,
"wires": [
[],
[
"de4f5338376f8573"
]
]
},
{
"id": "de4f5338376f8573",
"type": "function",
"z": "cb9c080ed8873949",
"g": "f7b2e0570b221e3c",
"name": "Store switch value",
"func": "const enabled = Number(msg.payload) === 1;\n\nflow.set(\"pv_to_0_when_negative_price\", enabled);\n\nnode.status({\n fill: enabled ? \"green\" : \"grey\",\n shape: \"dot\",\n text: enabled ? \"PV negative price: ON\" : \"PV negative price: OFF\"\n});\n\n// Marker voor de Beslissen-node\nmsg.pv_negative_switch_msg = true;\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 470,
"y": 640,
"wires": [
[
"a3a362f7f62045cf",
"7725695c1d13fb23"
]
]
},
{
"id": "a3a362f7f62045cf",
"type": "debug",
"z": "cb9c080ed8873949",
"g": "f7b2e0570b221e3c",
"name": "Check",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 670,
"y": 640,
"wires": []
},
{
"id": "7f18bf94cc62c44b",
"type": "comment",
"z": "cb9c080ed8873949",
"g": "f7b2e0570b221e3c",
"name": "PV to 0 when buy price negative (JGR 01mei26)",
"info": "",
"x": 240,
"y": 580,
"wires": []
},
{
"id": "f6b0956158deeb6b",
"type": "debug",
"z": "cb9c080ed8873949",
"g": "f7b2e0570b221e3c",
"name": "Check",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1270,
"y": 760,
"wires": []
},
{
"id": "3eeec71798d41402",
"type": "config-vrm-api",
"name": "VRM API",
"forceIpv4": false
},
{
"id": "c17b1b5dc3235643",
"type": "global-config",
"env": [],
"modules": {
"@victronenergy/node-red-contrib-victron": "1.6.63",
"victron-vrm-api": "0.3.11"
}
}
] |