@switchbot/homebridge-switchbot 3.5.0-beta.9 → 3.5.0
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/.vscode/settings.json +4 -1
- package/CHANGELOG.md +4 -1
- package/config.schema.json +166 -24
- package/dist/device/blindtilt.d.ts +21 -96
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +439 -817
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +27 -72
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +835 -865
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +15 -69
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +287 -653
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +15 -76
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +354 -732
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +14 -66
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +268 -576
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +18 -89
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +431 -851
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +60 -0
- package/dist/device/device.d.ts.map +1 -0
- package/dist/device/device.js +739 -0
- package/dist/device/device.js.map +1 -0
- package/dist/device/fan.d.ts +63 -0
- package/dist/device/fan.d.ts.map +1 -0
- package/dist/device/fan.js +698 -0
- package/dist/device/fan.js.map +1 -0
- package/dist/device/hub.d.ts +15 -60
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +257 -631
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +11 -66
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +266 -629
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +12 -64
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +215 -615
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +12 -70
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +336 -645
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +17 -63
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +290 -595
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +15 -64
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +211 -608
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +15 -65
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +205 -615
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +12 -69
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +202 -563
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +10 -57
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +125 -484
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +13 -63
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +233 -549
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts +11 -63
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +170 -493
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/homebridge-ui/public/index.html +22 -16
- package/dist/homebridge-ui/server.js +1 -1
- package/dist/homebridge-ui/server.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +10 -50
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +340 -468
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +8 -39
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +105 -319
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +7 -36
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +44 -285
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +7 -43
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +92 -350
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +40 -0
- package/dist/irdevice/irdevice.d.ts.map +1 -0
- package/dist/irdevice/irdevice.js +369 -0
- package/dist/irdevice/irdevice.js.map +1 -0
- package/dist/irdevice/light.d.ts +12 -45
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +118 -362
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +19 -48
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +438 -570
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +8 -40
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +91 -339
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +7 -36
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +45 -285
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +7 -36
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +47 -291
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +22 -8
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +342 -191
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +64 -17
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +16 -552
- package/dist/settings.js.map +1 -1
- package/dist/utils.d.ts +77 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +638 -1
- package/dist/utils.js.map +1 -1
- package/eslint.config.js +96 -0
- package/package.json +20 -16
- package/src/custom.d.ts +2 -1
- package/src/device/blindtilt.ts +472 -888
- package/src/device/bot.ts +893 -968
- package/src/device/ceilinglight.ts +304 -709
- package/src/device/colorbulb.ts +370 -803
- package/src/device/contact.ts +301 -611
- package/src/device/curtain.ts +460 -908
- package/src/device/device.ts +755 -0
- package/src/device/fan.ts +749 -0
- package/src/device/hub.ts +294 -664
- package/src/device/humidifier.ts +299 -696
- package/src/device/iosensor.ts +251 -644
- package/src/device/lightstrip.ts +362 -712
- package/src/device/lock.ts +328 -653
- package/src/device/meter.ts +247 -637
- package/src/device/meterplus.ts +240 -644
- package/src/device/motion.ts +230 -598
- package/src/device/plug.ts +139 -525
- package/src/device/robotvacuumcleaner.ts +258 -593
- package/src/device/waterdetector.ts +191 -522
- package/src/homebridge-ui/public/index.html +22 -16
- package/src/homebridge-ui/server.ts +1 -1
- package/src/index.ts +4 -3
- package/src/irdevice/airconditioner.ts +370 -527
- package/src/irdevice/airpurifier.ts +132 -356
- package/src/irdevice/camera.ts +58 -311
- package/src/irdevice/fan.ts +109 -379
- package/src/irdevice/irdevice.ts +382 -0
- package/src/irdevice/light.ts +157 -412
- package/src/irdevice/other.ts +507 -648
- package/src/irdevice/tv.ts +121 -375
- package/src/irdevice/vacuumcleaner.ts +59 -311
- package/src/irdevice/waterheater.ts +61 -320
- package/src/platform.ts +395 -259
- package/src/settings.ts +118 -609
- package/src/utils.ts +642 -1
- package/.github/npm-version-script.cjs +0 -81
- package/src/device/waterdetector.json +0 -11
package/dist/irdevice/other.js
CHANGED
|
@@ -1,61 +1,54 @@
|
|
|
1
|
+
/* Copyright(C) 2021-2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
|
|
2
|
+
*
|
|
3
|
+
* other.ts: @switchbot/homebridge-switchbot.
|
|
4
|
+
*/
|
|
1
5
|
import { request } from 'undici';
|
|
2
6
|
import { Devices } from '../settings.js';
|
|
7
|
+
import { irdeviceBase } from './irdevice.js';
|
|
3
8
|
/**
|
|
4
9
|
* Platform Accessory
|
|
5
10
|
* An instance of this class is created for each accessory your platform registers
|
|
6
11
|
* Each accessory may expose multiple services of different service types.
|
|
7
12
|
*/
|
|
8
|
-
export class Others {
|
|
13
|
+
export class Others extends irdeviceBase {
|
|
9
14
|
platform;
|
|
10
|
-
accessory;
|
|
11
|
-
device;
|
|
12
|
-
api;
|
|
13
|
-
log;
|
|
14
|
-
config;
|
|
15
|
-
hap;
|
|
16
15
|
// Services
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
// Characteristic Values
|
|
28
|
-
On;
|
|
29
|
-
FirmwareRevision;
|
|
16
|
+
Switch;
|
|
17
|
+
GarageDoor;
|
|
18
|
+
Door;
|
|
19
|
+
Window;
|
|
20
|
+
WindowCovering;
|
|
21
|
+
LockMechanism;
|
|
22
|
+
Faucet;
|
|
23
|
+
Fan;
|
|
24
|
+
StatefulProgrammableSwitch;
|
|
25
|
+
Outlet;
|
|
30
26
|
// Config
|
|
31
|
-
deviceLogging;
|
|
32
|
-
disablePushOn;
|
|
33
27
|
otherDeviceType;
|
|
34
|
-
disablePushOff;
|
|
35
28
|
constructor(platform, accessory, device) {
|
|
29
|
+
super(platform, accessory, device);
|
|
36
30
|
this.platform = platform;
|
|
37
|
-
this.accessory = accessory;
|
|
38
|
-
this.device = device;
|
|
39
|
-
this.api = this.platform.api;
|
|
40
|
-
this.log = this.platform.log;
|
|
41
|
-
this.config = this.platform.config;
|
|
42
|
-
this.hap = this.api.hap;
|
|
43
31
|
// default placeholders
|
|
44
|
-
this.
|
|
45
|
-
this.deviceType(device);
|
|
46
|
-
this.deviceContext();
|
|
47
|
-
this.disablePushOnChanges(device);
|
|
48
|
-
this.disablePushOffChanges(device);
|
|
49
|
-
this.deviceConfig(device);
|
|
50
|
-
// set accessory information
|
|
51
|
-
accessory
|
|
52
|
-
.getService(this.hap.Service.AccessoryInformation)
|
|
53
|
-
.setCharacteristic(this.hap.Characteristic.Manufacturer, 'SwitchBot')
|
|
54
|
-
.setCharacteristic(this.hap.Characteristic.Model, device.remoteType)
|
|
55
|
-
.setCharacteristic(this.hap.Characteristic.SerialNumber, device.deviceId)
|
|
56
|
-
.setCharacteristic(this.hap.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
|
|
32
|
+
this.getOtherConfigSettings(device);
|
|
57
33
|
// deviceType
|
|
58
34
|
if (this.otherDeviceType === 'switch') {
|
|
35
|
+
// Initialize Switch Service
|
|
36
|
+
accessory.context.Switch = accessory.context.Switch ?? {};
|
|
37
|
+
this.Switch = {
|
|
38
|
+
Name: accessory.context.Switch.Name ?? `${accessory.displayName} Switch`,
|
|
39
|
+
Service: accessory.getService(this.hap.Service.Switch) ?? accessory.addService(this.hap.Service.Switch),
|
|
40
|
+
On: accessory.context.On ?? false,
|
|
41
|
+
};
|
|
42
|
+
accessory.context.Switch = this.Switch;
|
|
43
|
+
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Switch`);
|
|
44
|
+
this.Switch.Service
|
|
45
|
+
.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
46
|
+
.getCharacteristic(this.hap.Characteristic.On)
|
|
47
|
+
.onGet(() => {
|
|
48
|
+
return this.Switch.On;
|
|
49
|
+
})
|
|
50
|
+
.onSet(this.OnSet.bind(this));
|
|
51
|
+
// Remove other services
|
|
59
52
|
this.removeFanService(accessory);
|
|
60
53
|
this.removeLockService(accessory);
|
|
61
54
|
this.removeDoorService(accessory);
|
|
@@ -65,18 +58,26 @@ export class Others {
|
|
|
65
58
|
this.removeGarageDoorService(accessory);
|
|
66
59
|
this.removeWindowCoveringService(accessory);
|
|
67
60
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
68
|
-
// Add switchService
|
|
69
|
-
const switchService = `${accessory.displayName} Switch`;
|
|
70
|
-
(this.switchService = accessory.getService(this.hap.Service.Switch)
|
|
71
|
-
|| accessory.addService(this.hap.Service.Switch)), switchService;
|
|
72
|
-
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Switch`);
|
|
73
|
-
this.switchService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
74
|
-
if (!this.switchService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
75
|
-
this.switchService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
76
|
-
}
|
|
77
|
-
this.switchService.getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
78
61
|
}
|
|
79
62
|
else if (this.otherDeviceType === 'garagedoor') {
|
|
63
|
+
// Initialize Garage Door Service
|
|
64
|
+
accessory.context.GarageDoor = accessory.context.GarageDoor ?? {};
|
|
65
|
+
this.GarageDoor = {
|
|
66
|
+
Name: accessory.context.GarageDoor.Name ?? `${accessory.displayName} Garage Door`,
|
|
67
|
+
Service: accessory.getService(this.hap.Service.GarageDoorOpener) ?? accessory.addService(this.hap.Service.GarageDoorOpener),
|
|
68
|
+
On: accessory.context.On ?? false,
|
|
69
|
+
};
|
|
70
|
+
accessory.context.GarageDoor = this.GarageDoor;
|
|
71
|
+
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Garage Door Opener`);
|
|
72
|
+
this.GarageDoor.Service
|
|
73
|
+
.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
74
|
+
.setCharacteristic(this.hap.Characteristic.ObstructionDetected, false)
|
|
75
|
+
.getCharacteristic(this.hap.Characteristic.TargetDoorState)
|
|
76
|
+
.onGet(() => {
|
|
77
|
+
return this.GarageDoor.On;
|
|
78
|
+
})
|
|
79
|
+
.onSet(this.OnSet.bind(this));
|
|
80
|
+
// Remove other services
|
|
80
81
|
this.removeFanService(accessory);
|
|
81
82
|
this.removeLockService(accessory);
|
|
82
83
|
this.removeDoorService(accessory);
|
|
@@ -86,109 +87,129 @@ export class Others {
|
|
|
86
87
|
this.removeWindowService(accessory);
|
|
87
88
|
this.removeWindowCoveringService(accessory);
|
|
88
89
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
89
|
-
// Add garageDoorService
|
|
90
|
-
const garageDoorService = `${accessory.displayName} Garage Door Opener`;
|
|
91
|
-
(this.garageDoorService = accessory.getService(this.hap.Service.GarageDoorOpener)
|
|
92
|
-
|| accessory.addService(this.hap.Service.GarageDoorOpener)), garageDoorService;
|
|
93
|
-
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Garage Door Opener`);
|
|
94
|
-
this.garageDoorService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
95
|
-
if (!this.garageDoorService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
96
|
-
this.garageDoorService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
97
|
-
}
|
|
98
|
-
this.garageDoorService.getCharacteristic(this.hap.Characteristic.TargetDoorState).onSet(this.OnSet.bind(this));
|
|
99
|
-
this.garageDoorService.setCharacteristic(this.hap.Characteristic.ObstructionDetected, false);
|
|
100
90
|
}
|
|
101
91
|
else if (this.otherDeviceType === 'door') {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
this.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
this.
|
|
110
|
-
this.removeStatefulProgrammableSwitchService(accessory);
|
|
111
|
-
// Add doorService
|
|
112
|
-
const doorService = `${accessory.displayName} Door`;
|
|
113
|
-
(this.doorService = accessory.getService(this.hap.Service.Door)
|
|
114
|
-
|| accessory.addService(this.hap.Service.Door)), doorService;
|
|
92
|
+
// Initialize Door Service
|
|
93
|
+
accessory.context.Door = accessory.context.Door ?? {};
|
|
94
|
+
this.Door = {
|
|
95
|
+
Name: accessory.context.Door.Name ?? `${accessory.displayName} Door`,
|
|
96
|
+
Service: accessory.getService(this.hap.Service.Door) ?? accessory.addService(this.hap.Service.Door),
|
|
97
|
+
On: accessory.context.On ?? false,
|
|
98
|
+
};
|
|
99
|
+
accessory.context.Door = this.Door;
|
|
115
100
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Door`);
|
|
116
|
-
this.
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
this.doorService
|
|
101
|
+
this.Door.Service
|
|
102
|
+
.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
103
|
+
.setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
121
104
|
.getCharacteristic(this.hap.Characteristic.TargetPosition)
|
|
122
105
|
.setProps({
|
|
123
106
|
validValues: [0, 100],
|
|
124
107
|
minValue: 0,
|
|
125
108
|
maxValue: 100,
|
|
126
109
|
minStep: 100,
|
|
110
|
+
})
|
|
111
|
+
.onGet(() => {
|
|
112
|
+
return this.GarageDoor.On;
|
|
127
113
|
})
|
|
128
114
|
.onSet(this.OnSet.bind(this));
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
else if (this.otherDeviceType === 'window') {
|
|
115
|
+
// Remove other services
|
|
132
116
|
this.removeFanService(accessory);
|
|
133
117
|
this.removeLockService(accessory);
|
|
134
|
-
this.removeDoorService(accessory);
|
|
135
118
|
this.removeOutletService(accessory);
|
|
136
119
|
this.removeFaucetService(accessory);
|
|
137
120
|
this.removeSwitchService(accessory);
|
|
121
|
+
this.removeWindowService(accessory);
|
|
138
122
|
this.removeGarageDoorService(accessory);
|
|
139
123
|
this.removeWindowCoveringService(accessory);
|
|
140
124
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
125
|
+
}
|
|
126
|
+
else if (this.otherDeviceType === 'window') {
|
|
127
|
+
// Initialize Window Service
|
|
128
|
+
accessory.context.Window = accessory.context.Window ?? {};
|
|
129
|
+
this.Window = {
|
|
130
|
+
Name: accessory.context.Window.Name ?? `${accessory.displayName} Window`,
|
|
131
|
+
Service: accessory.getService(this.hap.Service.Window) ?? accessory.addService(this.hap.Service.Window),
|
|
132
|
+
On: accessory.context.On ?? false,
|
|
133
|
+
};
|
|
134
|
+
accessory.context.Window = this.Window;
|
|
145
135
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Window`);
|
|
146
|
-
this.
|
|
147
|
-
|
|
148
|
-
this.windowService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
149
|
-
}
|
|
150
|
-
this.windowService
|
|
136
|
+
this.Window.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
137
|
+
.setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
151
138
|
.getCharacteristic(this.hap.Characteristic.TargetPosition)
|
|
152
139
|
.setProps({
|
|
153
140
|
validValues: [0, 100],
|
|
154
141
|
minValue: 0,
|
|
155
142
|
maxValue: 100,
|
|
156
143
|
minStep: 100,
|
|
144
|
+
})
|
|
145
|
+
.onGet(() => {
|
|
146
|
+
return this.GarageDoor.On;
|
|
157
147
|
})
|
|
158
148
|
.onSet(this.OnSet.bind(this));
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
else if (this.otherDeviceType === 'windowcovering') {
|
|
149
|
+
// Remove other services
|
|
162
150
|
this.removeFanService(accessory);
|
|
163
151
|
this.removeLockService(accessory);
|
|
164
152
|
this.removeDoorService(accessory);
|
|
165
153
|
this.removeOutletService(accessory);
|
|
166
154
|
this.removeFaucetService(accessory);
|
|
167
155
|
this.removeSwitchService(accessory);
|
|
168
|
-
this.removeWindowService(accessory);
|
|
169
156
|
this.removeGarageDoorService(accessory);
|
|
157
|
+
this.removeWindowCoveringService(accessory);
|
|
170
158
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
159
|
+
}
|
|
160
|
+
else if (this.otherDeviceType === 'windowcovering') {
|
|
161
|
+
// Initialize WindowCovering Service
|
|
162
|
+
accessory.context.WindowCovering = accessory.context.WindowCovering ?? {};
|
|
163
|
+
this.WindowCovering = {
|
|
164
|
+
Name: accessory.context.WindowCovering.Name ?? `${accessory.displayName} Window Covering`,
|
|
165
|
+
Service: accessory.getService(this.hap.Service.WindowCovering) ?? accessory.addService(this.hap.Service.WindowCovering),
|
|
166
|
+
On: accessory.context.On ?? false,
|
|
167
|
+
};
|
|
168
|
+
accessory.context.WindowCovering = this.WindowCovering;
|
|
175
169
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Window Covering`);
|
|
176
|
-
this.
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
this.windowCoveringService
|
|
170
|
+
this.WindowCovering.Service
|
|
171
|
+
.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
172
|
+
.setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
181
173
|
.getCharacteristic(this.hap.Characteristic.TargetPosition)
|
|
182
174
|
.setProps({
|
|
183
175
|
validValues: [0, 100],
|
|
184
176
|
minValue: 0,
|
|
185
177
|
maxValue: 100,
|
|
186
178
|
minStep: 100,
|
|
179
|
+
})
|
|
180
|
+
.onGet(() => {
|
|
181
|
+
return this.WindowCovering.On;
|
|
187
182
|
})
|
|
188
183
|
.onSet(this.OnSet.bind(this));
|
|
189
|
-
|
|
184
|
+
// Remove other services
|
|
185
|
+
this.removeFanService(accessory);
|
|
186
|
+
this.removeLockService(accessory);
|
|
187
|
+
this.removeDoorService(accessory);
|
|
188
|
+
this.removeOutletService(accessory);
|
|
189
|
+
this.removeFaucetService(accessory);
|
|
190
|
+
this.removeSwitchService(accessory);
|
|
191
|
+
this.removeWindowService(accessory);
|
|
192
|
+
this.removeGarageDoorService(accessory);
|
|
193
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
190
194
|
}
|
|
191
195
|
else if (this.otherDeviceType === 'lock') {
|
|
196
|
+
// Initialize LockMechanism Service
|
|
197
|
+
accessory.context.LockMechanism = accessory.context.LockMechanism ?? {};
|
|
198
|
+
this.LockMechanism = {
|
|
199
|
+
Name: accessory.context.LockMechanism.Name ?? `${accessory.displayName} Lock`,
|
|
200
|
+
Service: accessory.getService(this.hap.Service.LockMechanism) ?? accessory.addService(this.hap.Service.LockMechanism),
|
|
201
|
+
On: accessory.context.On ?? false,
|
|
202
|
+
};
|
|
203
|
+
accessory.context.LockMechanism = this.LockMechanism;
|
|
204
|
+
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Lock`);
|
|
205
|
+
this.LockMechanism.Service
|
|
206
|
+
.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
207
|
+
.getCharacteristic(this.hap.Characteristic.LockTargetState)
|
|
208
|
+
.onGet(() => {
|
|
209
|
+
return this.LockMechanism.On;
|
|
210
|
+
})
|
|
211
|
+
.onSet(this.OnSet.bind(this));
|
|
212
|
+
// Remove other services
|
|
192
213
|
this.removeFanService(accessory);
|
|
193
214
|
this.removeDoorService(accessory);
|
|
194
215
|
this.removeOutletService(accessory);
|
|
@@ -198,18 +219,25 @@ export class Others {
|
|
|
198
219
|
this.removeGarageDoorService(accessory);
|
|
199
220
|
this.removeWindowCoveringService(accessory);
|
|
200
221
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
201
|
-
// Add lockService
|
|
202
|
-
const lockService = `${accessory.displayName} Lock`;
|
|
203
|
-
(this.lockService = accessory.getService(this.hap.Service.LockMechanism)
|
|
204
|
-
|| accessory.addService(this.hap.Service.LockMechanism)), lockService;
|
|
205
|
-
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Lock`);
|
|
206
|
-
this.lockService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
207
|
-
if (!this.lockService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
208
|
-
this.lockService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
209
|
-
}
|
|
210
|
-
this.lockService.getCharacteristic(this.hap.Characteristic.LockTargetState).onSet(this.OnSet.bind(this));
|
|
211
222
|
}
|
|
212
223
|
else if (this.otherDeviceType === 'faucet') {
|
|
224
|
+
// Initialize Faucet Service
|
|
225
|
+
accessory.context.Faucet = accessory.context.Faucet ?? {};
|
|
226
|
+
this.Faucet = {
|
|
227
|
+
Name: accessory.context.Faucet.Name ?? `${accessory.displayName} Faucet`,
|
|
228
|
+
Service: accessory.getService(this.hap.Service.Faucet) ?? accessory.addService(this.hap.Service.Faucet),
|
|
229
|
+
On: accessory.context.On ?? false,
|
|
230
|
+
};
|
|
231
|
+
accessory.context.Faucet = this.Faucet;
|
|
232
|
+
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Faucet`);
|
|
233
|
+
this.Faucet.Service
|
|
234
|
+
.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
235
|
+
.getCharacteristic(this.hap.Characteristic.Active)
|
|
236
|
+
.onGet(() => {
|
|
237
|
+
return this.Faucet.On;
|
|
238
|
+
})
|
|
239
|
+
.onSet(this.OnSet.bind(this));
|
|
240
|
+
// Remove other services
|
|
213
241
|
this.removeFanService(accessory);
|
|
214
242
|
this.removeLockService(accessory);
|
|
215
243
|
this.removeDoorService(accessory);
|
|
@@ -219,18 +247,25 @@ export class Others {
|
|
|
219
247
|
this.removeGarageDoorService(accessory);
|
|
220
248
|
this.removeWindowCoveringService(accessory);
|
|
221
249
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
222
|
-
// Add faucetService
|
|
223
|
-
const faucetService = `${accessory.displayName} Faucet`;
|
|
224
|
-
(this.faucetService = accessory.getService(this.hap.Service.Faucet)
|
|
225
|
-
|| accessory.addService(this.hap.Service.Faucet)), faucetService;
|
|
226
|
-
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Faucet`);
|
|
227
|
-
this.faucetService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
228
|
-
if (!this.faucetService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
229
|
-
this.faucetService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
230
|
-
}
|
|
231
|
-
this.faucetService.getCharacteristic(this.hap.Characteristic.Active).onSet(this.OnSet.bind(this));
|
|
232
250
|
}
|
|
233
251
|
else if (this.otherDeviceType === 'fan') {
|
|
252
|
+
// Initialize Fan Service
|
|
253
|
+
accessory.context.Fan = accessory.context.Fan ?? {};
|
|
254
|
+
this.Fan = {
|
|
255
|
+
Name: accessory.context.Fan.Name ?? `${accessory.displayName} Fan`,
|
|
256
|
+
Service: accessory.getService(this.hap.Service.Fanv2) ?? accessory.addService(this.hap.Service.Fanv2),
|
|
257
|
+
On: accessory.context.On ?? false,
|
|
258
|
+
};
|
|
259
|
+
accessory.context.Fan = this.Fan;
|
|
260
|
+
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Fan`);
|
|
261
|
+
this.Fan.Service
|
|
262
|
+
.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
263
|
+
.getCharacteristic(this.hap.Characteristic.On)
|
|
264
|
+
.onGet(() => {
|
|
265
|
+
return this.Fan.On;
|
|
266
|
+
})
|
|
267
|
+
.onSet(this.OnSet.bind(this));
|
|
268
|
+
// Remove other services
|
|
234
269
|
this.removeLockService(accessory);
|
|
235
270
|
this.removeDoorService(accessory);
|
|
236
271
|
this.removeFaucetService(accessory);
|
|
@@ -240,18 +275,26 @@ export class Others {
|
|
|
240
275
|
this.removeGarageDoorService(accessory);
|
|
241
276
|
this.removeWindowCoveringService(accessory);
|
|
242
277
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
243
|
-
// Add fanService
|
|
244
|
-
const fanService = `${accessory.displayName} Fan`;
|
|
245
|
-
(this.fanService = accessory.getService(this.hap.Service.Fan)
|
|
246
|
-
|| accessory.addService(this.hap.Service.Fan)), fanService;
|
|
247
|
-
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Fan`);
|
|
248
|
-
this.fanService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
249
|
-
if (!this.fanService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
250
|
-
this.fanService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
251
|
-
}
|
|
252
|
-
this.fanService.getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
253
278
|
}
|
|
254
279
|
else if (this.otherDeviceType === 'stateful') {
|
|
280
|
+
// Initialize StatefulProgrammableSwitch Service
|
|
281
|
+
accessory.context.StatefulProgrammableSwitch = accessory.context.StatefulProgrammableSwitch ?? {};
|
|
282
|
+
this.StatefulProgrammableSwitch = {
|
|
283
|
+
Name: accessory.context.StatefulProgrammableSwitch.Name ?? `${accessory.displayName} Stateful Programmable Switch`,
|
|
284
|
+
Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch)
|
|
285
|
+
?? accessory.addService(this.hap.Service.StatefulProgrammableSwitch),
|
|
286
|
+
On: accessory.context.On ?? false,
|
|
287
|
+
};
|
|
288
|
+
accessory.context.StatefulProgrammableSwitch = this.StatefulProgrammableSwitch;
|
|
289
|
+
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Stateful Programmable Switch`);
|
|
290
|
+
this.StatefulProgrammableSwitch.Service
|
|
291
|
+
.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
292
|
+
.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState)
|
|
293
|
+
.onGet(() => {
|
|
294
|
+
return this.StatefulProgrammableSwitch.On;
|
|
295
|
+
})
|
|
296
|
+
.onSet(this.OnSet.bind(this));
|
|
297
|
+
// Remove other services
|
|
255
298
|
this.removeFanService(accessory);
|
|
256
299
|
this.removeLockService(accessory);
|
|
257
300
|
this.removeDoorService(accessory);
|
|
@@ -261,20 +304,25 @@ export class Others {
|
|
|
261
304
|
this.removeWindowService(accessory);
|
|
262
305
|
this.removeGarageDoorService(accessory);
|
|
263
306
|
this.removeWindowCoveringService(accessory);
|
|
264
|
-
// Add statefulProgrammableSwitchService
|
|
265
|
-
const statefulProgrammableSwitchService = `${accessory.displayName} Stateful Programmable Switch`;
|
|
266
|
-
(this.statefulProgrammableSwitchService = accessory.getService(this.hap.Service.StatefulProgrammableSwitch)
|
|
267
|
-
|| accessory.addService(this.hap.Service.StatefulProgrammableSwitch)), statefulProgrammableSwitchService;
|
|
268
|
-
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Stateful Programmable Switch`);
|
|
269
|
-
this.statefulProgrammableSwitchService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
270
|
-
if (!this.statefulProgrammableSwitchService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
271
|
-
this.statefulProgrammableSwitchService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
272
|
-
}
|
|
273
|
-
this.statefulProgrammableSwitchService
|
|
274
|
-
.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState)
|
|
275
|
-
.onSet(this.OnSet.bind(this));
|
|
276
307
|
}
|
|
277
308
|
else {
|
|
309
|
+
// Initialize Outlet Service
|
|
310
|
+
accessory.context.Outlet = accessory.context.Outlet ?? {};
|
|
311
|
+
this.Outlet = {
|
|
312
|
+
Name: accessory.context.Outlet.Name ?? `${accessory.displayName} Outlet`,
|
|
313
|
+
Service: accessory.getService(this.hap.Service.Outlet) ?? accessory.addService(this.hap.Service.Outlet),
|
|
314
|
+
On: accessory.context.On ?? false,
|
|
315
|
+
};
|
|
316
|
+
accessory.context.Outlet = this.Outlet;
|
|
317
|
+
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Outlet`);
|
|
318
|
+
this.Outlet.Service
|
|
319
|
+
.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
320
|
+
.getCharacteristic(this.hap.Characteristic.On)
|
|
321
|
+
.onGet(() => {
|
|
322
|
+
return this.Outlet.On;
|
|
323
|
+
})
|
|
324
|
+
.onSet(this.OnSet.bind(this));
|
|
325
|
+
// Remove other services
|
|
278
326
|
this.removeFanService(accessory);
|
|
279
327
|
this.removeLockService(accessory);
|
|
280
328
|
this.removeDoorService(accessory);
|
|
@@ -284,79 +332,94 @@ export class Others {
|
|
|
284
332
|
this.removeGarageDoorService(accessory);
|
|
285
333
|
this.removeWindowCoveringService(accessory);
|
|
286
334
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
287
|
-
// Add outletService
|
|
288
|
-
const outletService = `${accessory.displayName} Outlet`;
|
|
289
|
-
(this.outletService = accessory.getService(this.hap.Service.Outlet)
|
|
290
|
-
|| accessory.addService(this.hap.Service.Outlet)), outletService;
|
|
291
|
-
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Outlet`);
|
|
292
|
-
this.outletService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
293
|
-
if (!this.outletService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
294
|
-
this.outletService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
295
|
-
}
|
|
296
|
-
this.outletService.getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
297
335
|
}
|
|
298
336
|
}
|
|
299
337
|
/**
|
|
300
338
|
* Handle requests to set the "On" characteristic
|
|
301
339
|
*/
|
|
302
340
|
async OnSet(value) {
|
|
341
|
+
let On;
|
|
303
342
|
if (this.otherDeviceType === 'garagedoor') {
|
|
304
343
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set TargetDoorState: ${value}`);
|
|
305
344
|
if (value === this.hap.Characteristic.TargetDoorState.CLOSED) {
|
|
306
|
-
this.On = false;
|
|
345
|
+
this.GarageDoor.On = false;
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
this.GarageDoor.On = true;
|
|
349
|
+
}
|
|
350
|
+
On = this.GarageDoor.On;
|
|
351
|
+
}
|
|
352
|
+
else if (this.otherDeviceType === 'door') {
|
|
353
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set TargetPosition: ${value}`);
|
|
354
|
+
if (value === 0) {
|
|
355
|
+
this.Door.On = false;
|
|
307
356
|
}
|
|
308
357
|
else {
|
|
309
|
-
this.On = true;
|
|
358
|
+
this.Door.On = true;
|
|
310
359
|
}
|
|
360
|
+
On = this.Door.On;
|
|
311
361
|
}
|
|
312
|
-
else if (this.otherDeviceType === '
|
|
313
|
-
this.otherDeviceType === 'window' ||
|
|
314
|
-
this.otherDeviceType === 'windowcovering') {
|
|
362
|
+
else if (this.otherDeviceType === 'window') {
|
|
315
363
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set TargetPosition: ${value}`);
|
|
316
364
|
if (value === 0) {
|
|
317
|
-
this.On = false;
|
|
365
|
+
this.Window.On = false;
|
|
318
366
|
}
|
|
319
367
|
else {
|
|
320
|
-
this.On = true;
|
|
368
|
+
this.Window.On = true;
|
|
321
369
|
}
|
|
370
|
+
On = this.Window.On;
|
|
371
|
+
}
|
|
372
|
+
else if (this.otherDeviceType === 'windowcovering') {
|
|
373
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set TargetPosition: ${value}`);
|
|
374
|
+
if (value === 0) {
|
|
375
|
+
this.WindowCovering.On = false;
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
this.WindowCovering.On = true;
|
|
379
|
+
}
|
|
380
|
+
On = this.WindowCovering.On;
|
|
322
381
|
}
|
|
323
382
|
else if (this.otherDeviceType === 'lock') {
|
|
324
383
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set LockTargetState: ${value}`);
|
|
325
384
|
if (value === this.hap.Characteristic.LockTargetState.SECURED) {
|
|
326
|
-
this.On = false;
|
|
385
|
+
this.LockMechanism.On = false;
|
|
327
386
|
}
|
|
328
387
|
else {
|
|
329
|
-
this.On = true;
|
|
388
|
+
this.LockMechanism.On = true;
|
|
330
389
|
}
|
|
390
|
+
On = this.LockMechanism.On;
|
|
331
391
|
}
|
|
332
392
|
else if (this.otherDeviceType === 'faucet') {
|
|
333
393
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Active: ${value}`);
|
|
334
394
|
if (value === this.hap.Characteristic.Active.INACTIVE) {
|
|
335
|
-
this.On = false;
|
|
395
|
+
this.Faucet.On = false;
|
|
336
396
|
}
|
|
337
397
|
else {
|
|
338
|
-
this.On = true;
|
|
398
|
+
this.Faucet.On = true;
|
|
339
399
|
}
|
|
400
|
+
On = this.Faucet.On;
|
|
340
401
|
}
|
|
341
402
|
else if (this.otherDeviceType === 'stateful') {
|
|
342
403
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set ProgrammableSwitchOutputState: ${value}`);
|
|
343
404
|
if (value === 0) {
|
|
344
|
-
this.On = false;
|
|
405
|
+
this.StatefulProgrammableSwitch.On = false;
|
|
345
406
|
}
|
|
346
407
|
else {
|
|
347
|
-
this.On = true;
|
|
408
|
+
this.StatefulProgrammableSwitch.On = true;
|
|
348
409
|
}
|
|
410
|
+
On = this.StatefulProgrammableSwitch.On;
|
|
349
411
|
}
|
|
350
412
|
else {
|
|
351
413
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set On: ${value}`);
|
|
352
|
-
this.On = value;
|
|
414
|
+
this.Outlet.On = value;
|
|
415
|
+
On = this.Outlet.On ? true : false;
|
|
353
416
|
}
|
|
354
417
|
//pushChanges
|
|
355
|
-
if (
|
|
356
|
-
await this.pushOnChanges();
|
|
418
|
+
if (On === true) {
|
|
419
|
+
await this.pushOnChanges(On);
|
|
357
420
|
}
|
|
358
421
|
else {
|
|
359
|
-
await this.pushOffChanges();
|
|
422
|
+
await this.pushOffChanges(On);
|
|
360
423
|
}
|
|
361
424
|
}
|
|
362
425
|
/**
|
|
@@ -369,11 +432,11 @@ export class Others {
|
|
|
369
432
|
* Other - "command" "channelAdd" "default" = next channel
|
|
370
433
|
* Other - "command" "channelSub" "default" = previous channel
|
|
371
434
|
*/
|
|
372
|
-
async pushOnChanges() {
|
|
373
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOnChanges On: ${
|
|
374
|
-
` disablePushOn: ${this.disablePushOn}, customize: ${this.device.customize}, customOn: ${this.device.customOn}`);
|
|
435
|
+
async pushOnChanges(On) {
|
|
436
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOnChanges On: ${On},`
|
|
437
|
+
+ ` disablePushOn: ${this.disablePushOn}, customize: ${this.device.customize}, customOn: ${this.device.customOn}`);
|
|
375
438
|
if (this.device.customize) {
|
|
376
|
-
if (
|
|
439
|
+
if (On === true && !this.disablePushOn) {
|
|
377
440
|
const commandType = await this.commandType();
|
|
378
441
|
const command = await this.commandOn();
|
|
379
442
|
const bodyChange = JSON.stringify({
|
|
@@ -388,11 +451,11 @@ export class Others {
|
|
|
388
451
|
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} On Command not set`);
|
|
389
452
|
}
|
|
390
453
|
}
|
|
391
|
-
async pushOffChanges() {
|
|
392
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOffChanges On: ${
|
|
393
|
-
` disablePushOff: ${this.disablePushOff}, customize: ${this.device.customize}, customOff: ${this.device.customOff}`);
|
|
454
|
+
async pushOffChanges(On) {
|
|
455
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOffChanges On: ${On},`
|
|
456
|
+
+ ` disablePushOff: ${this.disablePushOff}, customize: ${this.device.customize}, customOff: ${this.device.customOff}`);
|
|
394
457
|
if (this.device.customize) {
|
|
395
|
-
if (
|
|
458
|
+
if (On === false && !this.disablePushOff) {
|
|
396
459
|
const commandType = await this.commandType();
|
|
397
460
|
const command = await this.commandOff();
|
|
398
461
|
const bodyChange = JSON.stringify({
|
|
@@ -422,8 +485,10 @@ export class Others {
|
|
|
422
485
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
423
486
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
424
487
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
425
|
-
this.
|
|
488
|
+
this.debugSuccessLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
426
489
|
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
490
|
+
this.successLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
491
|
+
+ ` request to SwitchBot API, body: ${JSON.stringify(JSON.parse(bodyChange))} sent successfully`);
|
|
427
492
|
this.updateHomeKitCharacteristics();
|
|
428
493
|
}
|
|
429
494
|
else {
|
|
@@ -433,425 +498,336 @@ export class Others {
|
|
|
433
498
|
}
|
|
434
499
|
catch (e) {
|
|
435
500
|
this.apiError(e);
|
|
436
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}`
|
|
437
|
-
` Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
501
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}`
|
|
502
|
+
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
438
503
|
}
|
|
439
504
|
}
|
|
440
505
|
else {
|
|
441
|
-
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
442
|
-
` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
506
|
+
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
507
|
+
+ ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
443
508
|
}
|
|
444
509
|
}
|
|
445
510
|
async updateHomeKitCharacteristics() {
|
|
446
511
|
if (this.otherDeviceType === 'garagedoor') {
|
|
447
|
-
if (this.On === undefined) {
|
|
448
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
512
|
+
if (this.GarageDoor.On === undefined) {
|
|
513
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.GarageDoor.On}`);
|
|
449
514
|
}
|
|
450
515
|
else {
|
|
451
|
-
if (this.On) {
|
|
452
|
-
this.
|
|
453
|
-
this.
|
|
454
|
-
this.debugLog(`${this.device.remoteType}:
|
|
516
|
+
if (this.GarageDoor.On) {
|
|
517
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, this.hap.Characteristic.TargetDoorState.OPEN);
|
|
518
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, this.hap.Characteristic.CurrentDoorState.OPEN);
|
|
519
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
520
|
+
+ ` TargetDoorState: Open, CurrentDoorState: Open (${this.GarageDoor.On})`);
|
|
455
521
|
}
|
|
456
522
|
else {
|
|
457
|
-
this.
|
|
458
|
-
this.
|
|
459
|
-
this.debugLog(`${this.device.remoteType}:
|
|
523
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, this.hap.Characteristic.TargetDoorState.CLOSED);
|
|
524
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, this.hap.Characteristic.CurrentDoorState.CLOSED);
|
|
525
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
526
|
+
+ ` TargetDoorState: Closed, CurrentDoorState: Closed (${this.GarageDoor.On})`);
|
|
460
527
|
}
|
|
461
528
|
}
|
|
462
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Garage Door On: ${this.On}`);
|
|
529
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Garage Door On: ${this.GarageDoor.On}`);
|
|
463
530
|
}
|
|
464
531
|
else if (this.otherDeviceType === 'door') {
|
|
465
|
-
if (this.On === undefined) {
|
|
466
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
532
|
+
if (this.Door.On === undefined) {
|
|
533
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.Door.On}`);
|
|
467
534
|
}
|
|
468
535
|
else {
|
|
469
|
-
if (this.On) {
|
|
470
|
-
this.
|
|
471
|
-
this.
|
|
472
|
-
this.
|
|
473
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic
|
|
536
|
+
if (this.Door.On) {
|
|
537
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
|
|
538
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
|
|
539
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
540
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
541
|
+
+ ` TargetPosition: 100, CurrentPosition: 100 (${this.Door.On})`);
|
|
474
542
|
}
|
|
475
543
|
else {
|
|
476
|
-
this.
|
|
477
|
-
this.
|
|
478
|
-
this.
|
|
479
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic
|
|
544
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
|
|
545
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
|
|
546
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
547
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
548
|
+
+ ` TargetPosition: 0, CurrentPosition: 0 (${this.Door.On})`);
|
|
480
549
|
}
|
|
481
550
|
}
|
|
482
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Door On: ${this.On}`);
|
|
551
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Door On: ${this.Door.On}`);
|
|
483
552
|
}
|
|
484
553
|
else if (this.otherDeviceType === 'window') {
|
|
485
|
-
if (this.On === undefined) {
|
|
486
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
554
|
+
if (this.Window.On === undefined) {
|
|
555
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.Window.On}`);
|
|
487
556
|
}
|
|
488
557
|
else {
|
|
489
|
-
if (this.On) {
|
|
490
|
-
this.
|
|
491
|
-
this.
|
|
492
|
-
this.
|
|
493
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic
|
|
558
|
+
if (this.Window.On) {
|
|
559
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
|
|
560
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
|
|
561
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
562
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
563
|
+
+ ` TargetPosition: 100, CurrentPosition: 100 (${this.Window.On})`);
|
|
494
564
|
}
|
|
495
565
|
else {
|
|
496
|
-
this.
|
|
497
|
-
this.
|
|
498
|
-
this.
|
|
499
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic
|
|
566
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
|
|
567
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
|
|
568
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
569
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
570
|
+
+ ` TargetPosition: 0, CurrentPosition: 0 (${this.Window.On})`);
|
|
500
571
|
}
|
|
501
572
|
}
|
|
502
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Window On: ${this.On}`);
|
|
573
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Window On: ${this.Window.On}`);
|
|
503
574
|
}
|
|
504
575
|
else if (this.otherDeviceType === 'windowcovering') {
|
|
505
|
-
if (this.On === undefined) {
|
|
506
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
576
|
+
if (this.WindowCovering.On === undefined) {
|
|
577
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.WindowCovering.On}`);
|
|
507
578
|
}
|
|
508
579
|
else {
|
|
509
|
-
if (this.On) {
|
|
510
|
-
this.
|
|
511
|
-
this.
|
|
512
|
-
this.
|
|
513
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic
|
|
580
|
+
if (this.WindowCovering.On) {
|
|
581
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
|
|
582
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
|
|
583
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
584
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
585
|
+
+ ` TargetPosition: 100, CurrentPosition: 100 (${this.WindowCovering.On})`);
|
|
514
586
|
}
|
|
515
587
|
else {
|
|
516
|
-
this.
|
|
517
|
-
this.
|
|
518
|
-
this.
|
|
519
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic
|
|
588
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
|
|
589
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
|
|
590
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
591
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
592
|
+
+ ` TargetPosition: 0, CurrentPosition: 0 (${this.WindowCovering.On})`);
|
|
520
593
|
}
|
|
521
594
|
}
|
|
522
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Window Covering On: ${this.On}`);
|
|
595
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Window Covering On: ${this.WindowCovering.On}`);
|
|
523
596
|
}
|
|
524
597
|
else if (this.otherDeviceType === 'lock') {
|
|
525
|
-
if (this.On === undefined) {
|
|
526
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
598
|
+
if (this.LockMechanism?.On === undefined) {
|
|
599
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.LockMechanism?.On}`);
|
|
527
600
|
}
|
|
528
601
|
else {
|
|
529
|
-
if (this.On) {
|
|
530
|
-
this.
|
|
531
|
-
this.
|
|
532
|
-
this.debugLog(`${this.device.remoteType}: `
|
|
533
|
-
|
|
602
|
+
if (this.LockMechanism.On) {
|
|
603
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.hap.Characteristic.LockTargetState.UNSECURED);
|
|
604
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.hap.Characteristic.LockCurrentState.UNSECURED);
|
|
605
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
606
|
+
+ ` LockTargetState: UNSECURED, LockCurrentState: UNSECURE (${this.LockMechanism.On})`);
|
|
534
607
|
}
|
|
535
608
|
else {
|
|
536
|
-
this.
|
|
537
|
-
this.
|
|
538
|
-
this.debugLog(`${this.device.remoteType}:
|
|
609
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.hap.Characteristic.LockTargetState.SECURED);
|
|
610
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.hap.Characteristic.LockCurrentState.SECURED);
|
|
611
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
612
|
+
+ ` LockTargetState: SECURED, LockCurrentState: SECURED (${this.LockMechanism.On})`);
|
|
539
613
|
}
|
|
540
614
|
}
|
|
541
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Lock On: ${this.On}`);
|
|
615
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Lock On: ${this.LockMechanism?.On}`);
|
|
542
616
|
}
|
|
543
617
|
else if (this.otherDeviceType === 'faucet') {
|
|
544
|
-
if (this.On === undefined) {
|
|
545
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
618
|
+
if (this.Faucet.On === undefined) {
|
|
619
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.Faucet.On}`);
|
|
546
620
|
}
|
|
547
621
|
else {
|
|
548
|
-
if (this.On) {
|
|
549
|
-
this.
|
|
550
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.On}`);
|
|
622
|
+
if (this.Faucet.On) {
|
|
623
|
+
this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.ACTIVE);
|
|
624
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Faucet.On}`);
|
|
551
625
|
}
|
|
552
626
|
else {
|
|
553
|
-
this.
|
|
554
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.On}`);
|
|
627
|
+
this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.INACTIVE);
|
|
628
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Faucet.On}`);
|
|
555
629
|
}
|
|
556
630
|
}
|
|
557
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Faucet On: ${this.On}`);
|
|
631
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Faucet On: ${this.Faucet.On}`);
|
|
558
632
|
}
|
|
559
633
|
else if (this.otherDeviceType === 'fan') {
|
|
560
|
-
if (this.On === undefined) {
|
|
561
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
634
|
+
if (this.Fan.On === undefined) {
|
|
635
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.Fan.On}`);
|
|
562
636
|
}
|
|
563
637
|
else {
|
|
564
|
-
if (this.On) {
|
|
565
|
-
this.
|
|
566
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
638
|
+
if (this.Fan.On) {
|
|
639
|
+
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.On, this.Fan.On);
|
|
640
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.Fan.On}`);
|
|
567
641
|
}
|
|
568
642
|
else {
|
|
569
|
-
this.
|
|
570
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
643
|
+
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.On, this.Fan.On);
|
|
644
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.Fan.On}`);
|
|
571
645
|
}
|
|
572
646
|
}
|
|
573
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Fan On: ${this.On}`);
|
|
647
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Fan On: ${this.Fan.On}`);
|
|
574
648
|
}
|
|
575
649
|
else if (this.otherDeviceType === 'stateful') {
|
|
576
|
-
if (this.On === undefined) {
|
|
577
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
650
|
+
if (this.StatefulProgrammableSwitch.On === undefined) {
|
|
651
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.StatefulProgrammableSwitch.On}`);
|
|
578
652
|
}
|
|
579
653
|
else {
|
|
580
|
-
if (this.On) {
|
|
581
|
-
this.
|
|
582
|
-
this.
|
|
583
|
-
this.debugLog(`${this.device.remoteType}: `
|
|
584
|
-
|
|
654
|
+
if (this.StatefulProgrammableSwitch.On) {
|
|
655
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
|
|
656
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, 1);
|
|
657
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
658
|
+
+ ` ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 1 (${this.StatefulProgrammableSwitch.On})`);
|
|
585
659
|
}
|
|
586
660
|
else {
|
|
587
|
-
this.
|
|
588
|
-
this.
|
|
589
|
-
this.debugLog(`${this.device.remoteType}: `
|
|
590
|
-
|
|
661
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
|
|
662
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, 0);
|
|
663
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
664
|
+
+ ` ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 0 (${this.StatefulProgrammableSwitch.On})`);
|
|
591
665
|
}
|
|
592
666
|
}
|
|
593
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} StatefulProgrammableSwitch On: ${this.On}`);
|
|
667
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} StatefulProgrammableSwitch On: ${this.StatefulProgrammableSwitch.On}`);
|
|
594
668
|
}
|
|
595
669
|
else if (this.otherDeviceType === 'switch') {
|
|
596
|
-
if (this.On === undefined) {
|
|
597
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
670
|
+
if (this.Switch.On === undefined) {
|
|
671
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.Switch.On}`);
|
|
598
672
|
}
|
|
599
673
|
else {
|
|
600
|
-
this.
|
|
601
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
674
|
+
this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, this.Switch.On);
|
|
675
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.Switch.On}`);
|
|
602
676
|
}
|
|
603
677
|
}
|
|
604
678
|
else {
|
|
605
|
-
if (this.On === undefined) {
|
|
606
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
679
|
+
if (this.Outlet.On === undefined) {
|
|
680
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.Outlet.On}`);
|
|
607
681
|
}
|
|
608
682
|
else {
|
|
609
|
-
this.
|
|
610
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
683
|
+
this.Outlet.Service.updateCharacteristic(this.hap.Characteristic.On, this.Outlet.On);
|
|
684
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.Outlet.On}`);
|
|
611
685
|
}
|
|
612
686
|
}
|
|
613
687
|
}
|
|
614
|
-
async disablePushOnChanges(device) {
|
|
615
|
-
if (device.disablePushOn === undefined) {
|
|
616
|
-
this.disablePushOn = false;
|
|
617
|
-
}
|
|
618
|
-
else {
|
|
619
|
-
this.disablePushOn = device.disablePushOn;
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
async disablePushOffChanges(device) {
|
|
623
|
-
if (device.disablePushOff === undefined) {
|
|
624
|
-
this.disablePushOff = false;
|
|
625
|
-
}
|
|
626
|
-
else {
|
|
627
|
-
this.disablePushOff = device.disablePushOff;
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
async commandType() {
|
|
631
|
-
let commandType;
|
|
632
|
-
if (this.device.commandType && this.device.customize) {
|
|
633
|
-
commandType = this.device.commandType;
|
|
634
|
-
}
|
|
635
|
-
else if (this.device.customize) {
|
|
636
|
-
commandType = 'customize';
|
|
637
|
-
}
|
|
638
|
-
else {
|
|
639
|
-
commandType = 'command';
|
|
640
|
-
}
|
|
641
|
-
return commandType;
|
|
642
|
-
}
|
|
643
|
-
async commandOn() {
|
|
644
|
-
let command;
|
|
645
|
-
if (this.device.customize && this.device.customOn) {
|
|
646
|
-
command = this.device.customOn;
|
|
647
|
-
}
|
|
648
|
-
else {
|
|
649
|
-
command = 'turnOn';
|
|
650
|
-
}
|
|
651
|
-
return command;
|
|
652
|
-
}
|
|
653
|
-
async commandOff() {
|
|
654
|
-
let command;
|
|
655
|
-
if (this.device.customize && this.device.customOff) {
|
|
656
|
-
command = this.device.customOff;
|
|
657
|
-
}
|
|
658
|
-
else {
|
|
659
|
-
command = 'turnOff';
|
|
660
|
-
}
|
|
661
|
-
return command;
|
|
662
|
-
}
|
|
663
|
-
async statusCode(statusCode) {
|
|
664
|
-
switch (statusCode) {
|
|
665
|
-
case 151:
|
|
666
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command not supported by this deviceType, statusCode: ${statusCode}`);
|
|
667
|
-
break;
|
|
668
|
-
case 152:
|
|
669
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device not found, statusCode: ${statusCode}`);
|
|
670
|
-
break;
|
|
671
|
-
case 160:
|
|
672
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command is not supported, statusCode: ${statusCode}`);
|
|
673
|
-
break;
|
|
674
|
-
case 161:
|
|
675
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline, statusCode: ${statusCode}`);
|
|
676
|
-
break;
|
|
677
|
-
case 171:
|
|
678
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
|
|
679
|
-
`Hub: ${this.device.hubDeviceId}`);
|
|
680
|
-
break;
|
|
681
|
-
case 190:
|
|
682
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` +
|
|
683
|
-
` Or command format is invalid, statusCode: ${statusCode}`);
|
|
684
|
-
break;
|
|
685
|
-
case 100:
|
|
686
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Command successfully sent, statusCode: ${statusCode}`);
|
|
687
|
-
break;
|
|
688
|
-
case 200:
|
|
689
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
|
|
690
|
-
break;
|
|
691
|
-
case 400:
|
|
692
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Bad Request, The client has issued an invalid request. `
|
|
693
|
-
+ `This is commonly used to specify validation errors in a request payload, statusCode: ${statusCode}`);
|
|
694
|
-
break;
|
|
695
|
-
case 401:
|
|
696
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Unauthorized, Authorization for the API is required, `
|
|
697
|
-
+ `but the request has not been authenticated, statusCode: ${statusCode}`);
|
|
698
|
-
break;
|
|
699
|
-
case 403:
|
|
700
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Forbidden, The request has been authenticated but does not `
|
|
701
|
-
+ `have appropriate permissions, or a requested resource is not found, statusCode: ${statusCode}`);
|
|
702
|
-
break;
|
|
703
|
-
case 404:
|
|
704
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Not Found, Specifies the requested path does not exist, `
|
|
705
|
-
+ `statusCode: ${statusCode}`);
|
|
706
|
-
break;
|
|
707
|
-
case 406:
|
|
708
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Not Acceptable, The client has requested a MIME type via `
|
|
709
|
-
+ `the Accept header for a value not supported by the server, statusCode: ${statusCode}`);
|
|
710
|
-
break;
|
|
711
|
-
case 415:
|
|
712
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Unsupported Media Type, The client has defined a contentType `
|
|
713
|
-
+ `header that is not supported by the server, statusCode: ${statusCode}`);
|
|
714
|
-
break;
|
|
715
|
-
case 422:
|
|
716
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Unprocessable Entity, The client has made a valid request, but `
|
|
717
|
-
+ `the server cannot process it. This is often used for APIs for which certain limits have been exceeded, statusCode: ${statusCode}`);
|
|
718
|
-
break;
|
|
719
|
-
case 429:
|
|
720
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Too Many Requests, The client has exceeded the number of `
|
|
721
|
-
+ `requests allowed for a given time window, statusCode: ${statusCode}`);
|
|
722
|
-
break;
|
|
723
|
-
case 500:
|
|
724
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Internal Server Error, An unexpected error on the SmartThings `
|
|
725
|
-
+ `servers has occurred. These errors should be rare, statusCode: ${statusCode}`);
|
|
726
|
-
break;
|
|
727
|
-
default:
|
|
728
|
-
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: ` +
|
|
729
|
-
`${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
688
|
async apiError(e) {
|
|
733
689
|
if (this.otherDeviceType === 'garagedoor') {
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
690
|
+
if (this.GarageDoor) {
|
|
691
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, e);
|
|
692
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, e);
|
|
693
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.ObstructionDetected, e);
|
|
694
|
+
}
|
|
737
695
|
}
|
|
738
696
|
else if (this.otherDeviceType === 'door') {
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
697
|
+
if (this.Door) {
|
|
698
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e);
|
|
699
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e);
|
|
700
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e);
|
|
701
|
+
}
|
|
742
702
|
}
|
|
743
703
|
else if (this.otherDeviceType === 'window') {
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
704
|
+
if (this.Window) {
|
|
705
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e);
|
|
706
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e);
|
|
707
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e);
|
|
708
|
+
}
|
|
747
709
|
}
|
|
748
710
|
else if (this.otherDeviceType === 'windowcovering') {
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
711
|
+
if (this.WindowCovering) {
|
|
712
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e);
|
|
713
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e);
|
|
714
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e);
|
|
715
|
+
}
|
|
752
716
|
}
|
|
753
717
|
else if (this.otherDeviceType === 'lock') {
|
|
754
|
-
|
|
755
|
-
|
|
718
|
+
if (this.LockMechanism) {
|
|
719
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, e);
|
|
720
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, e);
|
|
721
|
+
}
|
|
756
722
|
}
|
|
757
723
|
else if (this.otherDeviceType === 'faucet') {
|
|
758
|
-
|
|
724
|
+
if (this.Faucet) {
|
|
725
|
+
this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, e);
|
|
726
|
+
}
|
|
759
727
|
}
|
|
760
728
|
else if (this.otherDeviceType === 'fan') {
|
|
761
|
-
|
|
729
|
+
if (this.Fan) {
|
|
730
|
+
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.On, e);
|
|
731
|
+
}
|
|
762
732
|
}
|
|
763
733
|
else if (this.otherDeviceType === 'stateful') {
|
|
764
|
-
|
|
765
|
-
|
|
734
|
+
if (this.StatefulProgrammableSwitch) {
|
|
735
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, e);
|
|
736
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, e);
|
|
737
|
+
}
|
|
766
738
|
}
|
|
767
739
|
else if (this.otherDeviceType === 'switch') {
|
|
768
|
-
|
|
740
|
+
if (this.Switch) {
|
|
741
|
+
this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, e);
|
|
742
|
+
}
|
|
769
743
|
}
|
|
770
744
|
else {
|
|
771
|
-
|
|
745
|
+
if (this.Outlet) {
|
|
746
|
+
this.Outlet.Service.updateCharacteristic(this.hap.Characteristic.On, e);
|
|
747
|
+
}
|
|
772
748
|
}
|
|
773
749
|
}
|
|
774
750
|
async removeOutletService(accessory) {
|
|
775
|
-
// If
|
|
776
|
-
|
|
777
|
-
|
|
751
|
+
// If Outlet.Service still present, then remove first
|
|
752
|
+
if (this.Outlet?.Service) {
|
|
753
|
+
this.Outlet.Service = this.accessory.getService(this.hap.Service.Outlet);
|
|
778
754
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Outlet Service`);
|
|
755
|
+
accessory.removeService(this.Outlet.Service);
|
|
779
756
|
}
|
|
780
|
-
accessory.removeService(this.outletService);
|
|
781
757
|
}
|
|
782
758
|
async removeGarageDoorService(accessory) {
|
|
783
|
-
// If
|
|
784
|
-
|
|
785
|
-
|
|
759
|
+
// If GarageDoor.Service still present, then remove first
|
|
760
|
+
if (this.GarageDoor?.Service) {
|
|
761
|
+
this.GarageDoor.Service = this.accessory.getService(this.hap.Service.GarageDoorOpener);
|
|
786
762
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Garage Door Service`);
|
|
763
|
+
accessory.removeService(this.GarageDoor.Service);
|
|
787
764
|
}
|
|
788
|
-
accessory.removeService(this.garageDoorService);
|
|
789
765
|
}
|
|
790
766
|
async removeDoorService(accessory) {
|
|
791
|
-
// If
|
|
792
|
-
|
|
793
|
-
|
|
767
|
+
// If Door.Service still present, then remove first
|
|
768
|
+
if (this.Door?.Service) {
|
|
769
|
+
this.Door.Service = this.accessory.getService(this.hap.Service.Door);
|
|
794
770
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Door Service`);
|
|
771
|
+
accessory.removeService(this.Door.Service);
|
|
795
772
|
}
|
|
796
|
-
accessory.removeService(this.doorService);
|
|
797
773
|
}
|
|
798
774
|
async removeLockService(accessory) {
|
|
799
|
-
// If
|
|
800
|
-
|
|
801
|
-
|
|
775
|
+
// If Lock.Service still present, then remove first
|
|
776
|
+
if (this.LockMechanism?.Service) {
|
|
777
|
+
this.LockMechanism.Service = this.accessory.getService(this.hap.Service.LockMechanism);
|
|
802
778
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Lock Service`);
|
|
779
|
+
accessory.removeService(this.LockMechanism.Service);
|
|
803
780
|
}
|
|
804
|
-
accessory.removeService(this.lockService);
|
|
805
781
|
}
|
|
806
782
|
async removeFaucetService(accessory) {
|
|
807
|
-
// If
|
|
808
|
-
|
|
809
|
-
|
|
783
|
+
// If Faucet.Service still present, then remove first
|
|
784
|
+
if (this.Faucet?.Service) {
|
|
785
|
+
this.Faucet.Service = this.accessory.getService(this.hap.Service.Faucet);
|
|
810
786
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Faucet Service`);
|
|
787
|
+
accessory.removeService(this.Faucet.Service);
|
|
811
788
|
}
|
|
812
|
-
accessory.removeService(this.faucetService);
|
|
813
789
|
}
|
|
814
790
|
async removeFanService(accessory) {
|
|
815
|
-
// If
|
|
816
|
-
|
|
817
|
-
|
|
791
|
+
// If Fan Service still present, then remove first
|
|
792
|
+
if (this.Fan?.Service) {
|
|
793
|
+
this.Fan.Service = this.accessory.getService(this.hap.Service.Fan);
|
|
818
794
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Fan Service`);
|
|
795
|
+
accessory.removeService(this.Fan.Service);
|
|
819
796
|
}
|
|
820
|
-
accessory.removeService(this.fanService);
|
|
821
797
|
}
|
|
822
798
|
async removeWindowService(accessory) {
|
|
823
|
-
// If
|
|
824
|
-
|
|
825
|
-
|
|
799
|
+
// If Window.Service still present, then remove first
|
|
800
|
+
if (this.Window?.Service) {
|
|
801
|
+
this.Window.Service = this.accessory.getService(this.hap.Service.Window);
|
|
826
802
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Window Service`);
|
|
803
|
+
accessory.removeService(this.Window.Service);
|
|
827
804
|
}
|
|
828
|
-
accessory.removeService(this.windowService);
|
|
829
805
|
}
|
|
830
806
|
async removeWindowCoveringService(accessory) {
|
|
831
|
-
// If
|
|
832
|
-
|
|
833
|
-
|
|
807
|
+
// If WindowCovering.Service still present, then remove first
|
|
808
|
+
if (this.WindowCovering?.Service) {
|
|
809
|
+
this.WindowCovering.Service = this.accessory.getService(this.hap.Service.WindowCovering);
|
|
834
810
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Window Covering Service`);
|
|
811
|
+
accessory.removeService(this.WindowCovering.Service);
|
|
835
812
|
}
|
|
836
|
-
accessory.removeService(this.windowCoveringService);
|
|
837
813
|
}
|
|
838
814
|
async removeStatefulProgrammableSwitchService(accessory) {
|
|
839
|
-
// If
|
|
840
|
-
|
|
841
|
-
|
|
815
|
+
// If StatefulProgrammableSwitch.Service still present, then remove first
|
|
816
|
+
if (this.StatefulProgrammableSwitch?.Service) {
|
|
817
|
+
this.StatefulProgrammableSwitch.Service = this.accessory.getService(this.hap.Service.StatefulProgrammableSwitch);
|
|
842
818
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Stateful Programmable Switch Service`);
|
|
819
|
+
accessory.removeService(this.StatefulProgrammableSwitch.Service);
|
|
843
820
|
}
|
|
844
|
-
accessory.removeService(this.statefulProgrammableSwitchService);
|
|
845
821
|
}
|
|
846
822
|
async removeSwitchService(accessory) {
|
|
847
|
-
// If
|
|
848
|
-
|
|
849
|
-
|
|
823
|
+
// If Switch.Service still present, then remove first
|
|
824
|
+
if (this.Switch?.Service) {
|
|
825
|
+
this.Switch.Service = this.accessory.getService(this.hap.Service.Switch);
|
|
850
826
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Switch Service`);
|
|
827
|
+
accessory.removeService(this.Switch.Service);
|
|
851
828
|
}
|
|
852
|
-
accessory.removeService(this.switchService);
|
|
853
829
|
}
|
|
854
|
-
async
|
|
830
|
+
async getOtherConfigSettings(device) {
|
|
855
831
|
if (!device.other?.deviceType && this.accessory.context.deviceType) {
|
|
856
832
|
this.otherDeviceType = this.accessory.context.deviceType;
|
|
857
833
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Device Type: ${this.otherDeviceType}, from Accessory Cache.`);
|
|
@@ -867,113 +843,5 @@ export class Others {
|
|
|
867
843
|
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName} no deviceType set, using default deviceType: ${this.otherDeviceType}`);
|
|
868
844
|
}
|
|
869
845
|
}
|
|
870
|
-
async deviceContext() {
|
|
871
|
-
if (this.On === undefined) {
|
|
872
|
-
this.On = true;
|
|
873
|
-
}
|
|
874
|
-
else {
|
|
875
|
-
this.On = this.accessory.context.On;
|
|
876
|
-
}
|
|
877
|
-
if (this.FirmwareRevision === undefined) {
|
|
878
|
-
this.FirmwareRevision = this.platform.version;
|
|
879
|
-
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
async deviceConfig(device) {
|
|
883
|
-
let config = {};
|
|
884
|
-
if (device.other) {
|
|
885
|
-
config = device.other;
|
|
886
|
-
}
|
|
887
|
-
if (device.logging !== undefined) {
|
|
888
|
-
config['logging'] = device.logging;
|
|
889
|
-
}
|
|
890
|
-
if (device.connectionType !== undefined) {
|
|
891
|
-
config['connectionType'] = device.connectionType;
|
|
892
|
-
}
|
|
893
|
-
if (device.external !== undefined) {
|
|
894
|
-
config['external'] = device.external;
|
|
895
|
-
}
|
|
896
|
-
if (device.customOn !== undefined) {
|
|
897
|
-
config['customOn'] = device.customOn;
|
|
898
|
-
}
|
|
899
|
-
if (device.customOff !== undefined) {
|
|
900
|
-
config['customOff'] = device.customOff;
|
|
901
|
-
}
|
|
902
|
-
if (device.customize !== undefined) {
|
|
903
|
-
config['customize'] = device.customize;
|
|
904
|
-
}
|
|
905
|
-
if (device.disablePushOn !== undefined) {
|
|
906
|
-
config['disablePushOn'] = device.disablePushOn;
|
|
907
|
-
}
|
|
908
|
-
if (device.disablePushOff !== undefined) {
|
|
909
|
-
config['disablePushOff'] = device.disablePushOff;
|
|
910
|
-
}
|
|
911
|
-
if (Object.entries(config).length !== 0) {
|
|
912
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
async deviceLogs(device) {
|
|
916
|
-
if (this.platform.debugMode) {
|
|
917
|
-
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
918
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
919
|
-
}
|
|
920
|
-
else if (device.logging) {
|
|
921
|
-
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
922
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
923
|
-
}
|
|
924
|
-
else if (this.platform.config.options?.logging) {
|
|
925
|
-
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
926
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
927
|
-
}
|
|
928
|
-
else {
|
|
929
|
-
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
930
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
/**
|
|
934
|
-
* Logging for Device
|
|
935
|
-
*/
|
|
936
|
-
infoLog(...log) {
|
|
937
|
-
if (this.enablingDeviceLogging()) {
|
|
938
|
-
this.platform.log.info(String(...log));
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
warnLog(...log) {
|
|
942
|
-
if (this.enablingDeviceLogging()) {
|
|
943
|
-
this.platform.log.warn(String(...log));
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
debugWarnLog(...log) {
|
|
947
|
-
if (this.enablingDeviceLogging()) {
|
|
948
|
-
if (this.deviceLogging?.includes('debug')) {
|
|
949
|
-
this.platform.log.warn('[DEBUG]', String(...log));
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
}
|
|
953
|
-
errorLog(...log) {
|
|
954
|
-
if (this.enablingDeviceLogging()) {
|
|
955
|
-
this.platform.log.error(String(...log));
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
debugErrorLog(...log) {
|
|
959
|
-
if (this.enablingDeviceLogging()) {
|
|
960
|
-
if (this.deviceLogging?.includes('debug')) {
|
|
961
|
-
this.platform.log.error('[DEBUG]', String(...log));
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
debugLog(...log) {
|
|
966
|
-
if (this.enablingDeviceLogging()) {
|
|
967
|
-
if (this.deviceLogging === 'debug') {
|
|
968
|
-
this.platform.log.info('[DEBUG]', String(...log));
|
|
969
|
-
}
|
|
970
|
-
else {
|
|
971
|
-
this.platform.log.debug(String(...log));
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
enablingDeviceLogging() {
|
|
976
|
-
return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
|
|
977
|
-
}
|
|
978
846
|
}
|
|
979
847
|
//# sourceMappingURL=other.js.map
|