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
| [
{
"id": "c967fe73764d8038",
"type": "ui_date_picker",
"z": "a0328760f2e5cef0",
"name": "",
"label": "Selecteer een datum",
"group": "a3a6f615e04fd3c6",
"order": 1,
"width": "5",
"height": "1",
"passthru": true,
"topic": "",
"topicType": "str",
"className": "",
"x": 180,
"y": 440,
"wires": [
[
"3794bd96f6b22e4c"
]
]
},
{
"id": "20f2b9beaf8bef75",
"type": "inject",
"z": "a0328760f2e5cef0",
"name": "Inject date",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 160,
"y": 400,
"wires": [
[
"3794bd96f6b22e4c"
]
]
},
{
"id": "3794bd96f6b22e4c",
"type": "function",
"z": "a0328760f2e5cef0",
"name": "Format date",
"func": "var date = new Date(msg.payload);\nvar formattedDate = date.getDate().toString().padStart(2, '0') + '-' + (date.getMonth() + 1).toString().padStart(2, '0') + '-' + date.getFullYear();\n\nmsg.payload = formattedDate;\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 370,
"y": 400,
"wires": [
[
"073ef44c96642daa",
"c34f2cb3a4e7fb22",
"2740bd4bfd135ed3",
"02b877d7fc846351",
"066b0ce19217c986",
"9d1be6f21afafda9",
"d17acb6bfef820c2",
"dc58a0fabad79bd4",
"b43261327e655730",
"26d746ca0bc46e0e",
"f19e1fe3efcf01a8",
"b83f8f753ce882b7",
"9bc607f9ba2ebcee",
"9f2d3e1ce3d6dab8",
"e0311bee8d1633f6",
"9265f9c5b637448c",
"e73a4fc542e38d13",
"a5bad3e0e969d949",
"cdc16fa00298e81a",
"a4205c619f8d68d8",
"df8189cf17e50c8e",
"423001fa543d67ad",
"e2dd87dcddd553c3",
"13e19fac452871b6",
"042d049f474e0fcc",
"8caf11bf16e957d3"
]
]
},
{
"id": "073ef44c96642daa",
"type": "change",
"z": "a0328760f2e5cef0",
"name": "Add cookie header",
"rules": [
{
"t": "set",
"p": "headers.Cookie",
"pt": "msg",
"to": "form_token=Secret1; _enlighten_4_session=Secret2",
"tot": "str"
},
{
"t": "set",
"p": "url",
"pt": "msg",
"to": "\"https://enlighten.enphaseenergy.com/systems/2139320/inverters/46974739/time_series_x?&date=\" & $replace(msg.payload, \" \", \"%20\") & \"&stat=POWR\"",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 750,
"y": 260,
"wires": [
[
"8c7afe2a524764b3"
]
]
},
{
"id": "8c7afe2a524764b3",
"type": "http request",
"z": "a0328760f2e5cef0",
"name": "",
"method": "GET",
"ret": "txt",
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"x": 1030,
"y": 420,
"wires": [
[
"a800e610b7fbfdaf"
]
]
},
{
"id": "a800e610b7fbfdaf",
"type": "json",
"z": "a0328760f2e5cef0",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 1210,
"y": 420,
"wires": [
[
"7cef57a21b14be07"
]
]
},
{
"id": "7cef57a21b14be07",
"type": "join",
"z": "a0328760f2e5cef0",
"name": "",
"mode": "custom",
"build": "array",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": false,
"timeout": "5",
"count": "26",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "num",
"reduceFixup": "",
"x": 1370,
"y": 420,
"wires": [
[
"29e82ba2ddb049b1"
]
]
},
{
"id": "29e82ba2ddb049b1",
"type": "function",
"z": "a0328760f2e5cef0",
"name": "Extract Power",
"func": "// Initialiseren van de datastructuren\nvar data = [[], []];\nvar labels = [];\nvar ch_id = [];\nvar date = [];\nvar POWR = [];\n\n// Itereren over de berichten\nfor (var i = 0; i < msg.payload.length; i++) {\n // Extracting the data from the message\n ch_id[i] = msg.payload[i].ch_id;\n date = msg.payload[i].date;\n POWR[i] = msg.payload[i].POWR;\n\n // Initialiseren van de data array\n data[i] = [];\n\n // Extracting the data from the POWR array\n for (var j = 0; j < POWR[i].length; j++) {\n var epoch = POWR[i][j][0] * 1000;\n var watts = POWR[i][j][1];\n\n // Pushing the data to the correct arrays\n data[i][j] = {\"x\": epoch, \"y\": watts};\n }\n\n // Pushing the label to the labels array\n labels.push(date);\n}\n\n// Creating the chart object\nvar chart = [{ \"series\": ch_id, \"data\": data, \"labels\": labels}];\n\n// Setting the chart object as the payload\nmsg.payload = chart;\n\n// Returning the modified message\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 1560,
"y": 420,
"wires": [
[
"bd95aa280c6725a0"
]
]
},
{
"id": "bd95aa280c6725a0",
"type": "function",
"z": "a0328760f2e5cef0",
"name": "hernoem panelen",
"func": "var series = msg.payload[0].series.map(function(ch_id) {\n switch (ch_id) {\ncase 46974739: return 'G1';\ncase 46974736: return 'G2';\ncase 46974742: return 'G3';\ncase 46975385: return 'A8';\ncase 46974732: return 'G4';\ncase 46975300: return 'V8';\ncase 46974733: return 'K1';\ncase 46974737: return 'G5';\ncase 46976170: return 'V7';\ncase 46976165: return 'A7';\ncase 46974728: return 'G6';\ncase 46974735: return 'K2';\ncase 46974730: return 'A4';\ncase 46974734: return 'A1';\ncase 46974729: return 'G7';\ncase 46974731: return 'A3';\ncase 46974741: return 'A5';\ncase 46974740: return 'A6';\ncase 46974738: return 'K3';\ncase 46976167: return 'V2';\ncase 46976166: return 'V3';\ncase 46976172: return 'V4';\ncase 46976168: return 'V1';\ncase 46976171: return 'V5';\ncase 46976169: return 'V6';\ncase 46974727: return 'A2';\n // voeg hier extra cases toe voor andere ch_id's\n default:\n return ch_id;\n }\n});\n\n// Maak het bijgewerkte chart object\nvar chart = [{\n \"series\": series,\n \"data\": msg.payload[0].data,\n \"labels\": msg.payload[0].labels\n}];\n\n// Stel de payload in op het bijgewerkte chart object\nmsg.payload = chart;\nmsg.ui_control = {\"colors\":['#000000','#F1FC08','#E0CD00','#F5DA63','#E0A100','#FF9E00','#F5C501','#FCFB5D','#FFC266','#7D1EFC','#3514E0','#7885F5','#145DE0','#145DE0','#A65DFC','#0113F5','#66BEFF','#00F545','#08FCC7','#64FF00','#FF6900','#E03A04','#F57067','#E00456','#F605EF','#FFA66B','#F362F6']};\n\n\n// Stuur de bijgewerkte msg terug\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 1790,
"y": 420,
"wires": [
[
"0c5e8225d4720d26",
"d0b29681d84e1614"
]
]
},
{
"id": "d0b29681d84e1614",
"type": "function",
"z": "a0328760f2e5cef0",
"name": "Volgorde grafiek",
"func": "// Extract data from the message payload\nvar data = msg.payload[0].data;\nvar labels = msg.payload[0].labels;\nvar series = msg.payload[0].series;\n\n// Combine data, labels, and series into one array of objects\nvar chartData = [];\nfor (var i = 0; i < series.length; i++) {\n chartData.push({\n series: series[i],\n data: data[i],\n label: labels[i]\n });\n}\n\n// Sort the chart data array by series name\nchartData.sort(function(a, b) {\n var nameA = a.series.toUpperCase(); // ignore upper and lowercase\n var nameB = b.series.toUpperCase(); // ignore upper and lowercase\n if (nameA < nameB) {\n return -1;\n }\n if (nameA > nameB) {\n return 1;\n }\n\n // names must be equal\n return 0;\n});\n\n// Split the chart data array back into separate arrays for series, data, and labels\nvar sortedSeries = [];\nvar sortedData = [];\nvar sortedLabels = [];\nfor (var j = 0; j < chartData.length; j++) {\n sortedSeries.push(chartData[j].series);\n sortedData.push(chartData[j].data);\n sortedLabels.push(chartData[j].label);\n}\n\n// Create the chart object\nvar chart = [{\n \"series\": sortedSeries,\n \"data\": sortedData,\n \"labels\": sortedLabels\n}];\n\n// Set the chart object as the payload\nmsg.payload = chart;\n\n// Return the modified message\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 2020,
"y": 420,
"wires": [
[
"3491d4db266ca9c8"
]
]
},
{
"id": "3491d4db266ca9c8",
"type": "ui_chart",
"z": "a0328760f2e5cef0",
"name": "Grafiek van Enphase",
"group": "a3a6f615e04fd3c6",
"order": 58,
"width": "22",
"height": "13",
"label": "",
"chartType": "line",
"legend": "true",
"xformat": "dd HH:mm",
"interpolate": "bezier",
"nodata": "Opbrengst op de verschillende tijdstippen, opgehaald vanuit Enphase",
"dot": false,
"ymin": "",
"ymax": "",
"removeOlder": "24",
"removeOlderPoints": "0",
"removeOlderUnit": "3600",
"cutout": 0,
"useOneColor": false,
"useUTC": false,
"colors": [
"#000000",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#ffffff"
],
"outputs": 1,
"useDifferentColor": false,
"className": "",
"x": 2260,
"y": 420,
"wires": [
[]
]
},
{
"id": "c34f2cb3a4e7fb22",
"type": "change",
"z": "a0328760f2e5cef0",
"name": "Add cookie header",
"rules": [
{
"t": "set",
"p": "headers.Cookie",
"pt": "msg",
"to": "form_token=Secret1; _enlighten_4_session=Secret2",
"tot": "str"
},
{
"t": "set",
"p": "url",
"pt": "msg",
"to": "\"https://enlighten.enphaseenergy.com/systems/2139320/inverters/46974736/time_series_x?&date=\" & $replace(msg.payload, \" \", \"%20\") & \"&stat=POWR\"",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 750,
"y": 300,
"wires": [
[
"8c7afe2a524764b3"
]
]
},
{
"id": "2740bd4bfd135ed3",
"type": "change",
"z": "a0328760f2e5cef0",
"name": "Add cookie header",
"rules": [
{
"t": "set",
"p": "headers.Cookie",
"pt": "msg",
"to": "form_token=Secret1; _enlighten_4_session=Secret2",
"tot": "str"
},
{
"t": "set",
"p": "url",
"pt": "msg",
"to": "\"https://enlighten.enphaseenergy.com/systems/2139320/inverters/46974742/time_series_x?&date=\" & $replace(msg.payload, \" \", \"%20\") & \"&stat=POWR\"",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 750,
"y": 340,
"wires": [
[
"8c7afe2a524764b3"
]
]
},
{
"id": "a3a6f615e04fd3c6",
"type": "ui_group",
"name": "Mijn beste tablad.",
"tab": "52f93527d10c3629",
"order": 1,
"disp": true,
"width": "30",
"collapse": false,
"className": ""
},
{
"id": "52f93527d10c3629",
"type": "ui_tab",
"name": "Home Automation",
"icon": "dashboard",
"order": 1,
"disabled": false,
"hidden": false
}
] |