@switchbot/homebridge-switchbot 3.5.0-beta.9 → 3.5.1-beta.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 +164 -22
- package/dist/device/blindtilt.d.ts +21 -96
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +457 -866
- 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 +851 -913
- 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 +316 -742
- 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 +380 -833
- 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 +267 -602
- 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 +469 -897
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +76 -0
- package/dist/device/device.d.ts.map +1 -0
- package/dist/device/device.js +846 -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 +645 -0
- package/dist/device/fan.js.map +1 -0
- package/dist/device/hub.d.ts +19 -58
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +304 -640
- 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 +300 -710
- 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 +225 -643
- 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 +371 -742
- 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 +309 -642
- 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 +223 -638
- 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 +216 -644
- 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 +209 -588
- 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 +141 -532
- 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 +252 -609
- 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 +179 -521
- 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 +337 -482
- 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 +108 -333
- 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 +47 -299
- 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 +95 -364
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +46 -0
- package/dist/irdevice/irdevice.d.ts.map +1 -0
- package/dist/irdevice/irdevice.js +393 -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 +121 -376
- 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 +441 -584
- 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 +94 -353
- 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 +48 -299
- 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 +50 -305
- 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 +66 -18
- 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 +95 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +657 -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 +488 -937
- package/src/device/bot.ts +907 -1016
- package/src/device/ceilinglight.ts +330 -798
- package/src/device/colorbulb.ts +394 -904
- package/src/device/contact.ts +298 -637
- package/src/device/curtain.ts +496 -954
- package/src/device/device.ts +872 -0
- package/src/device/fan.ts +692 -0
- package/src/device/hub.ts +338 -671
- package/src/device/humidifier.ts +330 -777
- package/src/device/iosensor.ts +258 -671
- package/src/device/lightstrip.ts +394 -809
- package/src/device/lock.ts +345 -700
- package/src/device/meter.ts +256 -666
- package/src/device/meterplus.ts +248 -672
- package/src/device/motion.ts +234 -622
- package/src/device/plug.ts +152 -572
- package/src/device/robotvacuumcleaner.ts +273 -653
- package/src/device/waterdetector.ts +198 -549
- 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 +368 -540
- package/src/irdevice/airpurifier.ts +134 -369
- package/src/irdevice/camera.ts +60 -324
- package/src/irdevice/fan.ts +111 -392
- package/src/irdevice/irdevice.ts +406 -0
- package/src/irdevice/light.ts +159 -425
- package/src/irdevice/other.ts +509 -661
- package/src/irdevice/tv.ts +123 -388
- package/src/irdevice/vacuumcleaner.ts +61 -324
- package/src/irdevice/waterheater.ts +63 -333
- package/src/platform.ts +395 -259
- package/src/settings.ts +120 -610
- package/src/utils.ts +661 -1
- package/src/device/waterdetector.json +0 -11
package/src/irdevice/light.ts
CHANGED
|
@@ -1,125 +1,125 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/* Copyright(C) 2021-2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
|
|
2
|
+
*
|
|
3
|
+
* light.ts: @switchbot/homebridge-switchbot.
|
|
4
|
+
*/
|
|
5
|
+
import { irdeviceBase } from './irdevice.js';
|
|
6
|
+
|
|
7
|
+
import type { SwitchBotPlatform } from '../platform.js';
|
|
8
|
+
import type { irDevicesConfig, irdevice } from '../settings.js';
|
|
9
|
+
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
5
10
|
|
|
6
11
|
/**
|
|
7
12
|
* Platform Accessory
|
|
8
13
|
* An instance of this class is created for each accessory your platform registers
|
|
9
14
|
* Each accessory may expose multiple services of different service types.
|
|
10
15
|
*/
|
|
11
|
-
export class Light {
|
|
12
|
-
public readonly api: API;
|
|
13
|
-
public readonly log: Logging;
|
|
14
|
-
public readonly config!: SwitchBotPlatformConfig;
|
|
15
|
-
protected readonly hap: HAP;
|
|
16
|
+
export class Light extends irdeviceBase {
|
|
16
17
|
// Services
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
18
|
+
private LightBulb?: {
|
|
19
|
+
Name: CharacteristicValue;
|
|
20
|
+
Service: Service;
|
|
21
|
+
On: CharacteristicValue;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
private ProgrammableSwitchOn?: {
|
|
25
|
+
Name: CharacteristicValue;
|
|
26
|
+
Service: Service;
|
|
27
|
+
ProgrammableSwitchEvent: CharacteristicValue;
|
|
28
|
+
ProgrammableSwitchOutputState: CharacteristicValue;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
private ProgrammableSwitchOff?: {
|
|
32
|
+
Name: CharacteristicValue;
|
|
33
|
+
Service: Service;
|
|
34
|
+
ProgrammableSwitchEvent: CharacteristicValue;
|
|
35
|
+
ProgrammableSwitchOutputState: CharacteristicValue;
|
|
36
|
+
};
|
|
33
37
|
|
|
34
38
|
constructor(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
readonly platform: SwitchBotPlatform,
|
|
40
|
+
accessory: PlatformAccessory,
|
|
41
|
+
device: irdevice & irDevicesConfig,
|
|
38
42
|
) {
|
|
39
|
-
|
|
40
|
-
this.log = this.platform.log;
|
|
41
|
-
this.config = this.platform.config;
|
|
42
|
-
this.hap = this.api.hap;
|
|
43
|
-
// default placeholders
|
|
44
|
-
this.deviceLogs(device);
|
|
45
|
-
this.deviceContext();
|
|
46
|
-
this.disablePushOnChanges(device);
|
|
47
|
-
this.disablePushOffChanges(device);
|
|
48
|
-
this.deviceConfig(device);
|
|
49
|
-
|
|
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);
|
|
43
|
+
super(platform, accessory, device);
|
|
57
44
|
|
|
58
45
|
if (!device.irlight?.stateless) {
|
|
59
|
-
//
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
46
|
+
// Initialize LightBulb Service
|
|
47
|
+
accessory.context.LightBulb = accessory.context.LightBulb ?? {};
|
|
48
|
+
this.LightBulb = {
|
|
49
|
+
Name: accessory.context.LightBulb.Name ?? `${accessory.displayName} ${device.remoteType}`,
|
|
50
|
+
Service: accessory.getService(this.hap.Service.Lightbulb) ?? accessory.addService(this.hap.Service.Lightbulb) as Service,
|
|
51
|
+
On: accessory.context.On || false,
|
|
52
|
+
};
|
|
53
|
+
accessory.context.LightBulb = this.LightBulb as object;
|
|
54
|
+
|
|
55
|
+
this.LightBulb.Service
|
|
56
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.LightBulb.Name)
|
|
57
|
+
.getCharacteristic(this.hap.Characteristic.On)
|
|
58
|
+
.onGet(() => {
|
|
59
|
+
return this.LightBulb!.On;
|
|
60
|
+
})
|
|
61
|
+
.onSet(this.OnSet.bind(this));
|
|
73
62
|
} else {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
this.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
63
|
+
// Initialize ProgrammableSwitchOn Service
|
|
64
|
+
accessory.context.ProgrammableSwitchOn = accessory.context.ProgrammableSwitchOn ?? {};
|
|
65
|
+
this.ProgrammableSwitchOn = {
|
|
66
|
+
Name: accessory.context.ProgrammableSwitchOn.Name ?? `${accessory.displayName} ${device.remoteType} On`,
|
|
67
|
+
Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch)
|
|
68
|
+
?? accessory.addService(this.hap.Service.StatefulProgrammableSwitch) as Service,
|
|
69
|
+
ProgrammableSwitchEvent: accessory.context.ProgrammableSwitchEvent ?? this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS,
|
|
70
|
+
ProgrammableSwitchOutputState: accessory.context.ProgrammableSwitchOutputState ?? 0,
|
|
71
|
+
};
|
|
72
|
+
accessory.context.ProgrammableSwitchOn = this.ProgrammableSwitchOn as object;
|
|
73
|
+
|
|
74
|
+
// Initialize ProgrammableSwitchOn Characteristics
|
|
75
|
+
this.ProgrammableSwitchOn?.Service
|
|
76
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.ProgrammableSwitchOn.Name)
|
|
77
|
+
.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent).setProps({
|
|
78
|
+
validValueRanges: [0, 0],
|
|
79
|
+
minValue: 0,
|
|
80
|
+
maxValue: 0,
|
|
81
|
+
validValues: [0],
|
|
82
|
+
})
|
|
92
83
|
.onGet(() => {
|
|
93
|
-
return this.
|
|
84
|
+
return this.ProgrammableSwitchOn!.ProgrammableSwitchEvent;
|
|
94
85
|
});
|
|
95
86
|
|
|
96
|
-
this.
|
|
87
|
+
this.ProgrammableSwitchOn?.Service
|
|
88
|
+
.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState)
|
|
89
|
+
.onGet(() => {
|
|
90
|
+
return this.ProgrammableSwitchOn!.ProgrammableSwitchOutputState;
|
|
91
|
+
})
|
|
97
92
|
.onSet(this.ProgrammableSwitchOutputStateSetOn.bind(this));
|
|
98
93
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
94
|
+
// Initialize ProgrammableSwitchOff Service
|
|
95
|
+
accessory.context.ProgrammableSwitchOff = accessory.context.ProgrammableSwitchOff ?? {};
|
|
96
|
+
this.ProgrammableSwitchOff = {
|
|
97
|
+
Name: accessory.context.ProgrammableSwitchOff.Name ?? `${accessory.displayName} ${device.remoteType} Off`,
|
|
98
|
+
Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch)
|
|
99
|
+
?? accessory.addService(this.hap.Service.StatefulProgrammableSwitch) as Service,
|
|
100
|
+
ProgrammableSwitchEvent: accessory.context.ProgrammableSwitchEvent ?? this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS,
|
|
101
|
+
ProgrammableSwitchOutputState: accessory.context.ProgrammableSwitchOutputState ?? 0,
|
|
102
|
+
};
|
|
103
|
+
accessory.context.ProgrammableSwitchOff = this.ProgrammableSwitchOff as object;
|
|
104
|
+
|
|
105
|
+
// Initialize ProgrammableSwitchOff Characteristics
|
|
106
|
+
this.ProgrammableSwitchOff?.Service
|
|
107
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.ProgrammableSwitchOff.Name)
|
|
108
|
+
.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent).setProps({
|
|
109
|
+
validValueRanges: [0, 0],
|
|
110
|
+
minValue: 0,
|
|
111
|
+
maxValue: 0,
|
|
112
|
+
validValues: [0],
|
|
113
|
+
})
|
|
118
114
|
.onGet(() => {
|
|
119
|
-
return this.
|
|
115
|
+
return this.ProgrammableSwitchOff!.ProgrammableSwitchEvent;
|
|
120
116
|
});
|
|
121
117
|
|
|
122
|
-
this.
|
|
118
|
+
this.ProgrammableSwitchOff?.Service
|
|
119
|
+
.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState)
|
|
120
|
+
.onGet(() => {
|
|
121
|
+
return this.ProgrammableSwitchOff!.ProgrammableSwitchOutputState;
|
|
122
|
+
})
|
|
123
123
|
.onSet(this.ProgrammableSwitchOutputStateSetOff.bind(this));
|
|
124
124
|
}
|
|
125
125
|
|
|
@@ -128,11 +128,13 @@ export class Light {
|
|
|
128
128
|
async OnSet(value: CharacteristicValue): Promise<void> {
|
|
129
129
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${value}`);
|
|
130
130
|
|
|
131
|
-
this.On = value;
|
|
132
|
-
if (this.On) {
|
|
133
|
-
|
|
131
|
+
this.LightBulb!.On = value;
|
|
132
|
+
if (this.LightBulb?.On) {
|
|
133
|
+
const On = true;
|
|
134
|
+
await this.pushLightOnChanges(On);
|
|
134
135
|
} else {
|
|
135
|
-
|
|
136
|
+
const On = false;
|
|
137
|
+
await this.pushLightOffChanges(On);
|
|
136
138
|
}
|
|
137
139
|
/**
|
|
138
140
|
* pushLightOnChanges and pushLightOffChanges above assume they are measuring the state of the accessory BEFORE
|
|
@@ -143,10 +145,10 @@ export class Light {
|
|
|
143
145
|
async ProgrammableSwitchOutputStateSetOn(value: CharacteristicValue): Promise<void> {
|
|
144
146
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${value}`);
|
|
145
147
|
|
|
146
|
-
this.
|
|
147
|
-
if (this.
|
|
148
|
-
|
|
149
|
-
await this.pushLightOnChanges();
|
|
148
|
+
this.ProgrammableSwitchOn!.ProgrammableSwitchOutputState = value;
|
|
149
|
+
if (this.ProgrammableSwitchOn?.ProgrammableSwitchOutputState === 1) {
|
|
150
|
+
const On = true;
|
|
151
|
+
await this.pushLightOnChanges(On);
|
|
150
152
|
}
|
|
151
153
|
/**
|
|
152
154
|
* pushLightOnChanges and pushLightOffChanges above assume they are measuring the state of the accessory BEFORE
|
|
@@ -157,10 +159,10 @@ export class Light {
|
|
|
157
159
|
async ProgrammableSwitchOutputStateSetOff(value: CharacteristicValue): Promise<void> {
|
|
158
160
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${value}`);
|
|
159
161
|
|
|
160
|
-
this.
|
|
161
|
-
if (this.
|
|
162
|
-
|
|
163
|
-
await this.pushLightOffChanges();
|
|
162
|
+
this.ProgrammableSwitchOff!.ProgrammableSwitchOutputState = value;
|
|
163
|
+
if (this.ProgrammableSwitchOff?.ProgrammableSwitchOutputState === 1) {
|
|
164
|
+
const On = false;
|
|
165
|
+
await this.pushLightOffChanges(On);
|
|
164
166
|
}
|
|
165
167
|
/**
|
|
166
168
|
* pushLightOnChanges and pushLightOffChanges above assume they are measuring the state of the accessory BEFORE
|
|
@@ -180,11 +182,9 @@ export class Light {
|
|
|
180
182
|
* Light - "command" "channelAdd" "default" = next channel
|
|
181
183
|
* Light - "command" "channelSub" "default" = previous channel
|
|
182
184
|
*/
|
|
183
|
-
async pushLightOnChanges(): Promise<void> {
|
|
184
|
-
this.debugLog(
|
|
185
|
-
|
|
186
|
-
);
|
|
187
|
-
if (this.On && !this.disablePushOn) {
|
|
185
|
+
async pushLightOnChanges(On: boolean): Promise<void> {
|
|
186
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushLightOnChanges On: ${On}, disablePushOn: ${this.disablePushOn}`);
|
|
187
|
+
if (On === true && this.disablePushOn === false) {
|
|
188
188
|
const commandType: string = await this.commandType();
|
|
189
189
|
const command: string = await this.commandOn();
|
|
190
190
|
const bodyChange = JSON.stringify({
|
|
@@ -192,15 +192,13 @@ export class Light {
|
|
|
192
192
|
parameter: 'default',
|
|
193
193
|
commandType: commandType,
|
|
194
194
|
});
|
|
195
|
-
await this.pushChanges(bodyChange);
|
|
195
|
+
await this.pushChanges(bodyChange, On);
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
async pushLightOffChanges(): Promise<void> {
|
|
200
|
-
this.debugLog(
|
|
201
|
-
|
|
202
|
-
);
|
|
203
|
-
if (!this.On && !this.disablePushOff) {
|
|
199
|
+
async pushLightOffChanges(On: boolean): Promise<void> {
|
|
200
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushLightOffChanges On: ${On}, disablePushOff: ${this.disablePushOff}`);
|
|
201
|
+
if (On === false && this.disablePushOff === false) {
|
|
204
202
|
const commandType: string = await this.commandType();
|
|
205
203
|
const command: string = await this.commandOff();
|
|
206
204
|
const bodyChange = JSON.stringify({
|
|
@@ -208,345 +206,81 @@ export class Light {
|
|
|
208
206
|
parameter: 'default',
|
|
209
207
|
commandType: commandType,
|
|
210
208
|
});
|
|
211
|
-
await this.pushChanges(bodyChange);
|
|
209
|
+
await this.pushChanges(bodyChange, On);
|
|
212
210
|
}
|
|
213
211
|
}
|
|
214
212
|
|
|
215
|
-
|
|
216
|
-
const bodyChange = JSON.stringify({
|
|
217
|
-
command: 'brightnessUp',
|
|
218
|
-
parameter: 'default',
|
|
219
|
-
commandType: 'command',
|
|
220
|
-
});
|
|
221
|
-
await this.pushChanges(bodyChange);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
async pushLightBrightnessDownChanges(): Promise<void> {
|
|
225
|
-
const bodyChange = JSON.stringify({
|
|
226
|
-
command: 'brightnessDown',
|
|
227
|
-
parameter: 'default',
|
|
228
|
-
commandType: 'command',
|
|
229
|
-
});
|
|
230
|
-
await this.pushChanges(bodyChange);
|
|
231
|
-
}*/
|
|
232
|
-
|
|
233
|
-
async pushChanges(bodyChange: any): Promise<void> {
|
|
213
|
+
async pushChanges(bodyChange: any, On: boolean): Promise<void> {
|
|
234
214
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
|
|
235
215
|
if (this.device.connectionType === 'OpenAPI') {
|
|
236
216
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
237
217
|
try {
|
|
238
|
-
const { body, statusCode } = await
|
|
239
|
-
body: bodyChange,
|
|
240
|
-
method: 'POST',
|
|
241
|
-
headers: this.platform.generateHeaders(),
|
|
242
|
-
});
|
|
243
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
218
|
+
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
244
219
|
const deviceStatus: any = await body.json();
|
|
245
|
-
this.
|
|
246
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
220
|
+
await this.pushStatusCodes(statusCode, deviceStatus);
|
|
247
221
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
248
|
-
this.
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
this.updateHomeKitCharacteristics();
|
|
222
|
+
await this.successfulPushChange(statusCode, deviceStatus, bodyChange);
|
|
223
|
+
this.accessory.context.On = On;
|
|
224
|
+
await this.updateHomeKitCharacteristics();
|
|
252
225
|
} else {
|
|
253
|
-
this.statusCode(statusCode);
|
|
254
|
-
this.statusCode(deviceStatus.statusCode);
|
|
226
|
+
await this.statusCode(statusCode);
|
|
227
|
+
await this.statusCode(deviceStatus.statusCode);
|
|
255
228
|
}
|
|
256
229
|
} catch (e: any) {
|
|
257
230
|
this.apiError(e);
|
|
258
|
-
this.errorLog(
|
|
259
|
-
|
|
260
|
-
` Connection, Error Message: ${JSON.stringify(e.message)}`,
|
|
261
|
-
);
|
|
231
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}`
|
|
232
|
+
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
262
233
|
}
|
|
263
234
|
} else {
|
|
264
|
-
this.warnLog(
|
|
265
|
-
|
|
266
|
-
` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`,
|
|
267
|
-
);
|
|
235
|
+
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName} Connection Type: `
|
|
236
|
+
+ `${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
268
237
|
}
|
|
269
238
|
}
|
|
270
239
|
|
|
271
240
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
272
|
-
if (this.device.irlight?.stateless) {
|
|
241
|
+
if (!this.device.irlight?.stateless) {
|
|
273
242
|
// On
|
|
274
|
-
if (this.On === undefined) {
|
|
275
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
243
|
+
if (this.LightBulb?.On === undefined) {
|
|
244
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.LightBulb?.On}`);
|
|
276
245
|
} else {
|
|
277
|
-
this.accessory.context.On = this.On;
|
|
278
|
-
this.
|
|
279
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
246
|
+
this.accessory.context.On = this.LightBulb.On;
|
|
247
|
+
this.LightBulb?.Service.updateCharacteristic(this.hap.Characteristic.On, this.LightBulb.On);
|
|
248
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.LightBulb.On}`);
|
|
280
249
|
}
|
|
281
250
|
} else {
|
|
282
251
|
// On Stateful Programmable Switch
|
|
283
|
-
if (this.
|
|
252
|
+
if (this.ProgrammableSwitchOn?.ProgrammableSwitchOutputState === undefined) {
|
|
284
253
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
285
|
-
+ ` ProgrammableSwitchOutputStateOn: ${this.
|
|
254
|
+
+ ` ProgrammableSwitchOutputStateOn: ${this.ProgrammableSwitchOn?.ProgrammableSwitchOutputState}`);
|
|
286
255
|
} else {
|
|
287
|
-
this.accessory.context.ProgrammableSwitchOutputStateOn = this.
|
|
288
|
-
this.
|
|
289
|
-
this.
|
|
256
|
+
this.accessory.context.ProgrammableSwitchOutputStateOn = this.ProgrammableSwitchOn.ProgrammableSwitchOutputState;
|
|
257
|
+
this.ProgrammableSwitchOn?.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState,
|
|
258
|
+
this.ProgrammableSwitchOn.ProgrammableSwitchOutputState);
|
|
290
259
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
291
|
-
+ ` ProgrammableSwitchOutputStateOn: ${this.
|
|
260
|
+
+ ` ProgrammableSwitchOutputStateOn: ${this.ProgrammableSwitchOn.ProgrammableSwitchOutputState}`);
|
|
292
261
|
}
|
|
293
262
|
// Off Stateful Programmable Switch
|
|
294
|
-
if (this.
|
|
263
|
+
if (this.ProgrammableSwitchOff?.ProgrammableSwitchOutputState === undefined) {
|
|
295
264
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
296
|
-
+ ` ProgrammableSwitchOutputStateOff: ${this.
|
|
265
|
+
+ ` ProgrammableSwitchOutputStateOff: ${this.ProgrammableSwitchOff?.ProgrammableSwitchOutputState}`);
|
|
297
266
|
} else {
|
|
298
|
-
this.accessory.context.ProgrammableSwitchOutputStateOff = this.
|
|
299
|
-
this.
|
|
300
|
-
this.
|
|
267
|
+
this.accessory.context.ProgrammableSwitchOutputStateOff = this.ProgrammableSwitchOff.ProgrammableSwitchOutputState;
|
|
268
|
+
this.ProgrammableSwitchOff.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState,
|
|
269
|
+
this.ProgrammableSwitchOff.ProgrammableSwitchOutputState);
|
|
301
270
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
302
|
-
+ ` ProgrammableSwitchOutputStateOff: ${this.
|
|
271
|
+
+ ` ProgrammableSwitchOutputStateOff: ${this.ProgrammableSwitchOff?.ProgrammableSwitchOutputState}`);
|
|
303
272
|
}
|
|
304
273
|
}
|
|
305
274
|
}
|
|
306
275
|
|
|
307
|
-
async disablePushOnChanges(device: irdevice & irDevicesConfig): Promise<void> {
|
|
308
|
-
if (device.disablePushOn === undefined) {
|
|
309
|
-
this.disablePushOn = false;
|
|
310
|
-
} else {
|
|
311
|
-
this.disablePushOn = device.disablePushOn;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
async disablePushOffChanges(device: irdevice & irDevicesConfig): Promise<void> {
|
|
316
|
-
if (device.disablePushOff === undefined) {
|
|
317
|
-
this.disablePushOff = false;
|
|
318
|
-
} else {
|
|
319
|
-
this.disablePushOff = device.disablePushOff;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
async commandType(): Promise<string> {
|
|
324
|
-
let commandType: string;
|
|
325
|
-
if (this.device.customize) {
|
|
326
|
-
commandType = 'customize';
|
|
327
|
-
} else {
|
|
328
|
-
commandType = 'command';
|
|
329
|
-
}
|
|
330
|
-
return commandType;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
async commandOn(): Promise<string> {
|
|
334
|
-
let command: string;
|
|
335
|
-
if (this.device.customize && this.device.customOn) {
|
|
336
|
-
command = this.device.customOn;
|
|
337
|
-
} else {
|
|
338
|
-
command = 'turnOn';
|
|
339
|
-
}
|
|
340
|
-
return command;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
async commandOff(): Promise<string> {
|
|
344
|
-
let command: string;
|
|
345
|
-
if (this.device.customize && this.device.customOff) {
|
|
346
|
-
command = this.device.customOff;
|
|
347
|
-
} else {
|
|
348
|
-
command = 'turnOff';
|
|
349
|
-
}
|
|
350
|
-
return command;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
async statusCode(statusCode: number): Promise<void> {
|
|
354
|
-
switch (statusCode) {
|
|
355
|
-
case 151:
|
|
356
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command not supported by this deviceType, statusCode: ${statusCode}`);
|
|
357
|
-
break;
|
|
358
|
-
case 152:
|
|
359
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device not found, statusCode: ${statusCode}`);
|
|
360
|
-
break;
|
|
361
|
-
case 160:
|
|
362
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command is not supported, statusCode: ${statusCode}`);
|
|
363
|
-
break;
|
|
364
|
-
case 161:
|
|
365
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline, statusCode: ${statusCode}`);
|
|
366
|
-
break;
|
|
367
|
-
case 171:
|
|
368
|
-
this.errorLog(
|
|
369
|
-
`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
|
|
370
|
-
`Hub: ${this.device.hubDeviceId}`,
|
|
371
|
-
);
|
|
372
|
-
break;
|
|
373
|
-
case 190:
|
|
374
|
-
this.errorLog(
|
|
375
|
-
`${this.device.remoteType}: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` +
|
|
376
|
-
` Or command format is invalid, statusCode: ${statusCode}`,
|
|
377
|
-
);
|
|
378
|
-
break;
|
|
379
|
-
case 100:
|
|
380
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Command successfully sent, statusCode: ${statusCode}`);
|
|
381
|
-
break;
|
|
382
|
-
case 200:
|
|
383
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
|
|
384
|
-
break;
|
|
385
|
-
case 400:
|
|
386
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Bad Request, The client has issued an invalid request. `
|
|
387
|
-
+ `This is commonly used to specify validation errors in a request payload, statusCode: ${statusCode}`);
|
|
388
|
-
break;
|
|
389
|
-
case 401:
|
|
390
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Unauthorized, Authorization for the API is required, `
|
|
391
|
-
+ `but the request has not been authenticated, statusCode: ${statusCode}`);
|
|
392
|
-
break;
|
|
393
|
-
case 403:
|
|
394
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Forbidden, The request has been authenticated but does not `
|
|
395
|
-
+ `have appropriate permissions, or a requested resource is not found, statusCode: ${statusCode}`);
|
|
396
|
-
break;
|
|
397
|
-
case 404:
|
|
398
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Not Found, Specifies the requested path does not exist, `
|
|
399
|
-
+ `statusCode: ${statusCode}`);
|
|
400
|
-
break;
|
|
401
|
-
case 406:
|
|
402
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Not Acceptable, The client has requested a MIME type via `
|
|
403
|
-
+ `the Accept header for a value not supported by the server, statusCode: ${statusCode}`);
|
|
404
|
-
break;
|
|
405
|
-
case 415:
|
|
406
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Unsupported Media Type, The client has defined a contentType `
|
|
407
|
-
+ `header that is not supported by the server, statusCode: ${statusCode}`);
|
|
408
|
-
break;
|
|
409
|
-
case 422:
|
|
410
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Unprocessable Entity, The client has made a valid request, but `
|
|
411
|
-
+ `the server cannot process it. This is often used for APIs for which certain limits have been exceeded, statusCode: ${statusCode}`);
|
|
412
|
-
break;
|
|
413
|
-
case 429:
|
|
414
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Too Many Requests, The client has exceeded the number of `
|
|
415
|
-
+ `requests allowed for a given time window, statusCode: ${statusCode}`);
|
|
416
|
-
break;
|
|
417
|
-
case 500:
|
|
418
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Internal Server Error, An unexpected error on the SmartThings `
|
|
419
|
-
+ `servers has occurred. These errors should be rare, statusCode: ${statusCode}`);
|
|
420
|
-
break;
|
|
421
|
-
default:
|
|
422
|
-
this.infoLog(
|
|
423
|
-
`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: ` +
|
|
424
|
-
`${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`,
|
|
425
|
-
);
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
|
|
429
276
|
async apiError(e: any): Promise<void> {
|
|
430
|
-
if (this.device.irlight?.stateless) {
|
|
431
|
-
this.
|
|
432
|
-
} else {
|
|
433
|
-
this.ProgrammableSwitchServiceOn?.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, e);
|
|
434
|
-
this.ProgrammableSwitchServiceOn?.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, e);
|
|
435
|
-
this.ProgrammableSwitchServiceOff?.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, e);
|
|
436
|
-
this.ProgrammableSwitchServiceOff?.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, e);
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
async deviceContext() {
|
|
441
|
-
if (this.On === undefined) {
|
|
442
|
-
this.On = false;
|
|
443
|
-
} else {
|
|
444
|
-
this.On = this.accessory.context.On;
|
|
445
|
-
}
|
|
446
|
-
if (this.FirmwareRevision === undefined) {
|
|
447
|
-
this.FirmwareRevision = this.platform.version;
|
|
448
|
-
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
async deviceConfig(device: irdevice & irDevicesConfig): Promise<void> {
|
|
453
|
-
let config = {};
|
|
454
|
-
if (device.irlight) {
|
|
455
|
-
config = device.irlight;
|
|
456
|
-
}
|
|
457
|
-
if (device.logging !== undefined) {
|
|
458
|
-
config['logging'] = device.logging;
|
|
459
|
-
}
|
|
460
|
-
if (device.connectionType !== undefined) {
|
|
461
|
-
config['connectionType'] = device.connectionType;
|
|
462
|
-
}
|
|
463
|
-
if (device.external !== undefined) {
|
|
464
|
-
config['external'] = device.external;
|
|
465
|
-
}
|
|
466
|
-
if (device.customOn !== undefined) {
|
|
467
|
-
config['customOn'] = device.customOn;
|
|
468
|
-
}
|
|
469
|
-
if (device.customOff !== undefined) {
|
|
470
|
-
config['customOff'] = device.customOff;
|
|
471
|
-
}
|
|
472
|
-
if (device.customize !== undefined) {
|
|
473
|
-
config['customize'] = device.customize;
|
|
474
|
-
}
|
|
475
|
-
if (device.disablePushOn !== undefined) {
|
|
476
|
-
config['disablePushOn'] = device.disablePushOn;
|
|
477
|
-
}
|
|
478
|
-
if (device.disablePushOff !== undefined) {
|
|
479
|
-
config['disablePushOff'] = device.disablePushOff;
|
|
480
|
-
}
|
|
481
|
-
if (Object.entries(config).length !== 0) {
|
|
482
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
async deviceLogs(device: irdevice & irDevicesConfig): Promise<void> {
|
|
487
|
-
if (this.platform.debugMode) {
|
|
488
|
-
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
489
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
490
|
-
} else if (device.logging) {
|
|
491
|
-
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
492
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
493
|
-
} else if (this.platform.config.options?.logging) {
|
|
494
|
-
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
495
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
277
|
+
if (!this.device.irlight?.stateless) {
|
|
278
|
+
this.LightBulb?.Service.updateCharacteristic(this.hap.Characteristic.On, e);
|
|
496
279
|
} else {
|
|
497
|
-
this.
|
|
498
|
-
this.
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
/**
|
|
503
|
-
* Logging for Device
|
|
504
|
-
*/
|
|
505
|
-
infoLog(...log: any[]): void {
|
|
506
|
-
if (this.enablingDeviceLogging()) {
|
|
507
|
-
this.platform.log.info(String(...log));
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
warnLog(...log: any[]): void {
|
|
512
|
-
if (this.enablingDeviceLogging()) {
|
|
513
|
-
this.platform.log.warn(String(...log));
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
debugWarnLog(...log: any[]): void {
|
|
518
|
-
if (this.enablingDeviceLogging()) {
|
|
519
|
-
if (this.deviceLogging?.includes('debug')) {
|
|
520
|
-
this.platform.log.warn('[DEBUG]', String(...log));
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
errorLog(...log: any[]): void {
|
|
526
|
-
if (this.enablingDeviceLogging()) {
|
|
527
|
-
this.platform.log.error(String(...log));
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
debugErrorLog(...log: any[]): void {
|
|
532
|
-
if (this.enablingDeviceLogging()) {
|
|
533
|
-
if (this.deviceLogging?.includes('debug')) {
|
|
534
|
-
this.platform.log.error('[DEBUG]', String(...log));
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
debugLog(...log: any[]): void {
|
|
540
|
-
if (this.enablingDeviceLogging()) {
|
|
541
|
-
if (this.deviceLogging === 'debug') {
|
|
542
|
-
this.platform.log.info('[DEBUG]', String(...log));
|
|
543
|
-
} else {
|
|
544
|
-
this.platform.log.debug(String(...log));
|
|
545
|
-
}
|
|
280
|
+
this.ProgrammableSwitchOn?.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, e);
|
|
281
|
+
this.ProgrammableSwitchOn?.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, e);
|
|
282
|
+
this.ProgrammableSwitchOff?.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, e);
|
|
283
|
+
this.ProgrammableSwitchOff?.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, e);
|
|
546
284
|
}
|
|
547
285
|
}
|
|
548
|
-
|
|
549
|
-
enablingDeviceLogging(): boolean {
|
|
550
|
-
return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
|
|
551
|
-
}
|
|
552
286
|
}
|