-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js
617 lines (542 loc) · 28.7 KB
/
app.js
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
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
'use strict';
const { App } = require('homey');
const { Log } = require('homey-log');
const enums = require('./lib/enums.js');
const conditionHandler = require('./lib/conditionHandler.js');
class VictronEnergyApp extends App {
async onInit() {
this.homeyLog = new Log({ homey: this.homey });
await this.loadConditions();
await this.loadActions();
this.log(`Victron Energy v${this.getAppVersion()} has been initialized`);
}
getAppVersion() {
return this.homey.manifest.version;
}
async loadConditions() {
this.log('Loading conditions...');
const input_source_condition = this.homey.flow.getConditionCard('input_source_condition');
input_source_condition.registerRunListener(async (args, state) => {
//this.log(`[${args.device.getName()}] Condition 'input_source_condition' triggered`);
const source = args.device.getCapabilityValue('input_source');
//this.log(`[${args.device.getName()}] - input source: ${source}, condition status: ${args.source.name}`);
if (source == args.source.name) {
return true;
} else {
return false;
}
});
input_source_condition.registerArgumentAutocompleteListener('source',
async (query, args) => {
return enums.getInputPowerSource();
}
);
const switch_position_condition = this.homey.flow.getConditionCard('switch_position_condition');
switch_position_condition.registerRunListener(async (args, state) => {
//this.log(`[${args.device.getName()}] Condition 'switch_position_condition' triggered`);
const mode = args.device.getCapabilityValue('switch_position');
//this.log(`[${args.device.getName()}] - switch position: ${mode}, condition position: ${args.mode.name}`);
if (mode == args.mode.name) {
return true;
} else {
return false;
}
});
switch_position_condition.registerArgumentAutocompleteListener('mode',
async (query, args) => {
return enums.getSwitchPositions();
}
);
const battery_status_condition = this.homey.flow.getConditionCard('battery_status_condition');
battery_status_condition.registerRunListener(async (args, state) => {
//this.log(`[${args.device.getName()}] Condition 'battery_status_condition' triggered`);
const status = args.device.getCapabilityValue('battery_status');
//this.log(`[${args.device.getName()}] - battery status: ${status}, condition status: ${args.status.name}`);
if (status == args.status.name) {
return true;
} else {
return false;
}
});
battery_status_condition.registerArgumentAutocompleteListener('status',
async (query, args) => {
return enums.getBatteryStatuses();
}
);
const vebus_status_condition = this.homey.flow.getConditionCard('vebus_status_condition');
vebus_status_condition.registerRunListener(async (args, state) => {
//this.log(`[${args.device.getName()}] Condition 'vebus_status_condition' triggered`);
const status = args.device.getCapabilityValue('vebus_status');
//this.log(`[${args.device.getName()}] - vebus status: ${status}, condition status: ${args.status.name}`);
if (status == args.status.name) {
return true;
} else {
return false;
}
});
vebus_status_condition.registerArgumentAutocompleteListener('status',
async (query, args) => {
return enums.getVEBusStatuses();
}
);
const battery_soc_condition = this.homey.flow.getConditionCard('battery_soc_condition');
battery_soc_condition.registerRunListener(async (args, state) => {
//this.log(`[${args.device.getName()}] Condition 'battery_soc_condition' triggered`);
const soc = args.device.getCapabilityValue('measure_battery');
//this.log(`[${args.device.getName()}] - battery soc: ${soc}, condition soc: ${args.soc}`);
if (soc < args.soc) {
return true;
} else {
return false;
}
});
const consumption_power_condition = this.homey.flow.getConditionCard('consumption_power_condition');
consumption_power_condition.registerRunListener(async (args, state) => {
//this.log(`[${args.device.getName()}] Condition 'consumption_power_condition' triggered`);
const power = args.device.getCapabilityValue('measure_power');
//this.log(`[${args.device.getName()}] - consumption power: ${power}, condition power: ${args.power}`);
if (power < args.power) {
return true;
} else {
return false;
}
});
const grid_power_condition = this.homey.flow.getConditionCard('grid_power_condition');
grid_power_condition.registerRunListener(async (args, state) => {
//this.log(`[${args.device.getName()}] Condition 'grid_power_condition' triggered`);
const power = args.device.getCapabilityValue('measure_power.grid');
//this.log(`[${args.device.getName()}] - grid power: ${power}, condition power: ${args.power}`);
if (power < args.power) {
return true;
} else {
return false;
}
});
const battery_power_condition = this.homey.flow.getConditionCard('battery_power_condition');
battery_power_condition.registerRunListener(async (args, state) => {
//this.log(`[${args.device.getName()}] Condition 'battery_power_condition' triggered`);
const power = args.device.getCapabilityValue('measure_power.battery');
//this.log(`[${args.device.getName()}] - battery power: ${power}, condition power: ${args.power}`);
if (power < args.power) {
return true;
} else {
return false;
}
});
const solar_power_condition = this.homey.flow.getConditionCard('solar_power_condition');
solar_power_condition.registerRunListener(async (args, state) => {
//this.log(`[${args.device.getName()}] Condition 'solar_power_condition' triggered`);
const power = args.device.getCapabilityValue('measure_power.PV');
//this.log(`[${args.device.getName()}] - solar power: ${power}, condition power: ${args.power}`);
if (power < args.power) {
return true;
} else {
return false;
}
});
const excess_solar_power_condition = this.homey.flow.getConditionCard('excess_solar_power_condition');
excess_solar_power_condition.registerRunListener(async (args, state) => {
//this.log(`[${args.device.getName()}] Condition 'excess_solar_power_condition' triggered`);
const excess = args.device.calculateExcessSolar();
//this.log(`[${args.device.getName()}] - excess solar power: ${excess}, condition power: ${args.power}`);
if (excess < args.power) {
return true;
} else {
return false;
}
});
const charger_current_condition = this.homey.flow.getConditionCard('charger_current_condition');
charger_current_condition.registerRunListener(async (args, state) => {
//this.log(`[${args.device.getName()}] Condition 'charger_current_condition' triggered`);
const current = args.device.getCapabilityValue('measure_current.maxCharge');
//this.log(`[${args.device.getName()}] - max charge current: ${current}`);
//this.log(`[${args.device.getName()}] - condition type: ${args.conditionType.id}, condition current: ${args.current}`);
return conditionHandler.evaluateNumericCondition(args.conditionType.id, args.current, current);
});
charger_current_condition.registerArgumentAutocompleteListener('conditionType',
async (query, args) => {
return conditionHandler.getNumberConditions();
}
);
const grid_setpoint_condition = this.homey.flow.getConditionCard('grid_setpoint_condition');
grid_setpoint_condition.registerRunListener(async (args, state) => {
//this.log(`[${args.device.getName()}] Condition 'grid_setpoint_condition' triggered`);
const power = args.device.getCapabilityValue('measure_power.gridSetpoint');
//this.log(`[${args.device.getName()}] - grid setpoint power: ${power}`);
//this.log(`[${args.device.getName()}] - condition type: ${args.conditionType.id}, condition power: ${args.power}`);
return conditionHandler.evaluateNumericCondition(args.conditionType.id, args.power, power);
});
grid_setpoint_condition.registerArgumentAutocompleteListener('conditionType',
async (query, args) => {
return conditionHandler.getNumberConditions();
}
);
const inverter_power_condition = this.homey.flow.getConditionCard('inverter_power_condition');
inverter_power_condition.registerRunListener(async (args, state) => {
//this.log(`[${args.device.getName()}] Condition 'inverter_power_condition' triggered`);
const power = args.device.getCapabilityValue('measure_power.maxDischarge');
//this.log(`[${args.device.getName()}] - active max inverter power: ${power}`);
//this.log(`[${args.device.getName()}] - condition type: ${args.conditionType.id}, condition power: ${args.power}`);
return conditionHandler.evaluateNumericCondition(args.conditionType.id, args.power, power);
});
inverter_power_condition.registerArgumentAutocompleteListener('conditionType',
async (query, args) => {
return conditionHandler.getNumberConditions();
}
);
const grid_feedin_condition = this.homey.flow.getConditionCard('grid_feedin_condition');
grid_feedin_condition.registerRunListener(async (args, state) => {
//this.log(`[${args.device.getName()}] Condition 'grid_feedin_condition' triggered`);
const power = args.device.getCapabilityValue('measure_power.maxGridFeedin');
//this.log(`[${args.device.getName()}] - max grid feed-in power: ${power}`);
//this.log(`[${args.device.getName()}] - condition type: ${args.conditionType.id}, condition power: ${args.power}`);
return conditionHandler.evaluateNumericCondition(args.conditionType.id, args.power, power);
});
grid_feedin_condition.registerArgumentAutocompleteListener('conditionType',
async (query, args) => {
return conditionHandler.getNumberConditions();
}
);
const minimum_soc_condition = this.homey.flow.getConditionCard('minimum_soc_condition');
minimum_soc_condition.registerRunListener(async (args, state) => {
//this.log(`[${args.device.getName()}] Condition 'minimum_soc_condition' triggered`);
const previousReadings = args.device.getStoreValue('previousReadings');
const soc = previousReadings.minimumSOC;
//this.log(`[${args.device.getName()}] - minimum soc: ${soc}`);
//this.log(`[${args.device.getName()}] - condition type: ${args.conditionType.id}, condition soc: ${args.soc}`);
return conditionHandler.evaluateNumericCondition(args.conditionType.id, args.soc, soc);
});
minimum_soc_condition.registerArgumentAutocompleteListener('conditionType',
async (query, args) => {
return conditionHandler.getNumberConditions();
}
);
const ac_loads_condition = this.homey.flow.getConditionCard('ac_loads_condition');
ac_loads_condition.registerRunListener(async (args, state) => {
//this.log(`[${args.device.getName()}] Condition 'ac_loads_condition' triggered`);
const previousReadings = args.device.getStoreValue('previousReadings');
const ac_loads = previousReadings.consumptionL1 +
previousReadings.consumptionL2 + previousReadings.consumptionL3;
//this.log(`[${args.device.getName()}] - AC loads: ${ac_loads}, condition power: ${args.power}`);
if (ac_loads < args.power) {
return true;
} else {
return false;
}
});
const ac_input_condition = this.homey.flow.getConditionCard('ac_input_condition');
ac_input_condition.registerRunListener(async (args, state) => {
//this.log(`[${args.device.getName()}] Condition 'ac_input_condition' triggered`);
const previousReadings = args.device.getStoreValue('previousReadings');
const ac_inputs = previousReadings.inputL1 +
previousReadings.inputL2 + previousReadings.inputL3;
//this.log(`[${args.device.getName()}] - AC inputs: ${ac_inputs}, condition power: ${args.power}`);
if (ac_inputs < args.power) {
return true;
} else {
return false;
}
});
const ac_output_condition = this.homey.flow.getConditionCard('ac_output_condition')
ac_output_condition.registerRunListener(async (args, state) => {
//this.log(`[${args.device.getName()}] Condition 'ac_output_condition' triggered`);
const previousReadings = args.device.getStoreValue('previousReadings');
const ac_outputs = previousReadings.outputL1 +
previousReadings.outputL2 + previousReadings.outputL3;
//this.log(`[${args.device.getName()}] - AC outputs: ${ac_outputs}, condition power: ${args.power}`);
if (ac_outputs < args.power) {
return true;
} else {
return false;
}
});
const timeSinceLastFullCharge_condition = this.homey.flow.getConditionCard('timeSinceLastFullCharge_condition');
timeSinceLastFullCharge_condition.registerRunListener(async (args, state) => {
//this.log(`[${args.device.getName()}] Condition 'timeSinceLastFullCharge_condition' triggered`);
const previousReadings = args.device.getStoreValue('previousReadings');
//this.log(`[${args.device.getName()}] - Time since last full charge: ${previousReadings.timeSinceLastFullCharge}, condition time: ${args.time}`);
if (previousReadings.timeSinceLastFullCharge < args.time) {
return true;
} else {
return false;
}
});
const scheduled_charging_condition = this.homey.flow.getConditionCard('scheduled_charging_condition');
scheduled_charging_condition.registerRunListener(async (args, state) => {
//this.log(`[${args.device.getName()}] Condition 'scheduled_charging_condition' triggered`);
//this.log(`[${args.device.getName()}] - schedule: '${args.schedule.id}' (${args.schedule.name})`);
return args.device.api.isChargingScheduleEnabled(
args.device.getSetting('ssh_user'),
args.device.getSetting('ssh_private_key'),
args.schedule.id
)
.then(function (result) {
return Promise.resolve(result);
}).catch(reason => {
return Promise.reject(reason);
});
});
scheduled_charging_condition.registerArgumentAutocompleteListener('schedule',
async (query, args) => {
return enums.getChargingSchedule();
}
);
}
async loadActions() {
this.log('Loading actions...');
const enable_charging_schedule = this.homey.flow.getActionCard('enable_charging_schedule');
enable_charging_schedule.registerRunListener(async (args) => {
this.log(`[${args.device.getName()}] Action 'enable_charging_schedule' triggered`);
this.log(`[${args.device.getName()}] - schedule: '${args.schedule.id}' (${args.schedule.name})`);
return args.device.api.enableChargingSchedule(
args.device.getSetting('ssh_user'),
args.device.getSetting('ssh_private_key'),
args.schedule.id
)
.then(function (result) {
return Promise.resolve(result);
}).catch(reason => {
return Promise.reject(reason);
});
});
enable_charging_schedule.registerArgumentAutocompleteListener('schedule',
async (query, args) => {
return enums.getChargingSchedule();
}
);
const disable_charging_schedule = this.homey.flow.getActionCard('disable_charging_schedule');
disable_charging_schedule.registerRunListener(async (args) => {
this.log(`[${args.device.getName()}] Action 'disable_charging_schedule' triggered`);
this.log(`[${args.device.getName()}] - schedule: '${args.schedule.id}' (${args.schedule.name})`);
return args.device.api.disableChargingSchedule(
args.device.getSetting('ssh_user'),
args.device.getSetting('ssh_private_key'),
args.schedule.id
)
.then(function (result) {
return Promise.resolve(result);
}).catch(reason => {
return Promise.reject(reason);
});
});
disable_charging_schedule.registerArgumentAutocompleteListener('schedule',
async (query, args) => {
return enums.getChargingSchedule();
}
);
const create_charging_schedule = this.homey.flow.getActionCard('create_charging_schedule');
create_charging_schedule.registerRunListener(async (args) => {
this.log(`[${args.device.getName()}] Action 'create_charging_schedule' triggered`);
this.log(`[${args.device.getName()}] - schedule: '${args.schedule.id}' (${args.schedule.name})`);
this.log(`[${args.device.getName()}] - day: '${args.day.id}' (${args.day.name})`);
this.log(`[${args.device.getName()}] - start: '${args.start}'`);
this.log(`[${args.device.getName()}] - duration: '${args.duration}'`);
this.log(`[${args.device.getName()}] - soc: '${args.soc}'`);
return args.device.api.createChargingSchedule(
args.device.getSetting('ssh_user'),
args.device.getSetting('ssh_private_key'),
args.schedule.id,
args.day.id,
args.start,
args.duration,
args.soc
)
.then(function (result) {
return Promise.resolve(result);
}).catch(reason => {
return Promise.reject(reason);
});
});
create_charging_schedule.registerArgumentAutocompleteListener('schedule',
async (query, args) => {
return enums.getChargingSchedule();
}
);
create_charging_schedule.registerArgumentAutocompleteListener('day',
async (query, args) => {
return enums.getChargingScheduleDay();
}
);
const set_relay1_state = this.homey.flow.getActionCard('set_relay1_state');
set_relay1_state.registerRunListener(async (args) => {
this.log(`[${args.device.getName()}] Action 'set_relay1_state' triggered`);
this.log(`[${args.device.getName()}] - state: '${args.state.id}' (${args.state.name})`);
if (args.state.id == 'true') {
return args.device.api.turnOnGXRelay1()
.then(function (result) {
return Promise.resolve(true);
}).catch(reason => {
return Promise.reject('Failed to turn on relay1');
});
} else {
return args.device.api.turnOffGXRelay1()
.then(function (result) {
return Promise.resolve(true);
}).catch(reason => {
return Promise.reject('Failed to turn off relay1');
});
}
});
set_relay1_state.registerArgumentAutocompleteListener('state',
async (query, args) => {
return enums.getRelayState();
}
);
const set_relay2_state = this.homey.flow.getActionCard('set_relay2_state');
set_relay2_state.registerRunListener(async (args) => {
this.log(`[${args.device.getName()}] Action 'set_relay2_state' triggered`);
this.log(`[${args.device.getName()}] - state: '${args.state.id}' (${args.state.name})`);
if (args.state.id == 'true') {
return args.device.api.turnOnGXRelay2()
.then(function (result) {
return Promise.resolve(true);
}).catch(reason => {
return Promise.reject('Failed to turn on relay2');
});
} else {
return args.device.api.turnOffGXRelay2()
.then(function (result) {
return Promise.resolve(true);
}).catch(reason => {
return Promise.reject('Failed to turn off relay2');
});
}
});
set_relay2_state.registerArgumentAutocompleteListener('state',
async (query, args) => {
return enums.getRelayState();
}
);
const set_switch_position = this.homey.flow.getActionCard('set_switch_position');
set_switch_position.registerRunListener(async (args) => {
this.log(`[${args.device.getName()}] Action 'set_switch_position' triggered`);
this.log(`[${args.device.getName()}] - switch position: '${args.mode.id}' (${args.mode.name})`);
return args.device.api.setSwitchPosition(args.mode.id)
.then(function (result) {
return Promise.resolve(true);
}).catch(reason => {
return Promise.reject('Failed to set switch position');
});
});
set_switch_position.registerArgumentAutocompleteListener('mode',
async (query, args) => {
return enums.getSwitchPositions();
}
);
const set_batterylife_state = this.homey.flow.getActionCard('set_batterylife_state');
set_batterylife_state.registerRunListener(async (args) => {
this.log(`[${args.device.getName()}] Action 'set_batterylife_state' triggered`);
this.log(`[${args.device.getName()}] - state: '${args.mode.id}' (${args.mode.name})`);
return args.device.api.setBatteryLifeState(args.mode.id)
.then(function (result) {
return Promise.resolve(true);
}).catch(reason => {
return Promise.reject('Failed to set batterylife state');
});
});
set_batterylife_state.registerArgumentAutocompleteListener('mode',
async (query, args) => {
return enums.getBatteryLifeState();
}
);
const set_ess_state = this.homey.flow.getActionCard('set_ess_state');
set_ess_state.registerRunListener(async (args) => {
this.log(`[${args.device.getName()}] Action 'set_ess_state' triggered`);
this.log(`[${args.device.getName()}] - state: '${args.mode.id}' (${args.mode.name})`);
return args.device.api.setMultiphaseRegulation(args.mode.id)
.then(function (result) {
return Promise.resolve(true);
}).catch(reason => {
return Promise.reject('Failed to set multiphase regulation state');
});
});
set_ess_state.registerArgumentAutocompleteListener('mode',
async (query, args) => {
return enums.getESSState();
}
);
const update_grid_setpoint = this.homey.flow.getActionCard('update_grid_setpoint');
update_grid_setpoint.registerRunListener(async (args) => {
this.log(`[${args.device.getName()}] Action 'update_grid_setpoint' triggered`);
this.log(`[${args.device.getName()}] - power: '${args.power}'`);
return args.device.api.writeGridSetpoint(args.power)
.then(function (result) {
return Promise.resolve(true);
}).catch(reason => {
return Promise.reject('Failed to update grid setpoint');
});
});
const limit_inverter = this.homey.flow.getActionCard('limit_inverter');
limit_inverter.registerRunListener(async (args) => {
this.log(`[${args.device.getName()}] Action 'limit_inverter' triggered`);
this.log(`[${args.device.getName()}] - power: '${args.power}'`);
return args.device.api.limitInverterPower(args.power)
.then(function (result) {
return Promise.resolve(true);
}).catch(reason => {
return Promise.reject('Failed to set inverter power limit');
});
});
const limit_charger = this.homey.flow.getActionCard('limit_charger');
limit_charger.registerRunListener(async (args) => {
this.log(`[${args.device.getName()}] Action 'limit_charger' triggered`);
this.log(`[${args.device.getName()}] - current: '${args.current}'`);
return args.device.api.limitChargerCurrent(args.current)
.then(function (result) {
return Promise.resolve(true);
}).catch(reason => {
return Promise.reject('Failed to set charger current limit');
});
});
const limit_grid_feedin = this.homey.flow.getActionCard('limit_grid_feedin');
limit_grid_feedin.registerRunListener(async (args) => {
this.log(`[${args.device.getName()}] Action 'limit_grid_feedin' triggered`);
this.log(`[${args.device.getName()}] - power: '${args.power}'`);
return args.device.api.limitGridFeedInPower(args.power)
.then(function (result) {
return Promise.resolve(true);
}).catch(reason => {
return Promise.reject('Failed to set grid feed-in limit');
});
});
const update_minimum_soc = this.homey.flow.getActionCard('update_minimum_soc');
update_minimum_soc.registerRunListener(async (args) => {
this.log(`[${args.device.getName()}] Action 'update_minimum_soc' triggered`);
this.log(`[${args.device.getName()}] - soc: '${args.soc}'`);
return args.device.api.writeESSMinimumSOC(args.soc)
.then(function (result) {
return Promise.resolve(true);
}).catch(reason => {
return Promise.reject('Failed to update grid setpoint');
});
});
const set_evcharger_mode = this.homey.flow.getActionCard('set_evcharger_mode');
set_evcharger_mode.registerRunListener(async (args) => {
this.log(`[${args.device.getName()}] Action 'set_evcharger_mode' triggered`);
this.log(`[${args.device.getName()}] - state: '${args.mode.id}' (${args.mode.name})`);
return args.device.api.setChargerMode(args.mode.id)
.then(function (result) {
return Promise.resolve(true);
}).catch(reason => {
return Promise.reject('Failed to set EV charger mode');
});
});
set_evcharger_mode.registerArgumentAutocompleteListener('mode',
async (query, args) => {
return enums.getEvChargerModeType();
}
);
const set_evcharger_current = this.homey.flow.getActionCard('set_evcharger_current');
set_evcharger_current.registerRunListener(async (args) => {
this.log(`[${args.device.getName()}] Action 'set_evcharger_current' triggered`);
this.log(`[${args.device.getName()}] - current: '${args.current}'`);
return args.device.api.setChargerCurrent(args.current)
.then(function (result) {
return Promise.resolve(true);
}).catch(reason => {
return Promise.reject('Failed to set charger current');
});
});
}
}
module.exports = VictronEnergyApp;