@switchbot/homebridge-switchbot 2.0.0-beta.8 → 2.0.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/CHANGELOG.md +10 -1
- package/README.md +3 -2
- package/config.schema.json +91 -19
- package/dist/device/bot.d.ts +34 -28
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +657 -648
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +137 -0
- package/dist/device/ceilinglight.d.ts.map +1 -0
- package/dist/device/ceilinglight.js +1127 -0
- package/dist/device/ceilinglight.js.map +1 -0
- package/dist/device/colorbulb.d.ts +36 -19
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +486 -309
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +18 -8
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +306 -237
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +23 -16
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +566 -502
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/humidifier.d.ts +24 -18
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +453 -369
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/lock.d.ts +27 -8
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +305 -148
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +22 -16
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +367 -267
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +24 -12
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +381 -213
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +18 -8
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +279 -216
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +27 -17
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +295 -251
- package/dist/device/plug.js.map +1 -1
- package/dist/device/striplight.d.ts +43 -19
- package/dist/device/striplight.d.ts.map +1 -1
- package/dist/device/striplight.js +506 -262
- package/dist/device/striplight.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +9 -12
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +278 -230
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +5 -3
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +154 -104
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +11 -8
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +133 -86
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +10 -7
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +160 -109
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +11 -8
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +137 -103
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +11 -8
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +145 -98
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +12 -9
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +143 -93
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +9 -10
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +132 -89
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +8 -9
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +132 -89
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +13 -12
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +524 -418
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +19 -11
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/homebridge-ui/public/index.html +1 -0
- package/package.json +11 -9
- package/src/device/bot.ts +656 -659
- package/src/device/ceilinglight.ts +1208 -0
- package/src/device/colorbulb.ts +490 -344
- package/src/device/contact.ts +309 -241
- package/src/device/curtain.ts +571 -516
- package/src/device/humidifier.ts +456 -403
- package/src/device/lock.ts +314 -149
- package/src/device/meter.ts +378 -280
- package/src/device/meterplus.ts +391 -219
- package/src/device/motion.ts +285 -222
- package/src/device/plug.ts +299 -260
- package/src/device/striplight.ts +522 -289
- package/src/irdevice/airconditioner.ts +282 -241
- package/src/irdevice/airpurifier.ts +151 -103
- package/src/irdevice/camera.ts +131 -85
- package/src/irdevice/fan.ts +157 -106
- package/src/irdevice/light.ts +135 -103
- package/src/irdevice/other.ts +143 -97
- package/src/irdevice/tv.ts +142 -93
- package/src/irdevice/vacuumcleaner.ts +131 -89
- package/src/irdevice/waterheater.ts +130 -89
- package/src/platform.ts +522 -446
- package/src/settings.ts +20 -11
- package/.github/npm-version-script.js +0 -81
package/src/irdevice/other.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import https from 'https';
|
|
2
2
|
import crypto from 'crypto';
|
|
3
3
|
import { IncomingMessage } from 'http';
|
|
4
|
+
import superStringify from 'super-stringify';
|
|
4
5
|
import { SwitchBotPlatform } from '../platform';
|
|
5
6
|
import { irDevicesConfig, irdevice, HostDomain, DevicePath } from '../settings';
|
|
6
7
|
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
@@ -16,7 +17,6 @@ export class Others {
|
|
|
16
17
|
|
|
17
18
|
// Characteristic Values
|
|
18
19
|
Active!: CharacteristicValue;
|
|
19
|
-
ActiveCached!: CharacteristicValue;
|
|
20
20
|
|
|
21
21
|
// Config
|
|
22
22
|
deviceLogging!: string;
|
|
@@ -27,31 +27,30 @@ export class Others {
|
|
|
27
27
|
this.logs(device);
|
|
28
28
|
this.deviceType(device);
|
|
29
29
|
this.config(device);
|
|
30
|
-
|
|
31
|
-
this.Active = this.platform.Characteristic.Active.INACTIVE;
|
|
32
|
-
} else {
|
|
33
|
-
this.Active = this.accessory.context.Active;
|
|
34
|
-
}
|
|
30
|
+
this.context();
|
|
35
31
|
|
|
36
32
|
// set accessory information
|
|
37
33
|
accessory
|
|
38
34
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
39
35
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
40
36
|
.setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
|
|
41
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
37
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
38
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision(accessory, device))
|
|
39
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
40
|
+
.updateValue(this.FirmwareRevision(accessory, device));
|
|
42
41
|
|
|
43
42
|
// get the Television service if it exists, otherwise create a new Television service
|
|
44
43
|
// you can create multiple services for each accessory
|
|
45
44
|
if (this.otherDeviceType !== 'Fan') {
|
|
46
|
-
this.debugLog(
|
|
45
|
+
this.debugLog(`${this.device.remoteType}: ${accessory.displayName} Removing Fanv2 Service`);
|
|
47
46
|
|
|
48
47
|
if (this.otherDeviceType === undefined) {
|
|
49
|
-
this.errorLog(
|
|
48
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} No Device Type Set, deviceType: ${device.other?.deviceType}`);
|
|
50
49
|
}
|
|
51
50
|
this.fanService = this.accessory.getService(this.platform.Service.Fanv2);
|
|
52
51
|
accessory.removeService(this.fanService!);
|
|
53
52
|
} else if (!this.fanService && this.otherDeviceType === 'Fan') {
|
|
54
|
-
this.debugLog(
|
|
53
|
+
this.debugLog(`${this.device.remoteType}: ${accessory.displayName} Add Fanv2 Service`);
|
|
55
54
|
(this.fanService = this.accessory.getService(this.platform.Service.Fanv2) || this.accessory.addService(this.platform.Service.Fanv2)),
|
|
56
55
|
`${accessory.displayName} Fan`;
|
|
57
56
|
|
|
@@ -59,47 +58,37 @@ export class Others {
|
|
|
59
58
|
|
|
60
59
|
this.fanService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
|
|
61
60
|
} else {
|
|
62
|
-
this.debugLog(
|
|
61
|
+
this.debugLog(`${this.device.remoteType}: ${accessory.displayName} Fanv2 Service Not Added, deviceType: ${device.other?.deviceType}`);
|
|
63
62
|
}
|
|
64
63
|
}
|
|
65
64
|
|
|
66
65
|
async ActiveSet(value: CharacteristicValue): Promise<void> {
|
|
67
|
-
this.debugLog(
|
|
66
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${value}`);
|
|
67
|
+
this.Active = value;
|
|
68
|
+
this.accessory.context.Active = this.Active;
|
|
68
69
|
if (value) {
|
|
69
70
|
await this.pushOnChanges();
|
|
70
71
|
} else {
|
|
71
72
|
await this.pushOffChanges();
|
|
72
73
|
}
|
|
73
|
-
this.Active = value;
|
|
74
|
-
this.ActiveCached = this.Active;
|
|
75
|
-
this.accessory.context.Active = this.ActiveCached;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
async updateHomeKitCharacteristics(): Promise<void> {
|
|
79
|
-
if (this.Active === undefined) {
|
|
80
|
-
this.debugLog(`Other: ${this.accessory.displayName} Active: ${this.Active}`);
|
|
81
|
-
} else {
|
|
82
|
-
this.fanService?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
|
|
83
|
-
this.debugLog(`Other: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
|
|
84
|
-
}
|
|
85
74
|
}
|
|
86
75
|
|
|
87
76
|
/**
|
|
88
77
|
* Pushes the requested changes to the SwitchBot API
|
|
89
78
|
* deviceType commandType Command command parameter Description
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
79
|
+
* Other - "command" "turnOff" "default" = set to OFF state
|
|
80
|
+
* Other - "command" "turnOn" "default" = set to ON state
|
|
81
|
+
* Other - "command" "volumeAdd" "default" = volume up
|
|
82
|
+
* Other - "command" "volumeSub" "default" = volume down
|
|
83
|
+
* Other - "command" "channelAdd" "default" = next channel
|
|
84
|
+
* Other - "command" "channelSub" "default" = previous channel
|
|
96
85
|
*/
|
|
97
86
|
async pushOnChanges(): Promise<void> {
|
|
98
87
|
if (this.platform.config.options) {
|
|
99
88
|
if (this.device.other) {
|
|
100
89
|
if (this.device.other.commandOn) {
|
|
101
90
|
if (!this.Active) {
|
|
102
|
-
const body =
|
|
91
|
+
const body = superStringify({
|
|
103
92
|
'command': `${this.device.other.commandOn}`,
|
|
104
93
|
'parameter': 'default',
|
|
105
94
|
'commandType': 'customize',
|
|
@@ -107,13 +96,13 @@ export class Others {
|
|
|
107
96
|
await this.pushChanges(body);
|
|
108
97
|
}
|
|
109
98
|
} else {
|
|
110
|
-
this.errorLog(
|
|
99
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} On Command not set, commandOn: ${this.device.other.commandOn}`);
|
|
111
100
|
}
|
|
112
101
|
} else {
|
|
113
|
-
this.errorLog(
|
|
102
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} On Command not set, other: ${this.device.other}`);
|
|
114
103
|
}
|
|
115
104
|
} else {
|
|
116
|
-
this.errorLog(
|
|
105
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} On Command not set`);
|
|
117
106
|
}
|
|
118
107
|
}
|
|
119
108
|
|
|
@@ -122,7 +111,7 @@ export class Others {
|
|
|
122
111
|
if (this.device.other) {
|
|
123
112
|
if (this.device.other.commandOff) {
|
|
124
113
|
if (this.Active) {
|
|
125
|
-
const body =
|
|
114
|
+
const body = superStringify({
|
|
126
115
|
'command': `${this.device.other.commandOff}`,
|
|
127
116
|
'parameter': 'default',
|
|
128
117
|
'commandType': 'customize',
|
|
@@ -130,95 +119,106 @@ export class Others {
|
|
|
130
119
|
await this.pushChanges(body);
|
|
131
120
|
}
|
|
132
121
|
} else {
|
|
133
|
-
this.errorLog(
|
|
122
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Off Command not set, commandOff: ${this.device.other.commandOff}`);
|
|
134
123
|
}
|
|
135
124
|
} else {
|
|
136
|
-
this.errorLog(
|
|
125
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Off Command not set, other: ${this.device.other}`);
|
|
137
126
|
}
|
|
138
127
|
} else {
|
|
139
|
-
this.errorLog(
|
|
128
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Off Command not set.`);
|
|
140
129
|
}
|
|
141
130
|
}
|
|
142
131
|
|
|
143
132
|
async pushChanges(body): Promise<void> {
|
|
144
|
-
|
|
133
|
+
if (this.device.connectionType === 'OpenAPI') {
|
|
134
|
+
try {
|
|
145
135
|
// Make Push On request to the API
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
136
|
+
const t = Date.now();
|
|
137
|
+
const nonce = 'requestID';
|
|
138
|
+
const data = this.platform.config.credentials?.token + t + nonce;
|
|
139
|
+
const signTerm = crypto.createHmac('sha256', this.platform.config.credentials?.secret)
|
|
140
|
+
.update(Buffer.from(data, 'utf-8'))
|
|
141
|
+
.digest();
|
|
142
|
+
const sign = signTerm.toString('base64');
|
|
143
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} sign: ${sign}`);
|
|
144
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
|
|
145
|
+
const options = {
|
|
146
|
+
hostname: HostDomain,
|
|
147
|
+
port: 443,
|
|
148
|
+
path: `${DevicePath}/${this.device.deviceId}/commands`,
|
|
149
|
+
method: 'POST',
|
|
150
|
+
headers: {
|
|
151
|
+
'Authorization': this.platform.config.credentials?.token,
|
|
152
|
+
'sign': sign,
|
|
153
|
+
'nonce': nonce,
|
|
154
|
+
't': t,
|
|
155
|
+
'Content-Type': 'application/json',
|
|
156
|
+
'Content-Length': body.length,
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
const req = https.request(options, res => {
|
|
160
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushchanges statusCode: ${res.statusCode}`);
|
|
161
|
+
this.statusCode({ res });
|
|
162
|
+
res.on('data', d => {
|
|
163
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} d: ${d}`);
|
|
164
|
+
});
|
|
174
165
|
});
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
this.errorLog(
|
|
187
|
-
`Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
|
|
166
|
+
req.on('error', (e: any) => {
|
|
167
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} error message: ${e.message}`);
|
|
168
|
+
});
|
|
169
|
+
req.write(body);
|
|
170
|
+
req.end();
|
|
171
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushchanges: ${superStringify(req)}`);
|
|
172
|
+
this.updateHomeKitCharacteristics();
|
|
173
|
+
} catch (e: any) {
|
|
174
|
+
this.apiError(e);
|
|
175
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType} Connection,`
|
|
176
|
+
+ ` Error Message: ${superStringify(e.message)}`,
|
|
188
177
|
);
|
|
189
178
|
}
|
|
190
|
-
|
|
179
|
+
} else {
|
|
180
|
+
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
181
|
+
+ ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
async updateHomeKitCharacteristics(): Promise<void> {
|
|
186
|
+
if (this.Active === undefined) {
|
|
187
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.Active}`);
|
|
188
|
+
} else {
|
|
189
|
+
this.fanService?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
|
|
190
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
async statusCode({ res }: { res: IncomingMessage }): Promise<void> {
|
|
195
195
|
switch (res.statusCode) {
|
|
196
196
|
case 151:
|
|
197
|
-
this.errorLog(
|
|
197
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command not supported by this device type.`);
|
|
198
198
|
break;
|
|
199
199
|
case 152:
|
|
200
|
-
this.errorLog(
|
|
200
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device not found.`);
|
|
201
201
|
break;
|
|
202
202
|
case 160:
|
|
203
|
-
this.errorLog(
|
|
203
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command is not supported.`);
|
|
204
204
|
break;
|
|
205
205
|
case 161:
|
|
206
|
-
this.errorLog(
|
|
206
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline.`);
|
|
207
207
|
break;
|
|
208
208
|
case 171:
|
|
209
|
-
this.errorLog(
|
|
209
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
210
210
|
break;
|
|
211
211
|
case 190:
|
|
212
212
|
this.errorLog(
|
|
213
|
-
|
|
214
|
-
` with server, Or command: ${
|
|
213
|
+
`${this.device.remoteType}: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
|
|
214
|
+
` with server, Or command: ${superStringify(res)} format is invalid`,
|
|
215
215
|
);
|
|
216
216
|
break;
|
|
217
217
|
case 100:
|
|
218
|
-
this.debugLog(
|
|
218
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Command successfully sent.`);
|
|
219
219
|
break;
|
|
220
220
|
default:
|
|
221
|
-
this.debugLog(
|
|
221
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode.`);
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
224
|
|
|
@@ -231,10 +231,34 @@ export class Others {
|
|
|
231
231
|
if (device.other?.deviceType) {
|
|
232
232
|
this.otherDeviceType = this.accessory.context.deviceType = device.other.deviceType;
|
|
233
233
|
if (this.deviceLogging.includes('debug') || this.deviceLogging === 'standard') {
|
|
234
|
-
this.warnLog(
|
|
234
|
+
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Device Type: ${this.otherDeviceType}`);
|
|
235
235
|
}
|
|
236
236
|
} else {
|
|
237
|
-
this.errorLog(
|
|
237
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} No Device Type Set, deviceType: ${this.device.other?.deviceType}`);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
FirmwareRevision(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): string {
|
|
242
|
+
let FirmwareRevision: string;
|
|
243
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
244
|
+
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
|
|
245
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
246
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
247
|
+
if (accessory.context.FirmwareRevision) {
|
|
248
|
+
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
249
|
+
} else if (device.firmware) {
|
|
250
|
+
FirmwareRevision = device.firmware;
|
|
251
|
+
} else {
|
|
252
|
+
FirmwareRevision = this.platform.version;
|
|
253
|
+
}
|
|
254
|
+
return FirmwareRevision;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
async context() {
|
|
258
|
+
if (this.Active === undefined) {
|
|
259
|
+
this.Active = this.platform.Characteristic.Active.INACTIVE;
|
|
260
|
+
} else {
|
|
261
|
+
this.Active = this.accessory.context.Active;
|
|
238
262
|
}
|
|
239
263
|
}
|
|
240
264
|
|
|
@@ -246,24 +270,30 @@ export class Others {
|
|
|
246
270
|
if (device.logging !== undefined) {
|
|
247
271
|
config['logging'] = device.logging;
|
|
248
272
|
}
|
|
273
|
+
if (device.connectionType !== undefined) {
|
|
274
|
+
config['connectionType'] = device.connectionType;
|
|
275
|
+
}
|
|
276
|
+
if (device.external !== undefined) {
|
|
277
|
+
config['external'] = device.external;
|
|
278
|
+
}
|
|
249
279
|
if (Object.entries(config).length !== 0) {
|
|
250
|
-
this.infoLog(
|
|
280
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${superStringify(config)}`);
|
|
251
281
|
}
|
|
252
282
|
}
|
|
253
283
|
|
|
254
284
|
async logs(device: irdevice & irDevicesConfig): Promise<void> {
|
|
255
285
|
if (this.platform.debugMode) {
|
|
256
286
|
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
257
|
-
this.debugLog(
|
|
287
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
258
288
|
} else if (device.logging) {
|
|
259
289
|
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
260
|
-
this.debugLog(
|
|
290
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
261
291
|
} else if (this.platform.config.options?.logging) {
|
|
262
292
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
263
|
-
this.debugLog(
|
|
293
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
264
294
|
} else {
|
|
265
295
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
266
|
-
this.debugLog(
|
|
296
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
267
297
|
}
|
|
268
298
|
}
|
|
269
299
|
|
|
@@ -282,12 +312,28 @@ export class Others {
|
|
|
282
312
|
}
|
|
283
313
|
}
|
|
284
314
|
|
|
315
|
+
debugWarnLog(...log: any[]): void {
|
|
316
|
+
if (this.enablingDeviceLogging()) {
|
|
317
|
+
if (this.deviceLogging?.includes('debug')) {
|
|
318
|
+
this.platform.log.warn('[DEBUG]', String(...log));
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
285
323
|
errorLog(...log: any[]): void {
|
|
286
324
|
if (this.enablingDeviceLogging()) {
|
|
287
325
|
this.platform.log.error(String(...log));
|
|
288
326
|
}
|
|
289
327
|
}
|
|
290
328
|
|
|
329
|
+
debugErrorLog(...log: any[]): void {
|
|
330
|
+
if (this.enablingDeviceLogging()) {
|
|
331
|
+
if (this.deviceLogging?.includes('debug')) {
|
|
332
|
+
this.platform.log.error('[DEBUG]', String(...log));
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
291
337
|
debugLog(...log: any[]): void {
|
|
292
338
|
if (this.enablingDeviceLogging()) {
|
|
293
339
|
if (this.deviceLogging === 'debug') {
|