iobroker.amtronwallbox 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/ISSUE_TEMPLATE/bug_report.md +32 -0
- package/.github/workflows/npmpublish.yml +30 -0
- package/.github/workflows/test-and-release.yml +120 -0
- package/LICENSE +21 -0
- package/README.md +60 -0
- package/admin/amtronwallbox.png +0 -0
- package/admin/index_m.html +147 -0
- package/admin/words.js +13 -0
- package/amtronwallbox.njsproj +115 -0
- package/amtronwallbox.njsproj.user +6 -0
- package/io-package.json +89 -0
- package/lib/tools.js +99 -0
- package/main.js +918 -0
- package/package.json +61 -0
- package/readme.txt +20 -0
package/main.js
ADDED
|
@@ -0,0 +1,918 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* pvoutputorg adapter für iobroker
|
|
3
|
+
*
|
|
4
|
+
* Created: 15.05.2022 18:39:28
|
|
5
|
+
* Author: Rene
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
"use strict";
|
|
9
|
+
|
|
10
|
+
const utils = require("@iobroker/adapter-core");
|
|
11
|
+
const axios = require('axios');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* docu see
|
|
16
|
+
https://github.com/orlopau/amtron
|
|
17
|
+
https://forum.iobroker.net/topic/32179/wallbox-mennekes-amtron-auslesen-adapter-aus-skript
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
für ChargeControl mit Rest Api
|
|
21
|
+
https://office.elinc.de/rest_api
|
|
22
|
+
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
let adapter;
|
|
28
|
+
function startAdapter(options) {
|
|
29
|
+
options = options || {};
|
|
30
|
+
Object.assign(options, {
|
|
31
|
+
name: "amtronwallbox",
|
|
32
|
+
//#######################################
|
|
33
|
+
//
|
|
34
|
+
ready: function () {
|
|
35
|
+
try {
|
|
36
|
+
//adapter.log.debug('start');
|
|
37
|
+
main();
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
adapter.log.error("exception catch after ready [" + e + "]");
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
//#######################################
|
|
44
|
+
// is called when adapter shuts down
|
|
45
|
+
unload: function (callback) {
|
|
46
|
+
try {
|
|
47
|
+
adapter && adapter.log && adapter.log.info && adapter.log.info("cleaned everything up...");
|
|
48
|
+
//to do stop intervall
|
|
49
|
+
callback();
|
|
50
|
+
} catch (e) {
|
|
51
|
+
callback();
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
//#######################################
|
|
55
|
+
//
|
|
56
|
+
SIGINT: function () {
|
|
57
|
+
clearInterval(intervalID);
|
|
58
|
+
intervalID = null;
|
|
59
|
+
adapter && adapter.log && adapter.log.info && adapter.log.info("cleaned everything up...");
|
|
60
|
+
CronStop();
|
|
61
|
+
},
|
|
62
|
+
//#######################################
|
|
63
|
+
// is called if a subscribed object changes
|
|
64
|
+
//objectChange: function (id, obj) {
|
|
65
|
+
// adapter.log.debug("[OBJECT CHANGE] ==== " + id + " === " + JSON.stringify(obj));
|
|
66
|
+
//},
|
|
67
|
+
//#######################################
|
|
68
|
+
// is called if a subscribed state changes
|
|
69
|
+
//stateChange: function (id, state) {
|
|
70
|
+
//HandleStateChange(id, state);
|
|
71
|
+
//},
|
|
72
|
+
stateChange: async (id, state) => {
|
|
73
|
+
await HandleStateChange(id, state);
|
|
74
|
+
},
|
|
75
|
+
//#######################################
|
|
76
|
+
//
|
|
77
|
+
});
|
|
78
|
+
adapter = new utils.Adapter(options);
|
|
79
|
+
|
|
80
|
+
return adapter;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
let intervalID;
|
|
86
|
+
async function main() {
|
|
87
|
+
|
|
88
|
+
adapter.log.debug("start ");
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
await checkVariables();
|
|
92
|
+
|
|
93
|
+
subscribeVars();
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
let readInterval = 15;
|
|
97
|
+
if (parseInt(adapter.config.readInterval) > 0) {
|
|
98
|
+
readInterval = adapter.config.readInterval;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
adapter.log.warn("read interval not defined");
|
|
102
|
+
}
|
|
103
|
+
adapter.log.debug("read every " + readInterval + " minutes");
|
|
104
|
+
intervalID = setInterval(Do, readInterval * 60 * 1000);
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async function Do() {
|
|
109
|
+
|
|
110
|
+
adapter.log.debug("starting ... " );
|
|
111
|
+
|
|
112
|
+
await ReadData();
|
|
113
|
+
|
|
114
|
+
//to do
|
|
115
|
+
//await WriteData();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
async function ReadData(){
|
|
120
|
+
|
|
121
|
+
for (const system of adapter.config.WallboxSystems) {
|
|
122
|
+
|
|
123
|
+
if (system.Type === "ChargeControl") {
|
|
124
|
+
await read_rest(system);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
//system type ChargeControl string not yet implemented
|
|
128
|
+
adapter.log.warn("system type " + system.Type + " " + typeof system.Type + " not yet implemented");
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async function read_MHCP() {
|
|
136
|
+
|
|
137
|
+
try {
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
/*
|
|
141
|
+
var abfrage_DevInfo = "curl -H 'Accept: application/json' http://10.0.1.28:25000/MHCP/1.0/DevInfo?DevKey=999999";
|
|
142
|
+
var abfrage_ChargeData = "curl -H 'Accept: application/json' http://10.0.1.28:25000/MHCP/1.0/ChargeData?DevKey=999999";
|
|
143
|
+
var abfrage_Statistics_Day = "curl -H 'Accept: application/json' http://10.0.1.28:25000/MHCP/1.0/Statistics/Day?DevKey=999999";
|
|
144
|
+
var abfrage_Statistics_Week = "curl -H 'Accept: application/json' http://10.0.1.28:25000/MHCP/1.0/Statistics/Week?DevKey=999999";
|
|
145
|
+
var abfrage_Statistics_Month = "curl -H 'Accept: application/json' http://10.0.1.28:25000/MHCP/1.0/Statistics/Month?DevKey=999999";
|
|
146
|
+
var abfrage_Statistics_Year = "curl -H 'Accept: application/json' http://10.0.1.28:25000/MHCP/1.0/Statistics/Year?DevKey=999999";
|
|
147
|
+
var abfrage_Statistics_Annual = "curl -H 'Accept: application/json' http://10.0.1.28:25000/MHCP/1.0/Statistics/Annual?DevKey=999999";
|
|
148
|
+
*/
|
|
149
|
+
}
|
|
150
|
+
catch (e) {
|
|
151
|
+
adapter.log.error("exception in read_MHCP [" + e + "]");
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
async function read_rest(system) {
|
|
156
|
+
|
|
157
|
+
try {
|
|
158
|
+
|
|
159
|
+
/*
|
|
160
|
+
http://192.168.3.18/rest/full_state
|
|
161
|
+
|
|
162
|
+
conn_state: no_vehicle_connected
|
|
163
|
+
auth_state: not_authorized_for_charging
|
|
164
|
+
auth_uid:
|
|
165
|
+
time_since_charging_start: 0
|
|
166
|
+
meter_wh: 16701
|
|
167
|
+
power_w: 0
|
|
168
|
+
transaction_wh: 0
|
|
169
|
+
cp_id: +49 * 839 * 00000000001
|
|
170
|
+
ocpp_state: available
|
|
171
|
+
type2_state: a
|
|
172
|
+
type2_proximity: cable_attached
|
|
173
|
+
sig_current: 0
|
|
174
|
+
schuko_state: idle
|
|
175
|
+
backend_conn_state: pending
|
|
176
|
+
free_charging: off
|
|
177
|
+
slave_state:
|
|
178
|
+
ocpp_meter_cfg: modbus_meter_nzr
|
|
179
|
+
ocpp_meter_serial: 00202035
|
|
180
|
+
current_a: 0.00, 0.00, 0.00
|
|
181
|
+
energy_man_current: 0
|
|
182
|
+
ambient_temp: +15.00
|
|
183
|
+
firmware_ver: 5.22.1 - 13295
|
|
184
|
+
cc_serial_n: 2202532503 / b94060010me2
|
|
185
|
+
con_cycles_schuko: 0
|
|
186
|
+
con_cycles_type2: 5
|
|
187
|
+
max_current: 16
|
|
188
|
+
rcmb_state: okay
|
|
189
|
+
rcmb_max_values: 0.0, 0.0
|
|
190
|
+
rcmb_current_values: 0.0, 0.0
|
|
191
|
+
cable_attached: on
|
|
192
|
+
schuko_cfg: disable
|
|
193
|
+
rcd_state: disable
|
|
194
|
+
mcb_type2_state: disable
|
|
195
|
+
mcb_schuko_state: disable
|
|
196
|
+
cp_vendor: MENNEKES
|
|
197
|
+
errors: no_errors
|
|
198
|
+
cp_model: CC612_2S0R_CC
|
|
199
|
+
display_text:
|
|
200
|
+
|
|
201
|
+
*/
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
let sURL = "http://" + system.URL + "/rest/full_state";
|
|
210
|
+
let header = {
|
|
211
|
+
headers: {
|
|
212
|
+
Accept: 'application/json '
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
adapter.log.debug("URL " + sURL);
|
|
216
|
+
|
|
217
|
+
let buffer = await axios.get(sURL, header);
|
|
218
|
+
|
|
219
|
+
adapter.log.debug("got data status " + typeof buffer.data + " " + JSON.stringify(buffer.data));
|
|
220
|
+
/*
|
|
221
|
+
got data status string "conn_state:no_vehicle_connected\nauth_state:not_authorized_for_charging\nauth_uid:\ntime_since_charging_start:0\nmeter_wh:16701\npower_w:0\ntransaction_wh:0\ncp_id:+49*839*00000000001\nocpp_state:available\ntype2_state:a\ntype2_proximity:cable_attached\nsig_current:0\nschuko_state:idle\nbackend_conn_state:pending\nfree_charging:off\nslave_state:\nocpp_meter_cfg:modbus_meter_nzr\nocpp_meter_serial:00202035\ncurrent_a:0.00,0.00,0.00\nenergy_man_current:0\nambient_temp:+15.00\nfirmware_ver:5.22.1-13295\ncc_serial_n:2202532503/b94060010me2\ncon_cycles_schuko:0\ncon_cycles_type2:5\nmax_current:16\nrcmb_state:okay\nrcmb_max_values: 0.0, 0.0\nrcmb_current_values: 0.0, 0.0\ncable_attached:on\nschuko_cfg:disable\nrcd_state:disable\nmcb_type2_state:disable\nmcb_schuko_state:disable\ncp_vendor:MENNEKES\nerrors:no_errors\ncp_model:CC612_2S0R_CC\ndisplay_text:"
|
|
222
|
+
*/
|
|
223
|
+
|
|
224
|
+
if (buffer != null && buffer.status == 200 && buffer.data != null && typeof buffer.data === "string") {
|
|
225
|
+
|
|
226
|
+
let data = buffer.data.split(/\r?\n/);
|
|
227
|
+
|
|
228
|
+
adapter.log.debug("data " + JSON.stringify(data));
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
await adapter.setStateAsync(system.Name + ".Connection.State", { ack: true, val: data[0].split(":")[1] });
|
|
232
|
+
await adapter.setStateAsync(system.Name + ".Authorisation.State", { ack: true, val: data[1].split(":")[1] });
|
|
233
|
+
await adapter.setStateAsync(system.Name + ".Authorisation.UID", { ack: true, val: data[2].split(":")[1] });
|
|
234
|
+
await adapter.setStateAsync(system.Name + ".TimeSinceChargingStart", { ack: true, val: data[3].split(":")[1] });
|
|
235
|
+
await adapter.setStateAsync(system.Name + ".Meter", { ack: true, val: data[4].split(":")[1] });
|
|
236
|
+
await adapter.setStateAsync(system.Name + ".Power", { ack: true, val: data[5].split(":")[1] });
|
|
237
|
+
await adapter.setStateAsync(system.Name + ".Transaction", { ack: true, val: data[6].split(":")[1] });
|
|
238
|
+
await adapter.setStateAsync(system.Name + ".CP_ID", { ack: true, val: data[7].split(":")[1] });
|
|
239
|
+
await adapter.setStateAsync(system.Name + ".OCPP.State", { ack: true, val: data[8].split(":")[1] });
|
|
240
|
+
await adapter.setStateAsync(system.Name + ".Type2.State", { ack: true, val: data[9].split(":")[1] });
|
|
241
|
+
await adapter.setStateAsync(system.Name + ".Type2.Proximity", { ack: true, val: data[10].split(":")[1] });
|
|
242
|
+
await adapter.setStateAsync(system.Name + ".SigCurrent", { ack: true, val: data[11].split(":")[1] });
|
|
243
|
+
await adapter.setStateAsync(system.Name + ".Schuko.State", { ack: true, val: data[12].split(":")[1] });
|
|
244
|
+
await adapter.setStateAsync(system.Name + ".Backend.ConnectionState", { ack: true, val: data[13].split(":")[1] });
|
|
245
|
+
await adapter.setStateAsync(system.Name + ".FreeCharging", { ack: true, val: data[14].split(":")[1] });
|
|
246
|
+
await adapter.setStateAsync(system.Name + ".SlaveState", { ack: true, val: data[15].split(":")[1] });
|
|
247
|
+
await adapter.setStateAsync(system.Name + ".OCPP.MeterConfig", { ack: true, val: data[16].split(":")[1] });
|
|
248
|
+
await adapter.setStateAsync(system.Name + ".OCPP.MeterSerial", { ack: true, val: data[17].split(":")[1] });
|
|
249
|
+
await adapter.setStateAsync(system.Name + ".Current", { ack: true, val: data[18].split(":")[1] });
|
|
250
|
+
await adapter.setStateAsync(system.Name + ".EnergyManagerCurrent", { ack: true, val: data[19].split(":")[1] });
|
|
251
|
+
await adapter.setStateAsync(system.Name + ".AmbientTemperature", { ack: true, val: data[20].split(":")[1] });
|
|
252
|
+
await adapter.setStateAsync(system.Name + ".FirmwareVersion", { ack: true, val: data[21].split(":")[1] });
|
|
253
|
+
await adapter.setStateAsync(system.Name + ".SerialNumber", { ack: true, val: data[22].split(":")[1] });
|
|
254
|
+
await adapter.setStateAsync(system.Name + ".ContactCyclesSchuko", { ack: true, val: data[23].split(":")[1] });
|
|
255
|
+
await adapter.setStateAsync(system.Name + ".ContactcyclesType2", { ack: true, val: data[24].split(":")[1] });
|
|
256
|
+
await adapter.setStateAsync(system.Name + ".MaxCurrent", { ack: true, val: data[25].split(":")[1] });
|
|
257
|
+
await adapter.setStateAsync(system.Name + ".RCMB.State", { ack: true, val: data[26].split(":")[1] });
|
|
258
|
+
await adapter.setStateAsync(system.Name + ".RCMB.MaxValues", { ack: true, val: data[27].split(":")[1] });
|
|
259
|
+
await adapter.setStateAsync(system.Name + ".RCMB.CurrentValues", { ack: true, val: data[28].split(":")[1] });
|
|
260
|
+
await adapter.setStateAsync(system.Name + ".CableAttached", { ack: true, val: data[29].split(":")[1] });
|
|
261
|
+
await adapter.setStateAsync(system.Name + ".Schuko.Config", { ack: true, val: data[30].split(":")[1] });
|
|
262
|
+
await adapter.setStateAsync(system.Name + ".RCD.State", { ack: true, val: data[31].split(":")[1] });
|
|
263
|
+
await adapter.setStateAsync(system.Name + ".MCB.Type2State", { ack: true, val: data[32].split(":")[1] });
|
|
264
|
+
await adapter.setStateAsync(system.Name + ".MCB.SchukoState", { ack: true, val: data[33].split(":")[1] });
|
|
265
|
+
await adapter.setStateAsync(system.Name + ".CP_Vendor", { ack: true, val: data[34].split(":")[1] });
|
|
266
|
+
await adapter.setStateAsync(system.Name + ".Errors", { ack: true, val: data[35].split(":")[1] });
|
|
267
|
+
await adapter.setStateAsync(system.Name + ".CP_Model", { ack: true, val: data[36].split(":")[1] });
|
|
268
|
+
await adapter.setStateAsync(system.Name + ".DisplayText", { ack: true, val: data[37].split(":")[1] });
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
adapter.log.error("error status: " + JSON.stringify(buffer));
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
}
|
|
279
|
+
catch (e) {
|
|
280
|
+
adapter.log.error("exception in read_rest [" + e + "]");
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
function toDate(sDate) {
|
|
286
|
+
|
|
287
|
+
//yyyymmdd
|
|
288
|
+
const year = sDate.slice(0, 4);
|
|
289
|
+
const month = sDate.slice(4, 6);
|
|
290
|
+
const day = sDate.slice(6, 9);
|
|
291
|
+
|
|
292
|
+
let oDate = new Date(year, month - 1, day);
|
|
293
|
+
|
|
294
|
+
return oDate.toLocaleDateString();
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
async function HandleStateChange(id, state) {
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
if (state.ack !== true) {
|
|
301
|
+
|
|
302
|
+
adapter.log.debug("handle state change " + id);
|
|
303
|
+
const ids = id.split(".");
|
|
304
|
+
|
|
305
|
+
//just dummy
|
|
306
|
+
//if (ids[2] === "cmd") {
|
|
307
|
+
// await do_Command();
|
|
308
|
+
//}
|
|
309
|
+
//else {
|
|
310
|
+
adapter.log.warn("unhandled state change " + id);
|
|
311
|
+
//}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function subscribeVars() {
|
|
317
|
+
//adapter.subscribeStates("cmd");
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
async function checkVariables() {
|
|
322
|
+
adapter.log.debug("init variables ");
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
for (const system of adapter.config.WallboxSystems) {
|
|
327
|
+
|
|
328
|
+
let key;
|
|
329
|
+
let obj;
|
|
330
|
+
|
|
331
|
+
key = system.Name + ".Connection.State";
|
|
332
|
+
obj = {
|
|
333
|
+
type: "state",
|
|
334
|
+
common: {
|
|
335
|
+
name: "Connection State",
|
|
336
|
+
type: "string",
|
|
337
|
+
role: "value",
|
|
338
|
+
read: true,
|
|
339
|
+
write: false
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
await CreateObject(key, obj);
|
|
343
|
+
|
|
344
|
+
key = system.Name + ".Authorisation.State";
|
|
345
|
+
obj = {
|
|
346
|
+
type: "state",
|
|
347
|
+
common: {
|
|
348
|
+
name: "Authorisation State",
|
|
349
|
+
type: "string",
|
|
350
|
+
role: "value",
|
|
351
|
+
unit: "",
|
|
352
|
+
read: true,
|
|
353
|
+
write: false
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
await CreateObject(key, obj);
|
|
357
|
+
|
|
358
|
+
key = system.Name + ".Authorisation.UID";
|
|
359
|
+
obj = {
|
|
360
|
+
type: "state",
|
|
361
|
+
common: {
|
|
362
|
+
name: "Authorisation UID",
|
|
363
|
+
type: "string",
|
|
364
|
+
role: "value",
|
|
365
|
+
unit: "",
|
|
366
|
+
read: true,
|
|
367
|
+
write: false
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
await CreateObject(key, obj);
|
|
371
|
+
|
|
372
|
+
key = system.Name + ".TimeSinceChargingStart";
|
|
373
|
+
obj = {
|
|
374
|
+
type: "state",
|
|
375
|
+
common: {
|
|
376
|
+
name: "Time Since Charging Start",
|
|
377
|
+
type: "number",
|
|
378
|
+
role: "value",
|
|
379
|
+
unit: "s",
|
|
380
|
+
read: true,
|
|
381
|
+
write: false
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
await CreateObject(key, obj);
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
key = system.Name + ".Meter";
|
|
388
|
+
obj = {
|
|
389
|
+
type: "state",
|
|
390
|
+
common: {
|
|
391
|
+
name: "Meter",
|
|
392
|
+
type: "number",
|
|
393
|
+
role: "value",
|
|
394
|
+
unit: "Wh",
|
|
395
|
+
read: true,
|
|
396
|
+
write: false
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
await CreateObject(key, obj);
|
|
400
|
+
|
|
401
|
+
key = system.Name + ".Power";
|
|
402
|
+
obj = {
|
|
403
|
+
type: "state",
|
|
404
|
+
common: {
|
|
405
|
+
name: "Power",
|
|
406
|
+
type: "number",
|
|
407
|
+
role: "value",
|
|
408
|
+
unit: "W",
|
|
409
|
+
read: true,
|
|
410
|
+
write: false
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
await CreateObject(key, obj);
|
|
414
|
+
|
|
415
|
+
key = system.Name + ".Transaction";
|
|
416
|
+
obj = {
|
|
417
|
+
type: "state",
|
|
418
|
+
common: {
|
|
419
|
+
name: "Transaction",
|
|
420
|
+
type: "number",
|
|
421
|
+
role: "value",
|
|
422
|
+
unit: "Wh",
|
|
423
|
+
read: true,
|
|
424
|
+
write: false
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
await CreateObject(key, obj);
|
|
428
|
+
|
|
429
|
+
key = system.Name + ".CP_ID";
|
|
430
|
+
obj = {
|
|
431
|
+
type: "state",
|
|
432
|
+
common: {
|
|
433
|
+
name: "System ID",
|
|
434
|
+
type: "string",
|
|
435
|
+
role: "value",
|
|
436
|
+
unit: "",
|
|
437
|
+
read: true,
|
|
438
|
+
write: false
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
await CreateObject(key, obj);
|
|
442
|
+
|
|
443
|
+
key = system.Name + ".OCPP.State";
|
|
444
|
+
obj = {
|
|
445
|
+
type: "state",
|
|
446
|
+
common: {
|
|
447
|
+
name: "OCPP State",
|
|
448
|
+
type: "string",
|
|
449
|
+
role: "value",
|
|
450
|
+
unit: "",
|
|
451
|
+
read: true,
|
|
452
|
+
write: false
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
await CreateObject(key, obj);
|
|
456
|
+
|
|
457
|
+
key = system.Name + ".Type2.State";
|
|
458
|
+
obj = {
|
|
459
|
+
type: "state",
|
|
460
|
+
common: {
|
|
461
|
+
name: "Type2 State",
|
|
462
|
+
type: "string",
|
|
463
|
+
role: "value",
|
|
464
|
+
unit: "",
|
|
465
|
+
read: true,
|
|
466
|
+
write: false
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
await CreateObject(key, obj);
|
|
470
|
+
|
|
471
|
+
key = system.Name + ".Type2.Proximity";
|
|
472
|
+
obj = {
|
|
473
|
+
type: "state",
|
|
474
|
+
common: {
|
|
475
|
+
name: "Type2 Proximity",
|
|
476
|
+
type: "string",
|
|
477
|
+
role: "value",
|
|
478
|
+
unit: "",
|
|
479
|
+
read: true,
|
|
480
|
+
write: false
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
await CreateObject(key, obj);
|
|
484
|
+
|
|
485
|
+
key = system.Name + ".SigCurrent";
|
|
486
|
+
obj = {
|
|
487
|
+
type: "state",
|
|
488
|
+
common: {
|
|
489
|
+
name: "SIG Current",
|
|
490
|
+
type: "number",
|
|
491
|
+
role: "value",
|
|
492
|
+
unit: "",
|
|
493
|
+
read: true,
|
|
494
|
+
write: false
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
await CreateObject(key, obj);
|
|
498
|
+
|
|
499
|
+
key = system.Name + ".Schuko.State";
|
|
500
|
+
obj = {
|
|
501
|
+
type: "state",
|
|
502
|
+
common: {
|
|
503
|
+
name: "Schuko State",
|
|
504
|
+
type: "string",
|
|
505
|
+
role: "value",
|
|
506
|
+
unit: "",
|
|
507
|
+
read: true,
|
|
508
|
+
write: false
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
await CreateObject(key, obj);
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
key = system.Name + ".Backend.ConnectionState";
|
|
515
|
+
obj = {
|
|
516
|
+
type: "state",
|
|
517
|
+
common: {
|
|
518
|
+
name: "Backend Connection State",
|
|
519
|
+
type: "string",
|
|
520
|
+
role: "value",
|
|
521
|
+
unit: "",
|
|
522
|
+
read: true,
|
|
523
|
+
write: false
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
await CreateObject(key, obj);
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
key = system.Name + ".FreeCharging";
|
|
530
|
+
obj = {
|
|
531
|
+
type: "state",
|
|
532
|
+
common: {
|
|
533
|
+
name: "FreeCharging",
|
|
534
|
+
type: "boolean",
|
|
535
|
+
role: "value",
|
|
536
|
+
unit: "",
|
|
537
|
+
read: true,
|
|
538
|
+
write: false
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
await CreateObject(key, obj);
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
key = system.Name + ".SlaveState";
|
|
545
|
+
obj = {
|
|
546
|
+
type: "state",
|
|
547
|
+
common: {
|
|
548
|
+
name: "SlaveState",
|
|
549
|
+
type: "string",
|
|
550
|
+
role: "value",
|
|
551
|
+
unit: "",
|
|
552
|
+
read: true,
|
|
553
|
+
write: false
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
await CreateObject(key, obj);
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
key = system.Name + ".OCPP.MeterConfig";
|
|
560
|
+
obj = {
|
|
561
|
+
type: "state",
|
|
562
|
+
common: {
|
|
563
|
+
name: "OCPP Meter Config",
|
|
564
|
+
type: "string",
|
|
565
|
+
role: "value",
|
|
566
|
+
unit: "",
|
|
567
|
+
read: true,
|
|
568
|
+
write: false
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
await CreateObject(key, obj);
|
|
572
|
+
|
|
573
|
+
key = system.Name + ".OCPP.MeterSerial";
|
|
574
|
+
obj = {
|
|
575
|
+
type: "state",
|
|
576
|
+
common: {
|
|
577
|
+
name: "OCPP Meter Serial",
|
|
578
|
+
type: "string",
|
|
579
|
+
role: "value",
|
|
580
|
+
unit: "",
|
|
581
|
+
read: true,
|
|
582
|
+
write: false
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
await CreateObject(key, obj);
|
|
586
|
+
|
|
587
|
+
key = system.Name + ".Current";
|
|
588
|
+
obj = {
|
|
589
|
+
type: "state",
|
|
590
|
+
common: {
|
|
591
|
+
name: "Current",
|
|
592
|
+
type: "number",
|
|
593
|
+
role: "value",
|
|
594
|
+
unit: "A",
|
|
595
|
+
read: true,
|
|
596
|
+
write: false
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
await CreateObject(key, obj);
|
|
600
|
+
|
|
601
|
+
key = system.Name + ".EnergyManagerCurrent";
|
|
602
|
+
obj = {
|
|
603
|
+
type: "state",
|
|
604
|
+
common: {
|
|
605
|
+
name: "Energy Manager Current",
|
|
606
|
+
type: "number",
|
|
607
|
+
role: "value",
|
|
608
|
+
unit: "A",
|
|
609
|
+
read: true,
|
|
610
|
+
write: false
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
await CreateObject(key, obj);
|
|
614
|
+
|
|
615
|
+
key = system.Name + ".AmbientTemperature";
|
|
616
|
+
obj = {
|
|
617
|
+
type: "state",
|
|
618
|
+
common: {
|
|
619
|
+
name: "AmbientTemperature",
|
|
620
|
+
type: "string",
|
|
621
|
+
role: "value",
|
|
622
|
+
unit: "°C",
|
|
623
|
+
read: true,
|
|
624
|
+
write: false
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
await CreateObject(key, obj);
|
|
628
|
+
|
|
629
|
+
key = system.Name + ".FirmwareVersion";
|
|
630
|
+
obj = {
|
|
631
|
+
type: "state",
|
|
632
|
+
common: {
|
|
633
|
+
name: "FirmwareVersion",
|
|
634
|
+
type: "string",
|
|
635
|
+
role: "value",
|
|
636
|
+
unit: "",
|
|
637
|
+
read: true,
|
|
638
|
+
write: false
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
await CreateObject(key, obj);
|
|
642
|
+
|
|
643
|
+
key = system.Name + ".SerialNumber";
|
|
644
|
+
obj = {
|
|
645
|
+
type: "state",
|
|
646
|
+
common: {
|
|
647
|
+
name: "SerialNumber",
|
|
648
|
+
type: "string",
|
|
649
|
+
role: "value",
|
|
650
|
+
unit: "",
|
|
651
|
+
read: true,
|
|
652
|
+
write: false
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
await CreateObject(key, obj);
|
|
656
|
+
|
|
657
|
+
key = system.Name + ".ContactCyclesSchuko";
|
|
658
|
+
obj = {
|
|
659
|
+
type: "state",
|
|
660
|
+
common: {
|
|
661
|
+
name: "Contact´Cycles Schuko",
|
|
662
|
+
type: "number",
|
|
663
|
+
role: "value",
|
|
664
|
+
unit: "",
|
|
665
|
+
read: true,
|
|
666
|
+
write: false
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
await CreateObject(key, obj);
|
|
670
|
+
|
|
671
|
+
key = system.Name + ".ContactcyclesType2";
|
|
672
|
+
obj = {
|
|
673
|
+
type: "state",
|
|
674
|
+
common: {
|
|
675
|
+
name: "Contact´Cycles Type2",
|
|
676
|
+
type: "number",
|
|
677
|
+
role: "value",
|
|
678
|
+
unit: "",
|
|
679
|
+
read: true,
|
|
680
|
+
write: false
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
await CreateObject(key, obj);
|
|
684
|
+
|
|
685
|
+
key = system.Name + ".MaxCurrent";
|
|
686
|
+
obj = {
|
|
687
|
+
type: "state",
|
|
688
|
+
common: {
|
|
689
|
+
name: "Maximun Current",
|
|
690
|
+
type: "number",
|
|
691
|
+
role: "value",
|
|
692
|
+
unit: "A",
|
|
693
|
+
read: true,
|
|
694
|
+
write: false
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
await CreateObject(key, obj);
|
|
698
|
+
|
|
699
|
+
key = system.Name + ".RCMB.State";
|
|
700
|
+
obj = {
|
|
701
|
+
type: "state",
|
|
702
|
+
common: {
|
|
703
|
+
name: "RCMB State",
|
|
704
|
+
type: "string",
|
|
705
|
+
role: "value",
|
|
706
|
+
unit: "",
|
|
707
|
+
read: true,
|
|
708
|
+
write: false
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
await CreateObject(key, obj);
|
|
712
|
+
|
|
713
|
+
key = system.Name + ".RCMB.MaxValues";
|
|
714
|
+
obj = {
|
|
715
|
+
type: "state",
|
|
716
|
+
common: {
|
|
717
|
+
name: "RCMB Maximum Values",
|
|
718
|
+
type: "string",
|
|
719
|
+
role: "value",
|
|
720
|
+
unit: "",
|
|
721
|
+
read: true,
|
|
722
|
+
write: false
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
await CreateObject(key, obj);
|
|
726
|
+
|
|
727
|
+
key = system.Name + ".RCMB.CurrentValues";
|
|
728
|
+
obj = {
|
|
729
|
+
type: "state",
|
|
730
|
+
common: {
|
|
731
|
+
name: "RCMB Current Values",
|
|
732
|
+
type: "string",
|
|
733
|
+
role: "value",
|
|
734
|
+
unit: "",
|
|
735
|
+
read: true,
|
|
736
|
+
write: false
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
await CreateObject(key, obj);
|
|
740
|
+
|
|
741
|
+
key = system.Name + ".CableAttached";
|
|
742
|
+
obj = {
|
|
743
|
+
type: "state",
|
|
744
|
+
common: {
|
|
745
|
+
name: "CableAttached",
|
|
746
|
+
type: "boolean",
|
|
747
|
+
role: "value",
|
|
748
|
+
unit: "",
|
|
749
|
+
read: true,
|
|
750
|
+
write: false
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
await CreateObject(key, obj);
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
key = system.Name + ".Schuko.Config";
|
|
757
|
+
obj = {
|
|
758
|
+
type: "state",
|
|
759
|
+
common: {
|
|
760
|
+
name: "Schuko Config",
|
|
761
|
+
type: "string",
|
|
762
|
+
role: "value",
|
|
763
|
+
unit: "",
|
|
764
|
+
read: true,
|
|
765
|
+
write: false
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
await CreateObject(key, obj);
|
|
769
|
+
|
|
770
|
+
key = system.Name + ".RCD.State";
|
|
771
|
+
obj = {
|
|
772
|
+
type: "state",
|
|
773
|
+
common: {
|
|
774
|
+
name: "RCD State",
|
|
775
|
+
type: "string",
|
|
776
|
+
role: "value",
|
|
777
|
+
unit: "",
|
|
778
|
+
read: true,
|
|
779
|
+
write: false
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
await CreateObject(key, obj);
|
|
783
|
+
|
|
784
|
+
key = system.Name + ".MCB.Type2State";
|
|
785
|
+
obj = {
|
|
786
|
+
type: "state",
|
|
787
|
+
common: {
|
|
788
|
+
name: "MCB Type2 State",
|
|
789
|
+
type: "string",
|
|
790
|
+
role: "value",
|
|
791
|
+
unit: "",
|
|
792
|
+
read: true,
|
|
793
|
+
write: false
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
await CreateObject(key, obj);
|
|
797
|
+
|
|
798
|
+
key = system.Name + ".MCB.SchukoState";
|
|
799
|
+
obj = {
|
|
800
|
+
type: "state",
|
|
801
|
+
common: {
|
|
802
|
+
name: "MCB Schuko State",
|
|
803
|
+
type: "string",
|
|
804
|
+
role: "value",
|
|
805
|
+
unit: "",
|
|
806
|
+
read: true,
|
|
807
|
+
write: false
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
await CreateObject(key, obj);
|
|
811
|
+
|
|
812
|
+
key = system.Name + ".CP_Vendor";
|
|
813
|
+
obj = {
|
|
814
|
+
type: "state",
|
|
815
|
+
common: {
|
|
816
|
+
name: "System Vendor",
|
|
817
|
+
type: "string",
|
|
818
|
+
role: "value",
|
|
819
|
+
unit: "",
|
|
820
|
+
read: true,
|
|
821
|
+
write: false
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
await CreateObject(key, obj);
|
|
825
|
+
|
|
826
|
+
key = system.Name + ".Errors";
|
|
827
|
+
obj = {
|
|
828
|
+
type: "state",
|
|
829
|
+
common: {
|
|
830
|
+
name: "Errors",
|
|
831
|
+
type: "string",
|
|
832
|
+
role: "value",
|
|
833
|
+
unit: "",
|
|
834
|
+
read: true,
|
|
835
|
+
write: false
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
await CreateObject(key, obj);
|
|
839
|
+
|
|
840
|
+
key = system.Name + ".CP_Model";
|
|
841
|
+
obj = {
|
|
842
|
+
type: "state",
|
|
843
|
+
common: {
|
|
844
|
+
name: "System Model",
|
|
845
|
+
type: "string",
|
|
846
|
+
role: "value",
|
|
847
|
+
unit: "",
|
|
848
|
+
read: true,
|
|
849
|
+
write: false
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
await CreateObject(key, obj);
|
|
853
|
+
|
|
854
|
+
|
|
855
|
+
key = system.Name + ".DisplayText";
|
|
856
|
+
obj = {
|
|
857
|
+
type: "state",
|
|
858
|
+
common: {
|
|
859
|
+
name: "Display Text",
|
|
860
|
+
type: "string",
|
|
861
|
+
role: "value",
|
|
862
|
+
unit: "",
|
|
863
|
+
read: true,
|
|
864
|
+
write: false
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
await CreateObject(key, obj);
|
|
868
|
+
|
|
869
|
+
|
|
870
|
+
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
|
|
874
|
+
|
|
875
|
+
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
|
|
879
|
+
async function CreateObject(key, obj) {
|
|
880
|
+
|
|
881
|
+
const obj_new = await adapter.getObjectAsync(key);
|
|
882
|
+
//adapter.log.warn("got object " + JSON.stringify(obj_new));
|
|
883
|
+
|
|
884
|
+
if (obj_new != null) {
|
|
885
|
+
|
|
886
|
+
if ((obj_new.common.role != obj.common.role
|
|
887
|
+
|| obj_new.common.type != obj.common.type
|
|
888
|
+
|| (obj_new.common.unit != obj.common.unit && obj.common.unit != null)
|
|
889
|
+
|| obj_new.common.read != obj.common.read
|
|
890
|
+
|| obj_new.common.write != obj.common.write
|
|
891
|
+
|| obj_new.common.name != obj.common.name)
|
|
892
|
+
&& obj.type === "state"
|
|
893
|
+
) {
|
|
894
|
+
adapter.log.warn("change object " + JSON.stringify(obj) + " " + JSON.stringify(obj_new));
|
|
895
|
+
await adapter.extendObject(key, {
|
|
896
|
+
common: {
|
|
897
|
+
name: obj.common.name,
|
|
898
|
+
role: obj.common.role,
|
|
899
|
+
type: obj.common.type,
|
|
900
|
+
unit: obj.common.unit,
|
|
901
|
+
read: obj.common.read,
|
|
902
|
+
write: obj.common.write
|
|
903
|
+
}
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
else {
|
|
908
|
+
await adapter.setObjectNotExistsAsync(key, obj);
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
// If started as allInOne/compact mode => return function to create instance
|
|
913
|
+
if (module && module.parent) {
|
|
914
|
+
module.exports = startAdapter;
|
|
915
|
+
} else {
|
|
916
|
+
// or start the instance directly
|
|
917
|
+
startAdapter();
|
|
918
|
+
}
|