homebridge-smartsystem 6.1.7 → 6.2.2
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/README.md +14 -0
- package/accessories/accessory.js +4 -4
- package/accessories/accessory.ts +1 -2
- package/accessories/dimmer.js +6 -6
- package/accessories/dimmer.ts +1 -1
- package/accessories/door.js +2 -2
- package/accessories/door.ts +1 -1
- package/accessories/garagedoor.js +5 -4
- package/accessories/garagedoor.ts +2 -1
- package/accessories/lock.js +6 -5
- package/accessories/lock.ts +2 -1
- package/accessories/mood.js +2 -1
- package/accessories/mood.ts +2 -1
- package/accessories/temperature.js +2 -2
- package/accessories/temperature.ts +1 -1
- package/accessories/windowcovering.js +8 -7
- package/accessories/windowcovering.ts +2 -1
- package/config.json +169 -228
- package/config.smappee.json +178 -2
- package/config.smartapp.json +63 -0
- package/duotecno/Q.js +8 -8
- package/duotecno/Q.ts +1 -1
- package/duotecno/api.js +3 -3
- package/duotecno/api.ts +2 -2
- package/duotecno/config.js +24 -23
- package/duotecno/config.ts +23 -16
- package/duotecno/logger.js +51 -0
- package/duotecno/logger.ts +41 -0
- package/duotecno/master.js +4 -6
- package/duotecno/master.ts +2 -4
- package/duotecno/protocol.js +10 -9
- package/duotecno/protocol.ts +2 -1
- package/duotecno/system.js +17 -41
- package/duotecno/system.ts +7 -34
- package/duotecno/types.js +58 -131
- package/duotecno/types.ts +65 -125
- package/index.spec.js +22 -36
- package/index.spec.ts +20 -33
- package/package.json +2 -2
- package/server/base.js +10 -38
- package/server/base.ts +9 -42
- package/server/p1.js +9 -8
- package/server/p1.ts +6 -4
- package/server/platform.js +66 -36
- package/server/platform.ts +47 -12
- package/server/powerbase.js +15 -55
- package/server/powerbase.ts +4 -50
- package/server/shelly.js +4 -4
- package/server/shelly.ts +3 -2
- package/server/smappee.js +9 -8
- package/server/smappee.ts +4 -3
- package/server/smartapp.js +94 -39
- package/server/smartapp.ts +73 -20
- package/server/socapp.js +6 -6
- package/server/socapp.ts +2 -1
- package/server/somfy.js +12 -12
- package/server/somfy.ts +1 -1
- package/server/support.js +13 -13
- package/server/support.ts +4 -4
- package/server/views/style.ejs +1 -0
- package/server/views/switch-details.ejs +15 -5
- package/server/webapp.js +45 -47
- package/server/webapp.ts +29 -38
- package/config.groups.json +0 -8
- package/config.p1-dev.json +0 -59
- package/config.scenes.json +0 -15
package/duotecno/master.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Node, Protocol, Unit, recName, Rec, TempPreset } from "./protocol";
|
|
2
|
-
import { MasterConfig, WriteError, CommRecord, Message, Sanitizers
|
|
2
|
+
import { MasterConfig, WriteError, CommRecord, Message, Sanitizers } from "./types";
|
|
3
|
+
import { log, debug } from "./logger";
|
|
3
4
|
import { System } from "./system";
|
|
4
5
|
import { Base } from "../server/base";
|
|
5
6
|
|
|
@@ -30,9 +31,6 @@ export class Master extends Base {
|
|
|
30
31
|
// command was sent, no response received yet
|
|
31
32
|
|
|
32
33
|
/* system.config: {
|
|
33
|
-
"language": "EN",
|
|
34
|
-
"stores": false,
|
|
35
|
-
"multiple": false,
|
|
36
34
|
"socketserver": "akiworks.be",
|
|
37
35
|
"socketport": 9999,
|
|
38
36
|
"mood": "sfeer",
|
package/duotecno/protocol.js
CHANGED
|
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.Protocol = exports.Unit = exports.Node = exports.recName = exports.Rec = exports.TempPreset = exports.cmdName = void 0;
|
|
13
13
|
const types_1 = require("./types");
|
|
14
|
+
const logger_1 = require("./logger");
|
|
14
15
|
// Duotecno master IP protocol implementation
|
|
15
16
|
// Johan Coppieters
|
|
16
17
|
//
|
|
@@ -522,14 +523,14 @@ exports.Protocol = {
|
|
|
522
523
|
// if no enclosing "[...]", add them
|
|
523
524
|
if (data[0] != "[")
|
|
524
525
|
data = "[" + data + "]";
|
|
525
|
-
(0,
|
|
526
|
+
(0, logger_1.log)("protocol", "sending: " + cmdName(cmd) + " - " + data);
|
|
526
527
|
try {
|
|
527
528
|
// append a LF char and send
|
|
528
529
|
socket.write(data + String.fromCharCode(10));
|
|
529
530
|
return types_1.WriteError.writeOK;
|
|
530
531
|
}
|
|
531
532
|
catch (err) {
|
|
532
|
-
(0,
|
|
533
|
+
(0, logger_1.log)("protocol", "error sending through socket " + err.message);
|
|
533
534
|
return types_1.WriteError.writeFatal;
|
|
534
535
|
}
|
|
535
536
|
}
|
|
@@ -574,7 +575,7 @@ exports.Protocol = {
|
|
|
574
575
|
// get the first byte to see what kind of incoming data
|
|
575
576
|
nextRec.cmd = nextRec.message[0];
|
|
576
577
|
nextRec.isStatus = this.isStatus(nextRec.cmd);
|
|
577
|
-
(0,
|
|
578
|
+
(0, logger_1.debug)("protocol", "processing: " + (nextRec.isStatus ? "status -> " : "") + msg);
|
|
578
579
|
}
|
|
579
580
|
}
|
|
580
581
|
return nextRec;
|
|
@@ -684,7 +685,7 @@ exports.Protocol = {
|
|
|
684
685
|
unit.hsun = next.message[13] * 256 + next.message[14]; // 10x temperature
|
|
685
686
|
unit.moon = next.message[15] * 256 + next.message[16]; // 10x temperature
|
|
686
687
|
unit.hmoon = next.message[17] * 256 + next.message[18]; // 10x temperature
|
|
687
|
-
(0,
|
|
688
|
+
(0, logger_1.debug)("protocol", "received status - " + unit.getDisplayName() + ", temperature = " + unit.value / 10.0 + ", sun = " + unit.sun);
|
|
688
689
|
kind = "S";
|
|
689
690
|
// Dimmers, switches and moods have
|
|
690
691
|
// - status (0=off,1=on,2=pir-on)
|
|
@@ -694,21 +695,21 @@ exports.Protocol = {
|
|
|
694
695
|
// switch -> boolean
|
|
695
696
|
unit.status = next.message[6];
|
|
696
697
|
unit.value = (next.message[6] > 0);
|
|
697
|
-
(0,
|
|
698
|
+
(0, logger_1.debug)("protocol", "received status - switch = " + unit.value);
|
|
698
699
|
kind = "S";
|
|
699
700
|
}
|
|
700
701
|
else if (next.cmd === Rec.Dimmer) {
|
|
701
702
|
// dimmer -> 0 .. 99
|
|
702
703
|
unit.status = next.message[6];
|
|
703
704
|
unit.value = next.message[7];
|
|
704
|
-
(0,
|
|
705
|
+
(0, logger_1.debug)("protocol", "received status - dimmer -> value=" + unit.value + " / status=" + unit.status);
|
|
705
706
|
kind = "S";
|
|
706
707
|
}
|
|
707
708
|
else if (next.cmd === Rec.Mood) {
|
|
708
709
|
// control -> boolean
|
|
709
710
|
unit.status = next.message[6];
|
|
710
711
|
unit.value = (next.message[6] != 0);
|
|
711
|
-
(0,
|
|
712
|
+
(0, logger_1.debug)("protocol", "received status - mood = " + unit.value);
|
|
712
713
|
kind = "S";
|
|
713
714
|
}
|
|
714
715
|
else if (next.cmd === Rec.Motor) {
|
|
@@ -716,7 +717,7 @@ exports.Protocol = {
|
|
|
716
717
|
// 0 = stopped, 1 stopped/down, 2 = stopped/up, 3 = busy/down, 4 = busy/up
|
|
717
718
|
unit.status = next.message[6];
|
|
718
719
|
unit.value = next.message[6];
|
|
719
|
-
(0,
|
|
720
|
+
(0, logger_1.debug)("protocol", "received status - motor = " + unit.value);
|
|
720
721
|
kind = "S";
|
|
721
722
|
}
|
|
722
723
|
else if (next.cmd === Rec.Macro) {
|
|
@@ -738,7 +739,7 @@ exports.Protocol = {
|
|
|
738
739
|
(next.message[4] === 11)) {
|
|
739
740
|
unit.value = next.message[6] * 256 + next.message[7];
|
|
740
741
|
}
|
|
741
|
-
(0,
|
|
742
|
+
(0, logger_1.debug)("protocol", "received status - macro -> value=" + unit.value + " / status=" + unit.status);
|
|
742
743
|
kind = "M";
|
|
743
744
|
}
|
|
744
745
|
// clear the timer to turn the mood off again.
|
package/duotecno/protocol.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CommRecord, Message, Sanitizers, NodeInfo, UnitInfo, DBInfo, WriteError, hex, NodeType, UnitType, UnitExtendedType, UnitState, two
|
|
1
|
+
import { CommRecord, Message, Sanitizers, NodeInfo, UnitInfo, DBInfo, WriteError, hex, NodeType, UnitType, UnitExtendedType, UnitState, two } from "./types";
|
|
2
|
+
import { debug, log } from "./logger";
|
|
2
3
|
import { Master } from "./master";
|
|
3
4
|
import { SmartSocket } from "./smartsocket";
|
|
4
5
|
import { EventEmitter } from "events";
|
package/duotecno/system.js
CHANGED
|
@@ -11,13 +11,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.System = void 0;
|
|
13
13
|
const master_1 = require("./master");
|
|
14
|
-
const
|
|
14
|
+
const logger_1 = require("./logger");
|
|
15
15
|
const protocol_1 = require("./protocol");
|
|
16
16
|
const base_1 = require("../server/base");
|
|
17
17
|
const events_1 = require("events");
|
|
18
18
|
class System extends base_1.Base {
|
|
19
|
-
constructor(
|
|
20
|
-
super("system"
|
|
19
|
+
constructor() {
|
|
20
|
+
super("system");
|
|
21
21
|
this.isBrowser = true;
|
|
22
22
|
this.isSplitted = false;
|
|
23
23
|
this.moods = [];
|
|
@@ -29,8 +29,6 @@ class System extends base_1.Base {
|
|
|
29
29
|
this.emitter = new events_1.EventEmitter();
|
|
30
30
|
protocol_1.Protocol.setEmitter(this.emitter);
|
|
31
31
|
this.emitter.on('update', this.checkScenes.bind(this));
|
|
32
|
-
// this.readConfig();
|
|
33
|
-
this.readGroups();
|
|
34
32
|
this.readScenes();
|
|
35
33
|
// open all masters listed in the config
|
|
36
34
|
this.masters = [];
|
|
@@ -46,7 +44,7 @@ class System extends base_1.Base {
|
|
|
46
44
|
yield this.openMaster(this.config.cmasters[inx], readDB);
|
|
47
45
|
}
|
|
48
46
|
catch (err) {
|
|
49
|
-
(0,
|
|
47
|
+
(0, logger_1.log)("system", err);
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
50
|
});
|
|
@@ -66,18 +64,18 @@ class System extends base_1.Base {
|
|
|
66
64
|
if ((typeof master.config.active === "boolean") && (!master.config.active))
|
|
67
65
|
return;
|
|
68
66
|
try {
|
|
69
|
-
(0,
|
|
67
|
+
(0, logger_1.log)("system", "opening master: " + master.getAddress());
|
|
70
68
|
yield master.open();
|
|
71
69
|
if (!(yield master.login()))
|
|
72
70
|
throw (new Error("Failed to log in"));
|
|
73
|
-
(0,
|
|
71
|
+
(0, logger_1.log)("system", "logged in on: " + master.getAddress());
|
|
74
72
|
yield master.getDatabase(readDB);
|
|
75
|
-
(0,
|
|
73
|
+
(0, logger_1.log)("system", "master: " + master.getAddress() + " opened with " + master.nodes.length + " nodes.");
|
|
76
74
|
this.triggerRebuild();
|
|
77
75
|
return master;
|
|
78
76
|
}
|
|
79
77
|
catch (e) {
|
|
80
|
-
(0,
|
|
78
|
+
(0, logger_1.err)("system", "failed to open master (" + e.toString() + ")");
|
|
81
79
|
return null;
|
|
82
80
|
// throw(e);
|
|
83
81
|
}
|
|
@@ -96,7 +94,7 @@ class System extends base_1.Base {
|
|
|
96
94
|
yield master.close();
|
|
97
95
|
}
|
|
98
96
|
catch (e) {
|
|
99
|
-
(0,
|
|
97
|
+
(0, logger_1.err)("system", "failed to close master on " + master.getAddress() + ":" + master.getPort());
|
|
100
98
|
}
|
|
101
99
|
}
|
|
102
100
|
// remove from list
|
|
@@ -149,7 +147,7 @@ class System extends base_1.Base {
|
|
|
149
147
|
this.writeConfig();
|
|
150
148
|
}
|
|
151
149
|
else {
|
|
152
|
-
(0,
|
|
150
|
+
(0, logger_1.err)("system", "didn't find the master " + master.getAddress() + ":" + master.getConfig().port + " in the config");
|
|
153
151
|
}
|
|
154
152
|
});
|
|
155
153
|
}
|
|
@@ -189,19 +187,6 @@ class System extends base_1.Base {
|
|
|
189
187
|
}
|
|
190
188
|
}
|
|
191
189
|
}
|
|
192
|
-
selectGroup(group) {
|
|
193
|
-
if (this.config.multiple) {
|
|
194
|
-
// multiple groups = just turn on/off
|
|
195
|
-
group.visible = !group.visible;
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
// turn of other groups if this one becomes visible
|
|
199
|
-
if (!group.visible)
|
|
200
|
-
this.groups.forEach(g => g.visible = false);
|
|
201
|
-
group.visible = !group.visible;
|
|
202
|
-
}
|
|
203
|
-
this.writeGroups();
|
|
204
|
-
}
|
|
205
190
|
//////////////////////////////////////
|
|
206
191
|
// Finding masters, nodes and units //
|
|
207
192
|
//////////////////////////////////////
|
|
@@ -355,14 +340,14 @@ class System extends base_1.Base {
|
|
|
355
340
|
return 0;
|
|
356
341
|
}
|
|
357
342
|
// sort masters, nodes in masters, units in nodes.
|
|
358
|
-
(0,
|
|
343
|
+
(0, logger_1.log)("system", "rebuildMasters (" + this.masters.length + ") -> nodes -> units");
|
|
359
344
|
this.masters.sort(compare);
|
|
360
345
|
this.masters.forEach((m) => {
|
|
361
346
|
m.nodes.sort(compare);
|
|
362
347
|
m.nodes.forEach((n) => n.units.sort(compare));
|
|
363
348
|
});
|
|
364
349
|
// sort selected controls, temperatures and moods.
|
|
365
|
-
(0,
|
|
350
|
+
(0, logger_1.log)("system", "rebuildServices");
|
|
366
351
|
const services = this.allActiveUnits();
|
|
367
352
|
this.controls = services.filter(s => s.isCtrl()).sort(compareN);
|
|
368
353
|
this.temperatures = services.filter(s => s.isTemperature()).sort(compareN);
|
|
@@ -372,7 +357,7 @@ class System extends base_1.Base {
|
|
|
372
357
|
// should be of all active masters, nodes and units !!
|
|
373
358
|
// this.allMasters(m => m.allNodes(n => {if (n.nrUnits != n.units.length) complete = false; }))
|
|
374
359
|
if (complete) {
|
|
375
|
-
(0,
|
|
360
|
+
(0, logger_1.log)("system", "emitting READY");
|
|
376
361
|
this.emitter.emit('ready', this.masters.length);
|
|
377
362
|
}
|
|
378
363
|
}
|
|
@@ -383,13 +368,13 @@ class System extends base_1.Base {
|
|
|
383
368
|
// called by updateState that is listening for status changes
|
|
384
369
|
const scene = this.scenes.find(s => unit.isUnit(s.trigger.masterAddress, s.trigger.masterPort, s.trigger.logicalNodeAddress, s.trigger.logicalAddress));
|
|
385
370
|
if (scene) {
|
|
386
|
-
(0,
|
|
371
|
+
(0, logger_1.debug)("system", "scene found -> " + scene.name + ", value = " + scene.trigger.value + " unit = " + unit.value);
|
|
387
372
|
console.log(scene);
|
|
388
373
|
// if (unit.sameValue(scene.trigger.value)) {
|
|
389
374
|
scene.units.forEach(u => {
|
|
390
375
|
const unit = this.findUnit(u.masterAddress, u.masterPort, u.logicalNodeAddress, u.logicalAddress);
|
|
391
376
|
if (unit) {
|
|
392
|
-
(0,
|
|
377
|
+
(0, logger_1.debug)("system", " - attached unit found -> " + unit.getDisplayName() + " -> " + u.value);
|
|
393
378
|
unit.setState(u.value);
|
|
394
379
|
}
|
|
395
380
|
});
|
|
@@ -399,23 +384,14 @@ class System extends base_1.Base {
|
|
|
399
384
|
//////////////////
|
|
400
385
|
// Config stuff //
|
|
401
386
|
//////////////////
|
|
402
|
-
readGroups() {
|
|
403
|
-
this.groups = this.read("groups");
|
|
404
|
-
// order the groups and reset the order indices
|
|
405
|
-
this.groups.sort((a, b) => a.order - b.order);
|
|
406
|
-
this.groups.forEach((g, i) => g.order = i);
|
|
407
|
-
}
|
|
408
387
|
readScenes() {
|
|
409
388
|
this.scenes = this.read("scenes");
|
|
410
|
-
// order the
|
|
389
|
+
// order the scenes and reset the order indices
|
|
411
390
|
this.scenes.sort((a, b) => a.order - b.order);
|
|
412
391
|
this.scenes.forEach((g, i) => g.order = i);
|
|
413
392
|
}
|
|
414
393
|
writeScenes() {
|
|
415
|
-
this.
|
|
416
|
-
}
|
|
417
|
-
writeGroups() {
|
|
418
|
-
this.groups = this.write("groups", this.groups);
|
|
394
|
+
this.write("scenes", this.scenes);
|
|
419
395
|
}
|
|
420
396
|
}
|
|
421
397
|
exports.System = System;
|
package/duotecno/system.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Master } from "./master";
|
|
2
|
-
import { SystemConfig, MasterConfig, UnitConfig, YN, GroupConfig, SceneConfig
|
|
2
|
+
import { SystemConfig, MasterConfig, UnitConfig, YN, GroupConfig, SceneConfig } from "./types";
|
|
3
|
+
import { log, err, debug } from "./logger";
|
|
3
4
|
import { Node, Unit, Protocol } from "./protocol";
|
|
4
5
|
import { Base } from "../server/base";
|
|
5
6
|
import { EventEmitter } from "events";
|
|
@@ -8,7 +9,6 @@ import { EventEmitter } from "events";
|
|
|
8
9
|
export class System extends Base {
|
|
9
10
|
public masters: Array<Master>;
|
|
10
11
|
public config: SystemConfig;
|
|
11
|
-
public groups: Array<GroupConfig>;
|
|
12
12
|
public isBrowser: boolean = true;
|
|
13
13
|
public isSplitted: boolean = false;
|
|
14
14
|
|
|
@@ -21,16 +21,14 @@ export class System extends Base {
|
|
|
21
21
|
public stores: Array<Unit> = [];
|
|
22
22
|
public scenes: Array<SceneConfig> = [];
|
|
23
23
|
|
|
24
|
-
constructor(
|
|
25
|
-
super("system"
|
|
24
|
+
constructor() {
|
|
25
|
+
super("system");
|
|
26
26
|
|
|
27
27
|
this.trigger = null;
|
|
28
28
|
this.emitter = new EventEmitter();
|
|
29
29
|
Protocol.setEmitter(this.emitter);
|
|
30
30
|
this.emitter.on('update', this.checkScenes.bind(this));
|
|
31
31
|
|
|
32
|
-
// this.readConfig();
|
|
33
|
-
this.readGroups();
|
|
34
32
|
this.readScenes();
|
|
35
33
|
|
|
36
34
|
// open all masters listed in the config
|
|
@@ -200,20 +198,6 @@ export class System extends Base {
|
|
|
200
198
|
}
|
|
201
199
|
|
|
202
200
|
|
|
203
|
-
selectGroup(group: GroupConfig) {
|
|
204
|
-
if (this.config.multiple) {
|
|
205
|
-
// multiple groups = just turn on/off
|
|
206
|
-
group.visible = !group.visible;
|
|
207
|
-
|
|
208
|
-
} else {
|
|
209
|
-
// turn of other groups if this one becomes visible
|
|
210
|
-
if (!group.visible)
|
|
211
|
-
this.groups.forEach(g => g.visible = false);
|
|
212
|
-
group.visible = ! group.visible;
|
|
213
|
-
}
|
|
214
|
-
this.writeGroups();
|
|
215
|
-
}
|
|
216
|
-
|
|
217
201
|
//////////////////////////////////////
|
|
218
202
|
// Finding masters, nodes and units //
|
|
219
203
|
//////////////////////////////////////
|
|
@@ -430,27 +414,16 @@ export class System extends Base {
|
|
|
430
414
|
// Config stuff //
|
|
431
415
|
//////////////////
|
|
432
416
|
|
|
433
|
-
readGroups() {
|
|
434
|
-
this.groups = this.read("groups");
|
|
435
|
-
|
|
436
|
-
// order the groups and reset the order indices
|
|
437
|
-
this.groups.sort((a,b) => a.order-b.order);
|
|
438
|
-
this.groups.forEach((g,i) => g.order = i);
|
|
439
|
-
}
|
|
440
417
|
readScenes() {
|
|
441
|
-
this.scenes = this.read("scenes");
|
|
418
|
+
this.scenes = <SceneConfig[]>this.read("scenes");
|
|
442
419
|
|
|
443
|
-
// order the
|
|
420
|
+
// order the scenes and reset the order indices
|
|
444
421
|
this.scenes.sort((a,b) => a.order-b.order);
|
|
445
422
|
this.scenes.forEach((g,i) => g.order = i);
|
|
446
423
|
}
|
|
447
424
|
|
|
448
425
|
writeScenes() {
|
|
449
|
-
this.
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
writeGroups() {
|
|
453
|
-
this.groups = this.write("groups", this.groups);
|
|
426
|
+
this.write("scenes", this.scenes);
|
|
454
427
|
}
|
|
455
428
|
|
|
456
429
|
|