homebridge-smartsystem 6.0.8 → 6.1.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/README.md +120 -1
- package/accessories/accessory.js +8 -7
- package/accessories/accessory.ts +9 -9
- package/accessories/bulb.js +2 -2
- package/accessories/bulb.ts +2 -3
- package/accessories/dimmer.js +9 -8
- package/accessories/dimmer.ts +9 -9
- package/accessories/door.js +4 -3
- package/accessories/door.ts +4 -5
- package/accessories/garagedoor.js +7 -7
- package/accessories/garagedoor.ts +8 -8
- package/accessories/lock.js +9 -8
- package/accessories/lock.ts +10 -10
- package/accessories/mood.js +4 -4
- package/accessories/mood.ts +5 -5
- package/accessories/switch.js +2 -2
- package/accessories/switch.ts +2 -3
- package/accessories/temperature.js +5 -4
- package/accessories/temperature.ts +5 -5
- package/accessories/windowcovering.js +10 -10
- package/accessories/windowcovering.ts +11 -11
- package/config.homebridge.json +2 -0
- package/config.p1-dev.json +6 -0
- package/config.p1.json +6 -0
- package/duotecno/Q.js +10 -9
- package/duotecno/Q.ts +10 -11
- package/duotecno/master.js +37 -21
- package/duotecno/master.ts +39 -22
- package/duotecno/protocol.js +15 -20
- package/duotecno/protocol.ts +14 -20
- package/duotecno/smartsocket.js +26 -22
- package/duotecno/smartsocket.ts +32 -26
- package/duotecno/system.js +17 -17
- package/duotecno/system.ts +17 -18
- package/duotecno/types.js +70 -3
- package/duotecno/types.ts +70 -5
- package/index.spec.js +18 -11
- package/index.spec.ts +20 -12
- package/package.json +1 -1
- package/run.js +1 -1
- package/run.ts +1 -1
- package/run9998.js +1 -1
- package/run9998.ts +1 -1
- package/run9999.js +1 -1
- package/run9999.ts +1 -1
- package/server/base.js +6 -21
- package/server/base.ts +8 -23
- package/server/p1.js +137 -0
- package/server/p1.ts +220 -0
- package/server/platform.js +63 -54
- package/server/platform.ts +65 -56
- package/server/powerbase.js +260 -0
- package/server/powerbase.ts +288 -0
- package/server/shelly.js +63 -0
- package/server/shelly.ts +65 -0
- package/server/{smappee.json → smappee-sample.json} +0 -0
- package/server/smappee.js +158 -274
- package/server/smappee.ts +156 -311
- package/server/smartapp.js +76 -127
- package/server/smartapp.ts +87 -129
- package/server/socapp.js +20 -18
- package/server/socapp.ts +20 -19
- package/server/somfy.js +12 -22
- package/server/somfy.ts +13 -22
- package/server/support.js +11 -11
- package/server/support.ts +11 -13
- package/server/views/footer.ejs +1 -1
- package/server/views/nav.ejs +5 -3
- package/server/views/{smappee-binding.ejs → power-binding.ejs} +4 -2
- package/server/views/{smappee-rule.ejs → power-rule.ejs} +12 -10
- package/server/views/{smappee.ejs → power.ejs} +44 -38
- package/server/views/settings.ejs +4 -4
- package/server/views/switch-details.ejs +0 -1
- package/server/webapp.js +22 -8
- package/server/webapp.ts +24 -9
package/README.md
CHANGED
|
@@ -237,6 +237,20 @@ switch =>
|
|
|
237
237
|
## v5.14.1 - todo
|
|
238
238
|
- listen on gpio pin
|
|
239
239
|
|
|
240
|
+
## v6.0.x - 01-07-2022
|
|
241
|
+
- .1: first version running on Homebridge UI
|
|
242
|
+
- .9: read version from package.json
|
|
243
|
+
- .10: removed "homekit" nav tab,
|
|
244
|
+
added "restart plugin" to settings,
|
|
245
|
+
set lock target state to "locked"
|
|
246
|
+
|
|
247
|
+
## v6.1.0 - 15-07-2022
|
|
248
|
+
- global debug, log, err functions in types.ts
|
|
249
|
+
- split smappee.ts in PowerBase + smappee/p1/shelly
|
|
250
|
+
|
|
251
|
+
## v6.1.1 - 21-07-2022 - P1 release
|
|
252
|
+
- R1: implemented P1 power meter telegram
|
|
253
|
+
- R2: bugfixes, timeout mgt, etc...
|
|
240
254
|
|
|
241
255
|
|
|
242
256
|
## Hardware
|
|
@@ -304,7 +318,112 @@ this $ is replaced by the value of the attached unit
|
|
|
304
318
|
Example: http://192.168.0.101/relay/0?turn=on&brightness=$
|
|
305
319
|
|
|
306
320
|
|
|
307
|
-
## How to set up a Raspberry Pi
|
|
321
|
+
## How to set up a Raspberry Pi - from V6.0 on
|
|
322
|
+
```
|
|
323
|
+
1. Setup Debian in Pi on 192.168.0.9
|
|
324
|
+
|
|
325
|
+
- download “Raspberry Pi Imager” from https://www.raspberrypi.com/software/
|
|
326
|
+
- install “Raspberry PI OS Lite 32bit” in settings: user, password, name, enable ssh, etc… in settings
|
|
327
|
+
- add “ip=192.168.0.9” to /boot/cmdline.txt (or whatever free address)
|
|
328
|
+
- put the card into a Pi and power on
|
|
329
|
+
- try to connect with ssh pi@192.168.0.9
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
2. Install Homebridge
|
|
333
|
+
|
|
334
|
+
(see instructions on https://github.com/homebridge/homebridge/wiki/Install-Homebridge-on-Raspbian)
|
|
335
|
+
|
|
336
|
+
Execute on the Pi via ssh:
|
|
337
|
+
|
|
338
|
+
# if forgotten:
|
|
339
|
+
# 1. for better security enable public key
|
|
340
|
+
mkdir ~/.ssh
|
|
341
|
+
chmod 700 ~/.ssh
|
|
342
|
+
cat "Mac/PC .ssh/id_rsa.pub" >> ~/.ssh/authorized_keys
|
|
343
|
+
chmod 600 ~/.ssh/authorized_keys
|
|
344
|
+
rm ~/id_rsa.pub
|
|
345
|
+
|
|
346
|
+
# 2. use pi-config
|
|
347
|
+
sudo raspi-config
|
|
348
|
+
-> enable ssh
|
|
349
|
+
-> boot to cmdline
|
|
350
|
+
|
|
351
|
+
# Add Homebridge to repo’s
|
|
352
|
+
curl -sSfL https://repo.homebridge.io/KEY.gpg | sudo gpg --dearmor | sudo tee /usr/share/keyrings/homebridge.gpg > /dev/null
|
|
353
|
+
echo "deb [signed-by=/usr/share/keyrings/homebridge.gpg] https://repo.homebridge.io stable main" | sudo tee /etc/apt/sources.list.d/homebridge.list > /dev/null
|
|
354
|
+
|
|
355
|
+
# Install Homebridge
|
|
356
|
+
sudo apt-get update
|
|
357
|
+
sudo apt-get --yes install homebridge
|
|
358
|
+
sudo ln -s /opt/homebridge/bin/node /usr/bin/node
|
|
359
|
+
sudo ln -s /opt/homebridge/bin/npm /usr/bin/npm
|
|
360
|
+
|
|
361
|
+
# install smappee and mqtt
|
|
362
|
+
sudo npm install -g --force mqtt
|
|
363
|
+
sudo ln -s /opt/homebridge/bin/mqtt /usr/bin/mqtt
|
|
364
|
+
|
|
365
|
+
# connect to homebridge UI with a browser
|
|
366
|
+
http://192.168.0.9:8581
|
|
367
|
+
add user, for example: pi / pw…
|
|
368
|
+
|
|
369
|
+
# add duotecno plugin to Homebridge config
|
|
370
|
+
go to "Plugins"
|
|
371
|
+
search for "smartsystem"
|
|
372
|
+
click "install"
|
|
373
|
+
|
|
374
|
+
# or in advance:
|
|
375
|
+
cd /var/lib/homebridge
|
|
376
|
+
sudo npm install --save homebridge-smartsystem
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
# set config to:
|
|
380
|
+
{
|
|
381
|
+
"manufacturer": "Duotecno-Coppieters",
|
|
382
|
+
"name": "Duotecno",
|
|
383
|
+
"platform": "DuotecnoPlatform",
|
|
384
|
+
"smappee": true,
|
|
385
|
+
"smartapp": true,
|
|
386
|
+
"system": true,
|
|
387
|
+
"socapp": false
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
# restart Homebridge in webbrowser (right top icon)
|
|
391
|
+
|
|
392
|
+
# connect to Duotecno gateway
|
|
393
|
+
http://192.168.0.9:5002
|
|
394
|
+
add master and off you go… see "setup" a little bit higher
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
3. Various optional
|
|
398
|
+
|
|
399
|
+
Updates
|
|
400
|
+
sudo apt-get update
|
|
401
|
+
sudo apt-get install homebridge
|
|
402
|
+
sudo hb-service update-node
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
Uninstall
|
|
406
|
+
sudo apt-get remove homebridge
|
|
407
|
+
sudo rm -rf /etc/apt/sources.list.d/homebridge.list
|
|
408
|
+
sudo apt-get purge homebridge
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
4. Smappee
|
|
412
|
+
|
|
413
|
+
#find uuid
|
|
414
|
+
mqtt sub -t 'servicelocation/#' -h '192.168.0.186’ -v
|
|
415
|
+
# -> 57e3e0d8-bb05-4b04-8662-1a9871998f3f
|
|
416
|
+
|
|
417
|
+
#add uuid
|
|
418
|
+
mqtt sub -t 'servicelocation/57e3e0d8-bb05-4b04-8662-1a9871998f3f/#' -h '192.168.0.186' -v
|
|
419
|
+
|
|
420
|
+
# http://pro.smappee.net
|
|
421
|
+
# duotecno/duotecno1234
|
|
422
|
+
# 192.168.0.2
|
|
423
|
+
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
## How to set up a Raspberry Pi - V1
|
|
308
427
|
|
|
309
428
|
### Copy SD Card
|
|
310
429
|
dump ->
|
package/accessories/accessory.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Accessory = void 0;
|
|
4
|
+
const types_1 = require("../duotecno/types");
|
|
4
5
|
// Johan Coppieters Jan 2019
|
|
5
6
|
//
|
|
6
7
|
// base class for all kind of accessories on our platform
|
|
7
8
|
// handling the homekit required services.
|
|
8
9
|
class Accessory {
|
|
9
|
-
constructor(
|
|
10
|
+
constructor(api, unit) {
|
|
10
11
|
this.homebridge = api.hap;
|
|
11
|
-
this.
|
|
12
|
-
this.unit = unit; // : Unit
|
|
12
|
+
this.unit = unit; // : Duotecno Unit
|
|
13
13
|
this.name = unit.getDisplayName();
|
|
14
14
|
this.uuid_base = unit.getSerialNr();
|
|
15
|
+
// get all services and add ours
|
|
15
16
|
this.services = this.getAccessoryServices();
|
|
16
17
|
this.services.push(this.getInformationService());
|
|
17
18
|
}
|
|
18
19
|
makeService(service) {
|
|
19
|
-
|
|
20
|
+
(0, types_1.log)("accessory", "accessory - Making service: " + this.name + ", serial: " + this.uuid_base);
|
|
20
21
|
this.me = new service(this.name);
|
|
21
22
|
return this.me;
|
|
22
23
|
}
|
|
@@ -49,7 +50,7 @@ class Accessory {
|
|
|
49
50
|
if (this.unit) {
|
|
50
51
|
this.unit.reqState(unit => {
|
|
51
52
|
next(null, unit.status);
|
|
52
|
-
|
|
53
|
+
(0, types_1.log)("accessory", "getState was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status);
|
|
53
54
|
}).catch(err => next(err));
|
|
54
55
|
}
|
|
55
56
|
else {
|
|
@@ -60,7 +61,7 @@ class Accessory {
|
|
|
60
61
|
if (this.unit) {
|
|
61
62
|
this.unit.reqState(unit => {
|
|
62
63
|
next(null, unit.value);
|
|
63
|
-
|
|
64
|
+
(0, types_1.log)("accessory", "getValue was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.value);
|
|
64
65
|
}).catch(err => next(err));
|
|
65
66
|
}
|
|
66
67
|
else {
|
|
@@ -85,7 +86,7 @@ class Accessory {
|
|
|
85
86
|
}
|
|
86
87
|
updateState() {
|
|
87
88
|
this.me.getCharacteristic(this.homebridge.Characteristic.On).updateValue(this.unit.status);
|
|
88
|
-
//
|
|
89
|
+
// log("accessory", "Received status change -> update accessory -> " + this.unit.getName() + " -> on = " + this.unit.status);
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
92
|
exports.Accessory = Accessory;
|
package/accessories/accessory.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { log } from "../duotecno/types";
|
|
2
2
|
import { Unit } from "../duotecno/protocol";
|
|
3
3
|
import { API, HAP, Service } from "homebridge";
|
|
4
4
|
|
|
@@ -9,7 +9,6 @@ import { API, HAP, Service } from "homebridge";
|
|
|
9
9
|
|
|
10
10
|
export class Accessory {
|
|
11
11
|
homebridge: HAP; // homebridge api endpoint
|
|
12
|
-
log: LogFunction;
|
|
13
12
|
unit: Unit;
|
|
14
13
|
config: any; // all config params
|
|
15
14
|
name: string;
|
|
@@ -18,18 +17,19 @@ export class Accessory {
|
|
|
18
17
|
me: Service;
|
|
19
18
|
|
|
20
19
|
|
|
21
|
-
constructor(
|
|
20
|
+
constructor(api: API, unit: Unit) {
|
|
22
21
|
this.homebridge = api.hap;
|
|
23
|
-
this.
|
|
24
|
-
this.unit = unit; // : Unit
|
|
22
|
+
this.unit = unit; // : Duotecno Unit
|
|
25
23
|
this.name = unit.getDisplayName();
|
|
26
24
|
this.uuid_base = unit.getSerialNr();
|
|
25
|
+
|
|
26
|
+
// get all services and add ours
|
|
27
27
|
this.services = this.getAccessoryServices();
|
|
28
28
|
this.services.push(this.getInformationService());
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
makeService(service: any): Service {
|
|
32
|
-
|
|
32
|
+
log("accessory", "accessory - Making service: " + this.name + ", serial: " + this.uuid_base);
|
|
33
33
|
this.me = new service(this.name);
|
|
34
34
|
return this.me;
|
|
35
35
|
}
|
|
@@ -69,7 +69,7 @@ export class Accessory {
|
|
|
69
69
|
if (this.unit) {
|
|
70
70
|
this.unit.reqState(unit => {
|
|
71
71
|
next(null, unit.status);
|
|
72
|
-
|
|
72
|
+
log("accessory", "getState was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status);
|
|
73
73
|
}).catch(err => next(err));
|
|
74
74
|
} else {
|
|
75
75
|
next( new Error("accessory - getState needs to be overridden if no unit is provided.") );
|
|
@@ -80,7 +80,7 @@ export class Accessory {
|
|
|
80
80
|
if (this.unit) {
|
|
81
81
|
this.unit.reqState(unit => {
|
|
82
82
|
next(null, unit.value);
|
|
83
|
-
|
|
83
|
+
log("accessory", "getValue was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.value);
|
|
84
84
|
}).catch(err => next(err));
|
|
85
85
|
} else {
|
|
86
86
|
next( new Error("accessory - getState needs to be overridden if no unit is provided.") );
|
|
@@ -107,7 +107,7 @@ export class Accessory {
|
|
|
107
107
|
|
|
108
108
|
updateState() {
|
|
109
109
|
this.me.getCharacteristic(this.homebridge.Characteristic.On).updateValue(this.unit.status);
|
|
110
|
-
//
|
|
110
|
+
// log("accessory", "Received status change -> update accessory -> " + this.unit.getName() + " -> on = " + this.unit.status);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
}
|
package/accessories/bulb.js
CHANGED
|
@@ -9,8 +9,8 @@ const accessory_1 = require("./accessory");
|
|
|
9
9
|
// so when asking to Siri to turn off all lights, these get turned off too.
|
|
10
10
|
// - does same thing as a dimmer (which is also a LightBulb), but we don't supper Brightness.
|
|
11
11
|
class Bulb extends accessory_1.Accessory {
|
|
12
|
-
constructor(
|
|
13
|
-
super(
|
|
12
|
+
constructor(homebridge, unit) {
|
|
13
|
+
super(homebridge, unit);
|
|
14
14
|
}
|
|
15
15
|
getAccessoryServices() {
|
|
16
16
|
const lightbulbService = this.makeService(this.homebridge.Service.Lightbulb);
|
package/accessories/bulb.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Accessory } from "./accessory";
|
|
2
|
-
import { LogFunction } from "../duotecno/types";
|
|
3
2
|
import { Unit } from "../duotecno/protocol";
|
|
4
3
|
import { API } from "homebridge";
|
|
5
4
|
|
|
@@ -13,8 +12,8 @@ import { API } from "homebridge";
|
|
|
13
12
|
|
|
14
13
|
export class Bulb extends Accessory {
|
|
15
14
|
|
|
16
|
-
constructor(
|
|
17
|
-
super(
|
|
15
|
+
constructor(homebridge: API, unit: Unit) {
|
|
16
|
+
super(homebridge, unit);
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
|
package/accessories/dimmer.js
CHANGED
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Dimmer = void 0;
|
|
4
4
|
const accessory_1 = require("./accessory");
|
|
5
|
+
const types_1 = require("../duotecno/types");
|
|
5
6
|
// Johan Coppieters Jan 2019
|
|
6
7
|
//
|
|
7
8
|
// Dimmer
|
|
8
9
|
// - a LightBulb to homekit, so a "light"
|
|
9
10
|
//
|
|
10
11
|
class Dimmer extends accessory_1.Accessory {
|
|
11
|
-
constructor(
|
|
12
|
-
super(
|
|
12
|
+
constructor(homebridge, unit) {
|
|
13
|
+
super(homebridge, unit);
|
|
13
14
|
this.currValue = 0;
|
|
14
15
|
this.preventSetPower = false;
|
|
15
16
|
this.waitingSetPower = false;
|
|
@@ -30,7 +31,7 @@ class Dimmer extends accessory_1.Accessory {
|
|
|
30
31
|
if (this.unit) {
|
|
31
32
|
this.unit.reqState(unit => {
|
|
32
33
|
next(null, unit.value);
|
|
33
|
-
|
|
34
|
+
(0, types_1.log)("accessory", "getBrightness was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.value);
|
|
34
35
|
}).catch(err => next(err));
|
|
35
36
|
}
|
|
36
37
|
else {
|
|
@@ -39,10 +40,10 @@ class Dimmer extends accessory_1.Accessory {
|
|
|
39
40
|
}
|
|
40
41
|
setPower(powerOn, next) {
|
|
41
42
|
this.waitingSetPower = true;
|
|
42
|
-
|
|
43
|
+
(0, types_1.log)("accessory", "setPower: *** waiting *** " + powerOn);
|
|
43
44
|
setTimeout(() => {
|
|
44
45
|
if (!this.preventSetPower) {
|
|
45
|
-
|
|
46
|
+
(0, types_1.log)("accessory", "setPower: " + powerOn);
|
|
46
47
|
this.unit.setState(powerOn)
|
|
47
48
|
.then(() => next())
|
|
48
49
|
.catch(err => next(err));
|
|
@@ -59,16 +60,16 @@ class Dimmer extends accessory_1.Accessory {
|
|
|
59
60
|
// crush set on/off requests, bug in homekit / homebridge
|
|
60
61
|
if (this.waitingSetPower) {
|
|
61
62
|
this.preventSetPower = true;
|
|
62
|
-
|
|
63
|
+
(0, types_1.log)("accessory", "setBrightness -> setPower: *** cancelled ***");
|
|
63
64
|
}
|
|
64
|
-
|
|
65
|
+
(0, types_1.log)("accessory", "setBrightness " + value);
|
|
65
66
|
this.unit.setState(value)
|
|
66
67
|
.then(() => next())
|
|
67
68
|
.catch(err => next(err));
|
|
68
69
|
}
|
|
69
70
|
updateState() {
|
|
70
71
|
this.me.getCharacteristic(this.homebridge.Characteristic.Brightness).updateValue(this.unit.value);
|
|
71
|
-
//
|
|
72
|
+
// log("accessory", "Received status change -> update accessory -> " + this.unit.getName() + " -> Brightness = " + this.unit.value);
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
exports.Dimmer = Dimmer;
|
package/accessories/dimmer.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Accessory } from "./accessory";
|
|
2
|
-
import { LogFunction } from "../duotecno/types";
|
|
3
2
|
import { Unit } from "../duotecno/protocol";
|
|
4
3
|
import { API } from "homebridge";
|
|
4
|
+
import { log } from "../duotecno/types";
|
|
5
5
|
|
|
6
6
|
// Johan Coppieters Jan 2019
|
|
7
7
|
//
|
|
@@ -15,8 +15,8 @@ export class Dimmer extends Accessory {
|
|
|
15
15
|
preventSetPower: boolean;
|
|
16
16
|
waitingSetPower: boolean;
|
|
17
17
|
|
|
18
|
-
constructor(
|
|
19
|
-
super(
|
|
18
|
+
constructor(homebridge: API, unit: Unit) {
|
|
19
|
+
super(homebridge, unit);
|
|
20
20
|
this.currValue = 0;
|
|
21
21
|
this.preventSetPower = false;
|
|
22
22
|
this.waitingSetPower = false;
|
|
@@ -42,7 +42,7 @@ export class Dimmer extends Accessory {
|
|
|
42
42
|
if (this.unit) {
|
|
43
43
|
this.unit.reqState(unit => {
|
|
44
44
|
next(null, unit.value);
|
|
45
|
-
|
|
45
|
+
log("accessory", "getBrightness was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.value);
|
|
46
46
|
}).catch(err => next(err));
|
|
47
47
|
} else {
|
|
48
48
|
next( new Error("accessory - getState needs to be overridden if no unit is provided.") );
|
|
@@ -51,10 +51,10 @@ export class Dimmer extends Accessory {
|
|
|
51
51
|
|
|
52
52
|
setPower(powerOn, next) {
|
|
53
53
|
this.waitingSetPower = true;
|
|
54
|
-
|
|
54
|
+
log("accessory", "setPower: *** waiting *** " + powerOn);
|
|
55
55
|
setTimeout( () => {
|
|
56
56
|
if (!this.preventSetPower) {
|
|
57
|
-
|
|
57
|
+
log("accessory", "setPower: " + powerOn);
|
|
58
58
|
this.unit.setState(powerOn)
|
|
59
59
|
.then(() => next())
|
|
60
60
|
.catch(err => next(err))
|
|
@@ -72,10 +72,10 @@ export class Dimmer extends Accessory {
|
|
|
72
72
|
// crush set on/off requests, bug in homekit / homebridge
|
|
73
73
|
if (this.waitingSetPower) {
|
|
74
74
|
this.preventSetPower = true;
|
|
75
|
-
|
|
75
|
+
log("accessory", "setBrightness -> setPower: *** cancelled ***");
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
log("accessory", "setBrightness " + value);
|
|
79
79
|
|
|
80
80
|
this.unit.setState(value)
|
|
81
81
|
.then(() => next())
|
|
@@ -84,7 +84,7 @@ export class Dimmer extends Accessory {
|
|
|
84
84
|
|
|
85
85
|
updateState() {
|
|
86
86
|
this.me.getCharacteristic(this.homebridge.Characteristic.Brightness).updateValue(this.unit.value);
|
|
87
|
-
//
|
|
87
|
+
// log("accessory", "Received status change -> update accessory -> " + this.unit.getName() + " -> Brightness = " + this.unit.value);
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
}
|
package/accessories/door.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Door = void 0;
|
|
4
|
+
const types_1 = require("../duotecno/types");
|
|
4
5
|
const windowcovering_1 = require("./windowcovering");
|
|
5
6
|
// Johan Coppieters Jun 2020
|
|
6
7
|
//
|
|
@@ -46,8 +47,8 @@ const windowcovering_1 = require("./windowcovering");
|
|
|
46
47
|
|
|
47
48
|
*/
|
|
48
49
|
class Door extends windowcovering_1.WindowCovering {
|
|
49
|
-
constructor(
|
|
50
|
-
super(
|
|
50
|
+
constructor(homebridge, unit) {
|
|
51
|
+
super(homebridge, unit);
|
|
51
52
|
}
|
|
52
53
|
getAccessoryServices() {
|
|
53
54
|
// DoorOpener needs authentication
|
|
@@ -67,7 +68,7 @@ class Door extends windowcovering_1.WindowCovering {
|
|
|
67
68
|
// in response to Duotecno status messages
|
|
68
69
|
updateState() {
|
|
69
70
|
const value = this.DT2HB(this.unit.status);
|
|
70
|
-
|
|
71
|
+
(0, types_1.log)("accessory", "Received updateState -> Homekit Door for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status + " / " + this.unit.value + " -> passing to HB: " + value);
|
|
71
72
|
this.me.getCharacteristic(this.homebridge.Characteristic.CurrentPosition).updateValue(value);
|
|
72
73
|
}
|
|
73
74
|
}
|
package/accessories/door.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { LogFunction, UnitMotorCmd, UnitState } from "../duotecno/types";
|
|
1
|
+
import { log } from "../duotecno/types";
|
|
3
2
|
import { WindowCovering } from "./windowcovering";
|
|
4
3
|
import { Unit } from "../duotecno/protocol";
|
|
5
4
|
import { API } from "homebridge";
|
|
@@ -53,8 +52,8 @@ import { API } from "homebridge";
|
|
|
53
52
|
export class Door extends WindowCovering {
|
|
54
53
|
targetState;
|
|
55
54
|
|
|
56
|
-
constructor(
|
|
57
|
-
super(
|
|
55
|
+
constructor(homebridge: API, unit: Unit) {
|
|
56
|
+
super(homebridge, unit);
|
|
58
57
|
}
|
|
59
58
|
|
|
60
59
|
getAccessoryServices() {
|
|
@@ -82,7 +81,7 @@ export class Door extends WindowCovering {
|
|
|
82
81
|
// in response to Duotecno status messages
|
|
83
82
|
updateState() {
|
|
84
83
|
const value = this.DT2HB(this.unit.status);
|
|
85
|
-
|
|
84
|
+
log("accessory", "Received updateState -> Homekit Door for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status + " / " + this.unit.value + " -> passing to HB: " + value);
|
|
86
85
|
this.me.getCharacteristic(this.homebridge.Characteristic.CurrentPosition).updateValue(value);
|
|
87
86
|
}
|
|
88
87
|
|
|
@@ -11,8 +11,8 @@ const accessory_1 = require("./accessory");
|
|
|
11
11
|
//
|
|
12
12
|
//
|
|
13
13
|
class GarageDoor extends accessory_1.Accessory {
|
|
14
|
-
constructor(
|
|
15
|
-
super(
|
|
14
|
+
constructor(homebridge, unit) {
|
|
15
|
+
super(homebridge, unit);
|
|
16
16
|
}
|
|
17
17
|
getAccessoryServices() {
|
|
18
18
|
// GarageDoorOpener needs authentication
|
|
@@ -55,7 +55,7 @@ class GarageDoor extends accessory_1.Accessory {
|
|
|
55
55
|
try {
|
|
56
56
|
this.unit.reqState(unit => {
|
|
57
57
|
const hb = this.DT2HB(unit.status);
|
|
58
|
-
|
|
58
|
+
(0, types_1.log)("accessory", "Get TargetDoorState of " + this.name + " = " + unit.status + " -> " + hb);
|
|
59
59
|
next(null, hb);
|
|
60
60
|
});
|
|
61
61
|
}
|
|
@@ -69,24 +69,24 @@ class GarageDoor extends accessory_1.Accessory {
|
|
|
69
69
|
this.targetState = value;
|
|
70
70
|
let cmd = this.HB2DT(value);
|
|
71
71
|
if (cmd) {
|
|
72
|
-
|
|
72
|
+
(0, types_1.log)("accessory", "Set TargetDoorState of " + this.name + ", value =" + value + " -> cmd=" + cmd);
|
|
73
73
|
this.unit.setState(cmd)
|
|
74
74
|
.then(() => next())
|
|
75
75
|
.catch(err => next(err));
|
|
76
76
|
}
|
|
77
77
|
else {
|
|
78
|
-
|
|
78
|
+
(0, types_1.log)("accessory", "Set TargetDoorState of " + this.name + " -> failed for : " + value);
|
|
79
79
|
next(new Error("TargetDoorState of " + this.name + " -> failed"));
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
getTargetDoorState(next) {
|
|
83
|
-
|
|
83
|
+
(0, types_1.log)("accessory", "Characteristic.TargetDoorState.get was called of " + this.name + " = " + this.targetState);
|
|
84
84
|
next(null, this.targetState);
|
|
85
85
|
}
|
|
86
86
|
// in response to Duotecno status messages
|
|
87
87
|
updateState() {
|
|
88
88
|
const value = this.DT2HB(this.unit.status);
|
|
89
|
-
//
|
|
89
|
+
// log("accessory", "Received updateState -> Homekit GarageDoor for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status + " / " + this.unit.value + " -> passing to HB: " + value);
|
|
90
90
|
this.me.getCharacteristic(this.homebridge.Characteristic.CurrentDoorState).updateValue(value);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { API } from "homebridge";
|
|
2
2
|
import { Unit } from "../duotecno/protocol";
|
|
3
|
-
import {
|
|
3
|
+
import { log, UnitMotorCmd, UnitState } from "../duotecno/types";
|
|
4
4
|
import { Accessory } from "./accessory";
|
|
5
5
|
|
|
6
6
|
// Johan Coppieters Jun 2020
|
|
@@ -16,8 +16,8 @@ import { Accessory } from "./accessory";
|
|
|
16
16
|
export class GarageDoor extends Accessory {
|
|
17
17
|
targetState;
|
|
18
18
|
|
|
19
|
-
constructor(
|
|
20
|
-
super(
|
|
19
|
+
constructor(homebridge: API, unit: Unit) {
|
|
20
|
+
super(homebridge, unit);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
getAccessoryServices() {
|
|
@@ -79,7 +79,7 @@ export class GarageDoor extends Accessory {
|
|
|
79
79
|
try {
|
|
80
80
|
this.unit.reqState(unit => {
|
|
81
81
|
const hb = this.DT2HB(unit.status);
|
|
82
|
-
|
|
82
|
+
log("accessory", "Get TargetDoorState of " + this.name + " = " + unit.status + " -> " + hb);
|
|
83
83
|
next(null, hb);
|
|
84
84
|
});
|
|
85
85
|
|
|
@@ -96,19 +96,19 @@ export class GarageDoor extends Accessory {
|
|
|
96
96
|
let cmd = this.HB2DT(value);
|
|
97
97
|
|
|
98
98
|
if (cmd) {
|
|
99
|
-
|
|
99
|
+
log("accessory", "Set TargetDoorState of " + this.name + ", value =" + value + " -> cmd="+cmd);
|
|
100
100
|
this.unit.setState(cmd)
|
|
101
101
|
.then(() => next())
|
|
102
102
|
.catch(err => next(err));
|
|
103
103
|
|
|
104
104
|
} else {
|
|
105
|
-
|
|
105
|
+
log("accessory", "Set TargetDoorState of " + this.name + " -> failed for : " + value);
|
|
106
106
|
next(new Error("TargetDoorState of " + this.name + " -> failed"));
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
getTargetDoorState(next) {
|
|
111
|
-
|
|
111
|
+
log("accessory", "Characteristic.TargetDoorState.get was called of " + this.name + " = " + this.targetState);
|
|
112
112
|
next(null, this.targetState);
|
|
113
113
|
}
|
|
114
114
|
|
|
@@ -116,7 +116,7 @@ export class GarageDoor extends Accessory {
|
|
|
116
116
|
// in response to Duotecno status messages
|
|
117
117
|
updateState() {
|
|
118
118
|
const value = this.DT2HB(this.unit.status);
|
|
119
|
-
//
|
|
119
|
+
// log("accessory", "Received updateState -> Homekit GarageDoor for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status + " / " + this.unit.value + " -> passing to HB: " + value);
|
|
120
120
|
this.me.getCharacteristic(this.homebridge.Characteristic.CurrentDoorState).updateValue(value);
|
|
121
121
|
}
|
|
122
122
|
|
package/accessories/lock.js
CHANGED
|
@@ -11,9 +11,10 @@ const accessory_1 = require("./accessory");
|
|
|
11
11
|
// if name contains * = permanent locked=on/unlocked=off
|
|
12
12
|
// else short press -> unlock, locked again after 1.2 sec
|
|
13
13
|
class Lock extends accessory_1.Accessory {
|
|
14
|
-
constructor(
|
|
15
|
-
super(
|
|
16
|
-
this.
|
|
14
|
+
constructor(homebridge, unit) {
|
|
15
|
+
super(homebridge, unit);
|
|
16
|
+
this.targetState = 1; // locked
|
|
17
|
+
(0, types_1.log)("accessory", "created Lock -> " + unit.getDescription());
|
|
17
18
|
// set default for Unlocked to Locked
|
|
18
19
|
if (this.unit.getType() === types_1.UnitExtendedType.kUnlocker)
|
|
19
20
|
unit.setState(1);
|
|
@@ -35,7 +36,7 @@ class Lock extends accessory_1.Accessory {
|
|
|
35
36
|
this.targetState = value;
|
|
36
37
|
// unlocker is a mood, a lock is a switch
|
|
37
38
|
const dtVal = (this.unit.getType() === types_1.UnitExtendedType.kUnlocker) ? -1 : value;
|
|
38
|
-
|
|
39
|
+
(0, types_1.log)("accessory", "HB setting target state of lock: to " + value + " of " + this.unit.getDescription() + " (duotecno: " + dtVal + ")");
|
|
39
40
|
this.unit.setState(dtVal)
|
|
40
41
|
.then(() => {
|
|
41
42
|
//bypass ip node update mechanism of Duotecno
|
|
@@ -44,7 +45,7 @@ class Lock extends accessory_1.Accessory {
|
|
|
44
45
|
if (this.unit.getType() === types_1.UnitExtendedType.kUnlocker) {
|
|
45
46
|
// always set to "locked" after sending the request.
|
|
46
47
|
this.unit.resetTimer = setTimeout(() => {
|
|
47
|
-
|
|
48
|
+
(0, types_1.log)("accessory", "Autolock for an unlocker after 2 secs of " + this.unit.getDescription());
|
|
48
49
|
this.targetState = 1;
|
|
49
50
|
this.me.getCharacteristic(this.homebridge.Characteristic.LockTargetState).updateValue(1);
|
|
50
51
|
this.unit.status = 1;
|
|
@@ -56,18 +57,18 @@ class Lock extends accessory_1.Accessory {
|
|
|
56
57
|
.catch(err => next(err));
|
|
57
58
|
}
|
|
58
59
|
getTarget(next) {
|
|
59
|
-
|
|
60
|
+
(0, types_1.log)("accessory", "HB getting target state of lock = " + this.unit.status + " of " + this.unit.getDescription());
|
|
60
61
|
next(null, this.targetState);
|
|
61
62
|
}
|
|
62
63
|
getCurrent(next) {
|
|
63
64
|
this.unit.reqState(unit => {
|
|
64
|
-
|
|
65
|
+
(0, types_1.log)("accessory", "HB getting current state of lock = " + this.unit.status + " of " + this.unit.getDescription());
|
|
65
66
|
next(null, !!this.unit.status);
|
|
66
67
|
});
|
|
67
68
|
}
|
|
68
69
|
// in response to Duotecno status messages
|
|
69
70
|
updateState() {
|
|
70
|
-
//
|
|
71
|
+
// log("accessory", "Received updateState -> Homekit Lock for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status);
|
|
71
72
|
this.me.getCharacteristic(this.homebridge.Characteristic.LockCurrentState).updateValue(this.unit.status);
|
|
72
73
|
}
|
|
73
74
|
}
|