@switchbot/homebridge-switchbot 1.8.3-beta.0 → 1.9.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/.eslintrc +1 -1
- package/.vscode/settings.json +1 -1
- package/CHANGELOG.md +8 -0
- package/config.schema.json +9 -0
- package/dist/devices/bots.d.ts +37 -34
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +196 -243
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/colorbulb.d.ts +50 -50
- package/dist/devices/colorbulb.d.ts.map +1 -1
- package/dist/devices/colorbulb.js +131 -145
- package/dist/devices/colorbulb.js.map +1 -1
- package/dist/devices/contact.d.ts +29 -27
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +115 -138
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +31 -29
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +176 -211
- package/dist/devices/curtains.js.map +1 -1
- package/dist/devices/humidifiers.d.ts +33 -33
- package/dist/devices/humidifiers.d.ts.map +1 -1
- package/dist/devices/humidifiers.js +189 -214
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/meters.d.ts +31 -30
- package/dist/devices/meters.d.ts.map +1 -1
- package/dist/devices/meters.js +100 -124
- package/dist/devices/meters.js.map +1 -1
- package/dist/devices/motion.d.ts +26 -25
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +102 -120
- package/dist/devices/motion.js.map +1 -1
- package/dist/devices/plugs.d.ts +23 -23
- package/dist/devices/plugs.d.ts.map +1 -1
- package/dist/devices/plugs.js +63 -81
- package/dist/devices/plugs.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -22
- package/dist/index.js.map +1 -1
- package/dist/irdevices/airconditioners.d.ts +6 -6
- package/dist/irdevices/airconditioners.d.ts.map +1 -1
- package/dist/irdevices/airconditioners.js +79 -105
- package/dist/irdevices/airconditioners.js.map +1 -1
- package/dist/irdevices/airpurifiers.d.ts +5 -5
- package/dist/irdevices/airpurifiers.d.ts.map +1 -1
- package/dist/irdevices/airpurifiers.js +42 -56
- package/dist/irdevices/airpurifiers.js.map +1 -1
- package/dist/irdevices/cameras.d.ts +5 -5
- package/dist/irdevices/cameras.d.ts.map +1 -1
- package/dist/irdevices/cameras.js +27 -31
- package/dist/irdevices/cameras.js.map +1 -1
- package/dist/irdevices/fans.d.ts +5 -5
- package/dist/irdevices/fans.d.ts.map +1 -1
- package/dist/irdevices/fans.js +38 -45
- package/dist/irdevices/fans.js.map +1 -1
- package/dist/irdevices/lights.d.ts +5 -5
- package/dist/irdevices/lights.d.ts.map +1 -1
- package/dist/irdevices/lights.js +33 -37
- package/dist/irdevices/lights.js.map +1 -1
- package/dist/irdevices/others.d.ts +5 -5
- package/dist/irdevices/others.d.ts.map +1 -1
- package/dist/irdevices/others.js +29 -34
- package/dist/irdevices/others.js.map +1 -1
- package/dist/irdevices/tvs.d.ts +5 -5
- package/dist/irdevices/tvs.d.ts.map +1 -1
- package/dist/irdevices/tvs.js +76 -91
- package/dist/irdevices/tvs.js.map +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts +5 -5
- package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
- package/dist/irdevices/vacuumcleaners.js +27 -31
- package/dist/irdevices/vacuumcleaners.js.map +1 -1
- package/dist/irdevices/waterheaters.d.ts +5 -5
- package/dist/irdevices/waterheaters.d.ts.map +1 -1
- package/dist/irdevices/waterheaters.js +27 -31
- package/dist/irdevices/waterheaters.js.map +1 -1
- package/dist/platform.d.ts +12 -12
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +172 -241
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +2 -1
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +4 -4
- package/dist/settings.js.map +1 -1
- package/package.json +71 -72
- package/src/devices/bots.ts +455 -929
- package/src/devices/colorbulb.ts +246 -473
- package/src/devices/contact.ts +208 -381
- package/src/devices/curtains.ts +321 -613
- package/src/devices/humidifiers.ts +323 -594
- package/src/devices/meters.ts +186 -331
- package/src/devices/motion.ts +184 -327
- package/src/devices/plugs.ts +107 -175
- package/src/index.ts +5 -5
- package/src/irdevices/airconditioners.ts +149 -360
- package/src/irdevices/airpurifiers.ts +80 -178
- package/src/irdevices/cameras.ts +51 -109
- package/src/irdevices/fans.ts +77 -174
- package/src/irdevices/lights.ts +57 -110
- package/src/irdevices/others.ts +62 -137
- package/src/irdevices/tvs.ts +124 -249
- package/src/irdevices/vacuumcleaners.ts +52 -112
- package/src/irdevices/waterheaters.ts +53 -115
- package/src/platform.ts +357 -768
- package/src/settings.ts +24 -17
package/dist/irdevices/others.js
CHANGED
|
@@ -25,12 +25,12 @@ class Others {
|
|
|
25
25
|
// set accessory information
|
|
26
26
|
accessory
|
|
27
27
|
.getService(this.platform.Service.AccessoryInformation)
|
|
28
|
-
.setCharacteristic(this.platform.Characteristic.Manufacturer,
|
|
28
|
+
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
29
29
|
.setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
|
|
30
30
|
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId);
|
|
31
31
|
// get the Television service if it exists, otherwise create a new Television service
|
|
32
32
|
// you can create multiple services for each accessory
|
|
33
|
-
if (this.otherDeviceType !==
|
|
33
|
+
if (this.otherDeviceType !== 'Fan') {
|
|
34
34
|
this.debugLog(`Other: ${accessory.displayName} Removing Fanv2 Service`);
|
|
35
35
|
if (this.otherDeviceType === undefined) {
|
|
36
36
|
this.errorLog(`Other: ${this.accessory.displayName} No Device Type Set, deviceType: ${device.other?.deviceType}`);
|
|
@@ -38,16 +38,13 @@ class Others {
|
|
|
38
38
|
this.service = this.accessory.getService(this.platform.Service.Fanv2);
|
|
39
39
|
accessory.removeService(this.service);
|
|
40
40
|
}
|
|
41
|
-
else if (!this.service && this.otherDeviceType ===
|
|
41
|
+
else if (!this.service && this.otherDeviceType === 'Fan') {
|
|
42
42
|
this.debugLog(`Other: ${accessory.displayName} Add Fanv2 Service`);
|
|
43
43
|
(this.service =
|
|
44
44
|
this.accessory.getService(this.platform.Service.Fanv2) ||
|
|
45
|
-
this.accessory.addService(this.platform.Service.Fanv2)),
|
|
46
|
-
`${accessory.displayName} Fan`;
|
|
45
|
+
this.accessory.addService(this.platform.Service.Fanv2)), `${accessory.displayName} Fan`;
|
|
47
46
|
this.service.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Fan`);
|
|
48
|
-
this.service
|
|
49
|
-
.getCharacteristic(this.platform.Characteristic.Active)
|
|
50
|
-
.onSet(this.ActiveSet.bind(this));
|
|
47
|
+
this.service.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
|
|
51
48
|
}
|
|
52
49
|
else {
|
|
53
50
|
this.debugLog(`Other: ${accessory.displayName} Fanv2 Service Not Added, deviceType: ${device.other?.deviceType}`);
|
|
@@ -90,8 +87,8 @@ class Others {
|
|
|
90
87
|
if (this.device.other.commandOn) {
|
|
91
88
|
if (this.Active) {
|
|
92
89
|
const payload = {
|
|
93
|
-
commandType:
|
|
94
|
-
parameter:
|
|
90
|
+
commandType: 'customize',
|
|
91
|
+
parameter: 'default',
|
|
95
92
|
command: `${this.device.other.commandOn}`,
|
|
96
93
|
};
|
|
97
94
|
await this.pushChanges(payload);
|
|
@@ -115,8 +112,8 @@ class Others {
|
|
|
115
112
|
if (this.device.other.commandOff) {
|
|
116
113
|
if (!this.Active) {
|
|
117
114
|
const payload = {
|
|
118
|
-
commandType:
|
|
119
|
-
parameter:
|
|
115
|
+
commandType: 'customize',
|
|
116
|
+
parameter: 'default',
|
|
120
117
|
command: `${this.device.other.commandOff}`,
|
|
121
118
|
};
|
|
122
119
|
await this.pushChanges(payload);
|
|
@@ -136,8 +133,8 @@ class Others {
|
|
|
136
133
|
}
|
|
137
134
|
async pushChanges(payload) {
|
|
138
135
|
try {
|
|
139
|
-
this.infoLog(`Other: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
|
|
140
|
-
` parameter: ${payload.parameter}, commandType: ${payload.commandType}`);
|
|
136
|
+
this.infoLog(`Other: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
|
|
137
|
+
+ ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`);
|
|
141
138
|
// Make the API request
|
|
142
139
|
const push = await this.platform.axios.post(`${settings_1.DeviceURL}/${this.device.deviceId}/commands`, payload);
|
|
143
140
|
this.debugLog(`Other: ${this.accessory.displayName} pushChanges: ${push.data}`);
|
|
@@ -146,13 +143,13 @@ class Others {
|
|
|
146
143
|
}
|
|
147
144
|
catch (e) {
|
|
148
145
|
this.errorLog(`Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
|
|
149
|
-
if (this.deviceLogging ===
|
|
150
|
-
this.errorLog(`Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
151
|
-
` Error Message: ${JSON.stringify(e.message)}`);
|
|
146
|
+
if (this.deviceLogging === 'debug') {
|
|
147
|
+
this.errorLog(`Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
148
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
152
149
|
}
|
|
153
150
|
if (this.platform.debugMode) {
|
|
154
|
-
this.errorLog(`Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
155
|
-
` Error: ${JSON.stringify(e)}`);
|
|
151
|
+
this.errorLog(`Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
152
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
156
153
|
}
|
|
157
154
|
this.apiError(e);
|
|
158
155
|
}
|
|
@@ -175,8 +172,8 @@ class Others {
|
|
|
175
172
|
this.errorLog(`Other: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
176
173
|
break;
|
|
177
174
|
case 190:
|
|
178
|
-
this.errorLog(`Other: ${this.accessory.displayName} Device internal error due to device states not synchronized`
|
|
179
|
-
` with server, Or command: ${JSON.stringify(push.data)} format is invalid`);
|
|
175
|
+
this.errorLog(`Other: ${this.accessory.displayName} Device internal error due to device states not synchronized`
|
|
176
|
+
+ ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`);
|
|
180
177
|
break;
|
|
181
178
|
case 100:
|
|
182
179
|
this.debugLog(`Other: ${this.accessory.displayName} Command successfully sent.`);
|
|
@@ -191,9 +188,8 @@ class Others {
|
|
|
191
188
|
}
|
|
192
189
|
deviceType(device) {
|
|
193
190
|
if (device.other?.deviceType) {
|
|
194
|
-
this.otherDeviceType = this.accessory.context.deviceType =
|
|
195
|
-
|
|
196
|
-
if (this.deviceLogging === "debug" || this.deviceLogging === "standard") {
|
|
191
|
+
this.otherDeviceType = this.accessory.context.deviceType = device.other.deviceType;
|
|
192
|
+
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
197
193
|
this.warnLog(`Other: ${this.accessory.displayName} Using Device Type: ${this.otherDeviceType}`);
|
|
198
194
|
}
|
|
199
195
|
}
|
|
@@ -207,7 +203,7 @@ class Others {
|
|
|
207
203
|
config = device.other;
|
|
208
204
|
}
|
|
209
205
|
if (device.logging !== undefined) {
|
|
210
|
-
config[
|
|
206
|
+
config['logging'] = device.logging;
|
|
211
207
|
}
|
|
212
208
|
if (Object.entries(config).length !== 0) {
|
|
213
209
|
this.warnLog(`Other: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
@@ -215,7 +211,7 @@ class Others {
|
|
|
215
211
|
}
|
|
216
212
|
logs(device) {
|
|
217
213
|
if (this.platform.debugMode) {
|
|
218
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
214
|
+
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
219
215
|
this.debugLog(`Other: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
220
216
|
}
|
|
221
217
|
else if (device.logging) {
|
|
@@ -223,18 +219,17 @@ class Others {
|
|
|
223
219
|
this.debugLog(`Other: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
224
220
|
}
|
|
225
221
|
else if (this.platform.config.options?.logging) {
|
|
226
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
227
|
-
this.platform.config.options?.logging;
|
|
222
|
+
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
228
223
|
this.debugLog(`Other: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
229
224
|
}
|
|
230
225
|
else {
|
|
231
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
226
|
+
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
232
227
|
this.debugLog(`Other: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
233
228
|
}
|
|
234
229
|
}
|
|
235
230
|
/**
|
|
236
|
-
|
|
237
|
-
|
|
231
|
+
* Logging for Device
|
|
232
|
+
*/
|
|
238
233
|
infoLog(...log) {
|
|
239
234
|
if (this.enablingDeviceLogging()) {
|
|
240
235
|
this.platform.log.info(String(...log));
|
|
@@ -252,8 +247,8 @@ class Others {
|
|
|
252
247
|
}
|
|
253
248
|
debugLog(...log) {
|
|
254
249
|
if (this.enablingDeviceLogging()) {
|
|
255
|
-
if (this.deviceLogging ===
|
|
256
|
-
this.platform.log.info(
|
|
250
|
+
if (this.deviceLogging === 'debug') {
|
|
251
|
+
this.platform.log.info('[DEBUG]', String(...log));
|
|
257
252
|
}
|
|
258
253
|
else {
|
|
259
254
|
this.platform.log.debug(String(...log));
|
|
@@ -261,7 +256,7 @@ class Others {
|
|
|
261
256
|
}
|
|
262
257
|
}
|
|
263
258
|
enablingDeviceLogging() {
|
|
264
|
-
return this.deviceLogging
|
|
259
|
+
return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
|
|
265
260
|
}
|
|
266
261
|
}
|
|
267
262
|
exports.Others = Others;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"others.js","sourceRoot":"","sources":["../../src/irdevices/others.ts"],"names":[],"mappings":";;;AAEA,0CAA4E;AAG5E;;;;GAIG;AACH,MAAa,MAAM;IAYjB,YACmB,QAA2B,EACpC,SAA4B,EAC7B,MAAkC;QAFxB,aAAQ,GAAR,QAAQ,CAAmB;QACpC,cAAS,GAAT,SAAS,CAAmB;QAC7B,WAAM,GAAN,MAAM,CAA4B;QAEzC,uBAAuB;QACvB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACxB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACpB,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE;YAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC;SAC5D;aAAM;YACL,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC;SAC7C;QAED,4BAA4B;QAC5B,SAAS;aACN,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,oBAAoB,CAAE;aACvD,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,YAAY,EAAE,WAAW,CAAC;aACzE,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC;aACxE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"others.js","sourceRoot":"","sources":["../../src/irdevices/others.ts"],"names":[],"mappings":";;;AAEA,0CAA4E;AAG5E;;;;GAIG;AACH,MAAa,MAAM;IAYjB,YACmB,QAA2B,EACpC,SAA4B,EAC7B,MAAkC;QAFxB,aAAQ,GAAR,QAAQ,CAAmB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IAED,QAAQ,CAAC,GAAG,GAAU;QACpB,IAAI,IAAI,CAAC,qBAAqB,EAAE,EAAE;YAChC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;SACzC;IACH,CAAC;IAED,QAAQ,CAAC,GAAG,GAAU;QACpB,IAAI,IAAI,CAAC,qBAAqB,EAAE,EAAE;YAChC,IAAI,IAAI,CAAC,aAAa,KAAK,OAAO,EAAE;gBAClC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;aACnD;iBAAM;gBACL,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;aACzC;SACF;IACH,CAAC;IAED,qBAAqB;QACnB,OAAO,IAAI,CAAC,aAAa,KAAK,OAAO,IAAI,IAAI,CAAC,aAAa,KAAK,UAAU,CAAC;IAC7E,CAAC;CACF;AA3QD,wBA2QC"}
|
package/dist/irdevices/tvs.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SwitchBotPlatform } from
|
|
2
|
-
import { CharacteristicValue, PlatformAccessory, Service } from
|
|
3
|
-
import { irdevice, deviceStatusResponse, irDevicesConfig, payload } from
|
|
1
|
+
import { SwitchBotPlatform } from '../platform';
|
|
2
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
3
|
+
import { irdevice, deviceStatusResponse, irDevicesConfig, payload } from '../settings';
|
|
4
4
|
/**
|
|
5
5
|
* Platform Accessory
|
|
6
6
|
* An instance of this class is created for each accessory your platform registers
|
|
@@ -50,8 +50,8 @@ export declare class TV {
|
|
|
50
50
|
config(device: irdevice & irDevicesConfig): void;
|
|
51
51
|
logs(device: irdevice & irDevicesConfig): void;
|
|
52
52
|
/**
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
* Logging for Device
|
|
54
|
+
*/
|
|
55
55
|
infoLog(...log: any[]): void;
|
|
56
56
|
warnLog(...log: any[]): void;
|
|
57
57
|
errorLog(...log: any[]): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tvs.d.ts","sourceRoot":"","sources":["../../src/irdevices/tvs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,
|
|
1
|
+
{"version":3,"file":"tvs.d.ts","sourceRoot":"","sources":["../../src/irdevices/tvs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAa,QAAQ,EAAE,oBAAoB,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAElG;;;;GAIG;AACH,qBAAa,EAAE;IAiBX,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,SAAS;IACV,MAAM,EAAE,QAAQ,GAAG,eAAe;IAjB3C,OAAO,EAAG,OAAO,CAAC;IAClB,cAAc,EAAE,OAAO,CAAC;IAGxB,MAAM,EAAG,mBAAmB,CAAC;IAC7B,YAAY,EAAG,mBAAmB,CAAC;IACnC,gBAAgB,EAAG,mBAAmB,CAAC;IAGvC,YAAY,EAAG,oBAAoB,CAAC;IAGpC,aAAa,EAAG,MAAM,CAAC;gBAGJ,QAAQ,EAAE,iBAAiB,EACpC,SAAS,EAAE,iBAAiB,EAC7B,MAAM,EAAE,QAAQ,GAAG,eAAe;IAsG3C,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,YAAY;IAgEpB,OAAO,CAAC,mBAAmB;IAK3B,OAAO,CAAC,SAAS;IAcjB,OAAO,CAAC,4BAA4B;IAgBpC;;;;;;;;;OASG;IACG,eAAe;IAWf,gBAAgB;IAShB,aAAa;IASb,eAAe;IASf,eAAe;IASf,aAAa;IASb,eAAe;IASf,gBAAgB;IAShB,eAAe;IASf,mBAAmB;IASnB,qBAAqB;IASd,aAAa,CAAC,OAAO,EAAE,OAAO;IAyB3C,OAAO,CAAC,UAAU;IA8BX,QAAQ,CAAC,CAAC,EAAE,GAAG;IAMtB,MAAM,CAAC,MAAM,EAAE,QAAQ,GAAG,eAAe;IAazC,IAAI,CAAC,MAAM,EAAE,QAAQ,GAAG,eAAe;IAgBvC;;KAEC;IACD,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE;IAMrB,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE;IAMrB,QAAQ,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE;IAMtB,QAAQ,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE;IAUtB,qBAAqB,IAAI,OAAO;CAGjC"}
|
package/dist/irdevices/tvs.js
CHANGED
|
@@ -25,37 +25,33 @@ class TV {
|
|
|
25
25
|
accessory
|
|
26
26
|
.getService(this.platform.Service.AccessoryInformation)
|
|
27
27
|
.setCharacteristic(this.platform.Characteristic.Name, `${device.deviceName} ${device.remoteType}`)
|
|
28
|
-
.setCharacteristic(this.platform.Characteristic.Manufacturer,
|
|
28
|
+
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
29
29
|
.setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
|
|
30
30
|
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId);
|
|
31
31
|
// set the accessory category
|
|
32
32
|
switch (device.remoteType) {
|
|
33
|
-
case
|
|
34
|
-
case
|
|
33
|
+
case 'Speaker':
|
|
34
|
+
case 'DIY Speaker':
|
|
35
35
|
accessory.category = 26 /* SPEAKER */;
|
|
36
36
|
(this.service =
|
|
37
37
|
accessory.getService(this.platform.Service.Television) ||
|
|
38
|
-
accessory.addService(this.platform.Service.Television)),
|
|
39
|
-
`${accessory.displayName} Speaker`;
|
|
38
|
+
accessory.addService(this.platform.Service.Television)), `${accessory.displayName} Speaker`;
|
|
40
39
|
break;
|
|
41
|
-
case
|
|
42
|
-
case
|
|
43
|
-
accessory.category =
|
|
44
|
-
36 /* TV_STREAMING_STICK */;
|
|
40
|
+
case 'IPTV':
|
|
41
|
+
case 'DIY IPTV':
|
|
42
|
+
accessory.category = 36 /* TV_STREAMING_STICK */;
|
|
45
43
|
(this.service =
|
|
46
44
|
accessory.getService(this.platform.Service.Television) ||
|
|
47
|
-
accessory.addService(this.platform.Service.Television)),
|
|
48
|
-
`${accessory.displayName} Streaming Stick`;
|
|
45
|
+
accessory.addService(this.platform.Service.Television)), `${accessory.displayName} Streaming Stick`;
|
|
49
46
|
break;
|
|
50
|
-
case
|
|
51
|
-
case
|
|
52
|
-
case
|
|
53
|
-
case
|
|
47
|
+
case 'DVD':
|
|
48
|
+
case 'DIY DVD':
|
|
49
|
+
case 'Set Top Box':
|
|
50
|
+
case 'DIY Set Top Box':
|
|
54
51
|
accessory.category = 35 /* TV_SET_TOP_BOX */;
|
|
55
52
|
(this.service =
|
|
56
53
|
accessory.getService(this.platform.Service.Television) ||
|
|
57
|
-
accessory.addService(this.platform.Service.Television)),
|
|
58
|
-
`${accessory.displayName} Set Top Box`;
|
|
54
|
+
accessory.addService(this.platform.Service.Television)), `${accessory.displayName} Set Top Box`;
|
|
59
55
|
break;
|
|
60
56
|
default:
|
|
61
57
|
accessory.category = 31 /* TELEVISION */;
|
|
@@ -63,8 +59,7 @@ class TV {
|
|
|
63
59
|
// you can create multiple services for each accessory
|
|
64
60
|
(this.service =
|
|
65
61
|
accessory.getService(this.platform.Service.Television) ||
|
|
66
|
-
accessory.addService(this.platform.Service.Television)),
|
|
67
|
-
`${accessory.displayName} TV`;
|
|
62
|
+
accessory.addService(this.platform.Service.Television)), `${accessory.displayName} TV`;
|
|
68
63
|
}
|
|
69
64
|
// To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
|
|
70
65
|
// when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
|
|
@@ -75,26 +70,19 @@ class TV {
|
|
|
75
70
|
// set sleep discovery characteristic
|
|
76
71
|
this.service.setCharacteristic(this.platform.Characteristic.SleepDiscoveryMode, this.platform.Characteristic.SleepDiscoveryMode.ALWAYS_DISCOVERABLE);
|
|
77
72
|
// handle on / off events using the Active characteristic
|
|
78
|
-
this.service
|
|
79
|
-
.getCharacteristic(this.platform.Characteristic.Active)
|
|
80
|
-
.onSet(this.ActiveSet.bind(this));
|
|
73
|
+
this.service.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
|
|
81
74
|
this.service.setCharacteristic(this.platform.Characteristic.ActiveIdentifier, 1);
|
|
82
75
|
// handle input source changes
|
|
83
|
-
this.service
|
|
84
|
-
.getCharacteristic(this.platform.Characteristic.ActiveIdentifier)
|
|
85
|
-
.onSet(this.ActiveIdentifierSet.bind(this));
|
|
76
|
+
this.service.getCharacteristic(this.platform.Characteristic.ActiveIdentifier).onSet(this.ActiveIdentifierSet.bind(this));
|
|
86
77
|
// handle remote control input
|
|
87
|
-
this.service
|
|
88
|
-
.getCharacteristic(this.platform.Characteristic.RemoteKey)
|
|
89
|
-
.onSet(this.RemoteKeySet.bind(this));
|
|
78
|
+
this.service.getCharacteristic(this.platform.Characteristic.RemoteKey).onSet(this.RemoteKeySet.bind(this));
|
|
90
79
|
/**
|
|
91
80
|
* Create a speaker service to allow volume control
|
|
92
81
|
*/
|
|
93
82
|
// create a new Television Speaker service
|
|
94
83
|
(this.speakerService =
|
|
95
84
|
accessory.getService(this.platform.Service.TelevisionSpeaker) ||
|
|
96
|
-
accessory.addService(this.platform.Service.TelevisionSpeaker)),
|
|
97
|
-
`${accessory.displayName} Speaker`;
|
|
85
|
+
accessory.addService(this.platform.Service.TelevisionSpeaker)), `${accessory.displayName} Speaker`;
|
|
98
86
|
this.speakerService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Speaker`);
|
|
99
87
|
this.speakerService
|
|
100
88
|
.setCharacteristic(this.platform.Characteristic.Active, this.platform.Characteristic.Active.ACTIVE)
|
|
@@ -207,8 +195,8 @@ class TV {
|
|
|
207
195
|
}
|
|
208
196
|
else {
|
|
209
197
|
this.service?.updateCharacteristic(this.platform.Characteristic.ActiveIdentifier, this.ActiveIdentifier);
|
|
210
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
211
|
-
` updateCharacteristic ActiveIdentifier: ${this.ActiveIdentifier}`);
|
|
198
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
199
|
+
+ ` updateCharacteristic ActiveIdentifier: ${this.ActiveIdentifier}`);
|
|
212
200
|
}
|
|
213
201
|
}
|
|
214
202
|
/**
|
|
@@ -222,101 +210,99 @@ class TV {
|
|
|
222
210
|
* TV: "command" "channelSub" "default" = previous channel
|
|
223
211
|
*/
|
|
224
212
|
async pushTvOnChanges() {
|
|
225
|
-
if (this.Active !==
|
|
213
|
+
if (this.Active !== 1) {
|
|
226
214
|
const payload = {
|
|
227
|
-
commandType:
|
|
228
|
-
parameter:
|
|
229
|
-
command:
|
|
215
|
+
commandType: 'command',
|
|
216
|
+
parameter: 'default',
|
|
217
|
+
command: 'turnOn',
|
|
230
218
|
};
|
|
231
219
|
await this.pushTVChanges(payload);
|
|
232
220
|
}
|
|
233
221
|
}
|
|
234
222
|
async pushTvOffChanges() {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
await this.pushTVChanges(payload);
|
|
242
|
-
}
|
|
223
|
+
const payload = {
|
|
224
|
+
commandType: 'command',
|
|
225
|
+
parameter: 'default',
|
|
226
|
+
command: 'turnOff',
|
|
227
|
+
};
|
|
228
|
+
await this.pushTVChanges(payload);
|
|
243
229
|
}
|
|
244
230
|
async pushOkChanges() {
|
|
245
231
|
const payload = {
|
|
246
|
-
commandType:
|
|
247
|
-
parameter:
|
|
248
|
-
command:
|
|
232
|
+
commandType: 'command',
|
|
233
|
+
parameter: 'default',
|
|
234
|
+
command: 'Ok',
|
|
249
235
|
};
|
|
250
236
|
await this.pushTVChanges(payload);
|
|
251
237
|
}
|
|
252
238
|
async pushBackChanges() {
|
|
253
239
|
const payload = {
|
|
254
|
-
commandType:
|
|
255
|
-
parameter:
|
|
256
|
-
command:
|
|
240
|
+
commandType: 'command',
|
|
241
|
+
parameter: 'default',
|
|
242
|
+
command: 'Back',
|
|
257
243
|
};
|
|
258
244
|
await this.pushTVChanges(payload);
|
|
259
245
|
}
|
|
260
246
|
async pushMenuChanges() {
|
|
261
247
|
const payload = {
|
|
262
|
-
commandType:
|
|
263
|
-
parameter:
|
|
264
|
-
command:
|
|
248
|
+
commandType: 'command',
|
|
249
|
+
parameter: 'default',
|
|
250
|
+
command: 'Menu',
|
|
265
251
|
};
|
|
266
252
|
await this.pushTVChanges(payload);
|
|
267
253
|
}
|
|
268
254
|
async pushUpChanges() {
|
|
269
255
|
const payload = {
|
|
270
|
-
commandType:
|
|
271
|
-
parameter:
|
|
272
|
-
command:
|
|
256
|
+
commandType: 'command',
|
|
257
|
+
parameter: 'default',
|
|
258
|
+
command: 'Up',
|
|
273
259
|
};
|
|
274
260
|
await this.pushTVChanges(payload);
|
|
275
261
|
}
|
|
276
262
|
async pushDownChanges() {
|
|
277
263
|
const payload = {
|
|
278
|
-
commandType:
|
|
279
|
-
parameter:
|
|
280
|
-
command:
|
|
264
|
+
commandType: 'command',
|
|
265
|
+
parameter: 'default',
|
|
266
|
+
command: 'Down',
|
|
281
267
|
};
|
|
282
268
|
await this.pushTVChanges(payload);
|
|
283
269
|
}
|
|
284
270
|
async pushRightChanges() {
|
|
285
271
|
const payload = {
|
|
286
|
-
commandType:
|
|
287
|
-
parameter:
|
|
288
|
-
command:
|
|
272
|
+
commandType: 'command',
|
|
273
|
+
parameter: 'default',
|
|
274
|
+
command: 'Right',
|
|
289
275
|
};
|
|
290
276
|
await this.pushTVChanges(payload);
|
|
291
277
|
}
|
|
292
278
|
async pushLeftChanges() {
|
|
293
279
|
const payload = {
|
|
294
|
-
commandType:
|
|
295
|
-
parameter:
|
|
296
|
-
command:
|
|
280
|
+
commandType: 'command',
|
|
281
|
+
parameter: 'default',
|
|
282
|
+
command: 'Left',
|
|
297
283
|
};
|
|
298
284
|
await this.pushTVChanges(payload);
|
|
299
285
|
}
|
|
300
286
|
async pushVolumeUpChanges() {
|
|
301
287
|
const payload = {
|
|
302
|
-
commandType:
|
|
303
|
-
parameter:
|
|
304
|
-
command:
|
|
288
|
+
commandType: 'command',
|
|
289
|
+
parameter: 'default',
|
|
290
|
+
command: 'volumeAdd',
|
|
305
291
|
};
|
|
306
292
|
await this.pushTVChanges(payload);
|
|
307
293
|
}
|
|
308
294
|
async pushVolumeDownChanges() {
|
|
309
295
|
const payload = {
|
|
310
|
-
commandType:
|
|
311
|
-
parameter:
|
|
312
|
-
command:
|
|
296
|
+
commandType: 'command',
|
|
297
|
+
parameter: 'default',
|
|
298
|
+
command: 'volumeSub',
|
|
313
299
|
};
|
|
314
300
|
await this.pushTVChanges(payload);
|
|
315
301
|
}
|
|
316
302
|
async pushTVChanges(payload) {
|
|
317
303
|
try {
|
|
318
|
-
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
|
|
319
|
-
` parameter: ${payload.parameter}, commandType: ${payload.commandType}`);
|
|
304
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
|
|
305
|
+
+ ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`);
|
|
320
306
|
// Make the API request
|
|
321
307
|
const push = await this.platform.axios.post(`${settings_1.DeviceURL}/${this.device.deviceId}/commands`, payload);
|
|
322
308
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges: ${push.data}`);
|
|
@@ -325,13 +311,13 @@ class TV {
|
|
|
325
311
|
}
|
|
326
312
|
catch (e) {
|
|
327
313
|
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
|
|
328
|
-
if (this.deviceLogging ===
|
|
329
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
330
|
-
` Error Message: ${JSON.stringify(e.message)}`);
|
|
314
|
+
if (this.deviceLogging === 'debug') {
|
|
315
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
316
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
331
317
|
}
|
|
332
318
|
if (this.platform.debugMode) {
|
|
333
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
334
|
-
` Error: ${JSON.stringify(e)}`);
|
|
319
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
320
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
335
321
|
}
|
|
336
322
|
this.apiError(e);
|
|
337
323
|
}
|
|
@@ -354,9 +340,9 @@ class TV {
|
|
|
354
340
|
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
355
341
|
break;
|
|
356
342
|
case 190:
|
|
357
|
-
this.errorLog(`${this.device.remoteType}: `
|
|
358
|
-
`${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
|
|
359
|
-
` Or command: ${JSON.stringify(push.data)} format is invalid`);
|
|
343
|
+
this.errorLog(`${this.device.remoteType}: `
|
|
344
|
+
+ `${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
|
|
345
|
+
+ ` Or command: ${JSON.stringify(push.data)} format is invalid`);
|
|
360
346
|
break;
|
|
361
347
|
case 100:
|
|
362
348
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Command successfully sent.`);
|
|
@@ -376,7 +362,7 @@ class TV {
|
|
|
376
362
|
config = device.irtv;
|
|
377
363
|
}
|
|
378
364
|
if (device.logging !== undefined) {
|
|
379
|
-
config[
|
|
365
|
+
config['logging'] = device.logging;
|
|
380
366
|
}
|
|
381
367
|
if (Object.entries(config).length !== 0) {
|
|
382
368
|
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
@@ -384,7 +370,7 @@ class TV {
|
|
|
384
370
|
}
|
|
385
371
|
logs(device) {
|
|
386
372
|
if (this.platform.debugMode) {
|
|
387
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
373
|
+
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
388
374
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
389
375
|
}
|
|
390
376
|
else if (device.logging) {
|
|
@@ -392,18 +378,17 @@ class TV {
|
|
|
392
378
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
393
379
|
}
|
|
394
380
|
else if (this.platform.config.options?.logging) {
|
|
395
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
396
|
-
this.platform.config.options?.logging;
|
|
381
|
+
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
397
382
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
398
383
|
}
|
|
399
384
|
else {
|
|
400
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
385
|
+
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
401
386
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
402
387
|
}
|
|
403
388
|
}
|
|
404
389
|
/**
|
|
405
|
-
|
|
406
|
-
|
|
390
|
+
* Logging for Device
|
|
391
|
+
*/
|
|
407
392
|
infoLog(...log) {
|
|
408
393
|
if (this.enablingDeviceLogging()) {
|
|
409
394
|
this.platform.log.info(String(...log));
|
|
@@ -421,8 +406,8 @@ class TV {
|
|
|
421
406
|
}
|
|
422
407
|
debugLog(...log) {
|
|
423
408
|
if (this.enablingDeviceLogging()) {
|
|
424
|
-
if (this.deviceLogging ===
|
|
425
|
-
this.platform.log.info(
|
|
409
|
+
if (this.deviceLogging === 'debug') {
|
|
410
|
+
this.platform.log.info('[DEBUG]', String(...log));
|
|
426
411
|
}
|
|
427
412
|
else {
|
|
428
413
|
this.platform.log.debug(String(...log));
|
|
@@ -430,7 +415,7 @@ class TV {
|
|
|
430
415
|
}
|
|
431
416
|
}
|
|
432
417
|
enablingDeviceLogging() {
|
|
433
|
-
return this.deviceLogging
|
|
418
|
+
return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
|
|
434
419
|
}
|
|
435
420
|
}
|
|
436
421
|
exports.TV = TV;
|