@switchbot/homebridge-switchbot 1.8.2 → 1.8.3-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/.eslintrc +1 -1
- package/.vscode/extensions.json +5 -0
- package/.vscode/settings.json +15 -0
- package/dist/devices/bots.d.ts +34 -35
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +241 -184
- 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 +145 -131
- package/dist/devices/colorbulb.js.map +1 -1
- package/dist/devices/contact.d.ts +27 -29
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +138 -115
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +29 -31
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +211 -176
- 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 +214 -189
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/meters.d.ts +30 -31
- package/dist/devices/meters.d.ts.map +1 -1
- package/dist/devices/meters.js +124 -100
- package/dist/devices/meters.js.map +1 -1
- package/dist/devices/motion.d.ts +25 -26
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +120 -102
- 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 +81 -63
- 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 +22 -3
- 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 +105 -79
- 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 +56 -42
- 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 +31 -27
- 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 +45 -38
- 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 +37 -33
- 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 +34 -29
- 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 +91 -76
- 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 +31 -27
- 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 +31 -27
- 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 +241 -172
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +1 -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 +72 -71
- package/src/devices/bots.ts +927 -442
- package/src/devices/colorbulb.ts +473 -246
- package/src/devices/contact.ts +381 -208
- package/src/devices/curtains.ts +613 -321
- package/src/devices/humidifiers.ts +594 -323
- package/src/devices/meters.ts +331 -186
- package/src/devices/motion.ts +327 -184
- package/src/devices/plugs.ts +175 -107
- package/src/index.ts +5 -5
- package/src/irdevices/airconditioners.ts +360 -149
- package/src/irdevices/airpurifiers.ts +178 -80
- package/src/irdevices/cameras.ts +109 -51
- package/src/irdevices/fans.ts +174 -77
- package/src/irdevices/lights.ts +110 -57
- package/src/irdevices/others.ts +137 -62
- package/src/irdevices/tvs.ts +249 -124
- package/src/irdevices/vacuumcleaners.ts +112 -52
- package/src/irdevices/waterheaters.ts +115 -53
- package/src/platform.ts +768 -357
- package/src/settings.ts +17 -23
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,13 +38,16 @@ 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)),
|
|
45
|
+
this.accessory.addService(this.platform.Service.Fanv2)),
|
|
46
|
+
`${accessory.displayName} Fan`;
|
|
46
47
|
this.service.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Fan`);
|
|
47
|
-
this.service
|
|
48
|
+
this.service
|
|
49
|
+
.getCharacteristic(this.platform.Characteristic.Active)
|
|
50
|
+
.onSet(this.ActiveSet.bind(this));
|
|
48
51
|
}
|
|
49
52
|
else {
|
|
50
53
|
this.debugLog(`Other: ${accessory.displayName} Fanv2 Service Not Added, deviceType: ${device.other?.deviceType}`);
|
|
@@ -87,8 +90,8 @@ class Others {
|
|
|
87
90
|
if (this.device.other.commandOn) {
|
|
88
91
|
if (this.Active) {
|
|
89
92
|
const payload = {
|
|
90
|
-
commandType:
|
|
91
|
-
parameter:
|
|
93
|
+
commandType: "customize",
|
|
94
|
+
parameter: "default",
|
|
92
95
|
command: `${this.device.other.commandOn}`,
|
|
93
96
|
};
|
|
94
97
|
await this.pushChanges(payload);
|
|
@@ -112,8 +115,8 @@ class Others {
|
|
|
112
115
|
if (this.device.other.commandOff) {
|
|
113
116
|
if (!this.Active) {
|
|
114
117
|
const payload = {
|
|
115
|
-
commandType:
|
|
116
|
-
parameter:
|
|
118
|
+
commandType: "customize",
|
|
119
|
+
parameter: "default",
|
|
117
120
|
command: `${this.device.other.commandOff}`,
|
|
118
121
|
};
|
|
119
122
|
await this.pushChanges(payload);
|
|
@@ -133,8 +136,8 @@ class Others {
|
|
|
133
136
|
}
|
|
134
137
|
async pushChanges(payload) {
|
|
135
138
|
try {
|
|
136
|
-
this.infoLog(`Other: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
|
|
137
|
-
|
|
139
|
+
this.infoLog(`Other: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
|
|
140
|
+
` parameter: ${payload.parameter}, commandType: ${payload.commandType}`);
|
|
138
141
|
// Make the API request
|
|
139
142
|
const push = await this.platform.axios.post(`${settings_1.DeviceURL}/${this.device.deviceId}/commands`, payload);
|
|
140
143
|
this.debugLog(`Other: ${this.accessory.displayName} pushChanges: ${push.data}`);
|
|
@@ -143,13 +146,13 @@ class Others {
|
|
|
143
146
|
}
|
|
144
147
|
catch (e) {
|
|
145
148
|
this.errorLog(`Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
|
|
146
|
-
if (this.deviceLogging ===
|
|
147
|
-
this.errorLog(`Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
148
|
-
|
|
149
|
+
if (this.deviceLogging === "debug") {
|
|
150
|
+
this.errorLog(`Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
|
|
151
|
+
` Error Message: ${JSON.stringify(e.message)}`);
|
|
149
152
|
}
|
|
150
153
|
if (this.platform.debugMode) {
|
|
151
|
-
this.errorLog(`Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
152
|
-
|
|
154
|
+
this.errorLog(`Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
|
|
155
|
+
` Error: ${JSON.stringify(e)}`);
|
|
153
156
|
}
|
|
154
157
|
this.apiError(e);
|
|
155
158
|
}
|
|
@@ -172,8 +175,8 @@ class Others {
|
|
|
172
175
|
this.errorLog(`Other: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
173
176
|
break;
|
|
174
177
|
case 190:
|
|
175
|
-
this.errorLog(`Other: ${this.accessory.displayName} Device internal error due to device states not synchronized`
|
|
176
|
-
|
|
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`);
|
|
177
180
|
break;
|
|
178
181
|
case 100:
|
|
179
182
|
this.debugLog(`Other: ${this.accessory.displayName} Command successfully sent.`);
|
|
@@ -188,8 +191,9 @@ class Others {
|
|
|
188
191
|
}
|
|
189
192
|
deviceType(device) {
|
|
190
193
|
if (device.other?.deviceType) {
|
|
191
|
-
this.otherDeviceType = this.accessory.context.deviceType =
|
|
192
|
-
|
|
194
|
+
this.otherDeviceType = this.accessory.context.deviceType =
|
|
195
|
+
device.other.deviceType;
|
|
196
|
+
if (this.deviceLogging === "debug" || this.deviceLogging === "standard") {
|
|
193
197
|
this.warnLog(`Other: ${this.accessory.displayName} Using Device Type: ${this.otherDeviceType}`);
|
|
194
198
|
}
|
|
195
199
|
}
|
|
@@ -203,7 +207,7 @@ class Others {
|
|
|
203
207
|
config = device.other;
|
|
204
208
|
}
|
|
205
209
|
if (device.logging !== undefined) {
|
|
206
|
-
config[
|
|
210
|
+
config["logging"] = device.logging;
|
|
207
211
|
}
|
|
208
212
|
if (Object.entries(config).length !== 0) {
|
|
209
213
|
this.warnLog(`Other: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
@@ -211,7 +215,7 @@ class Others {
|
|
|
211
215
|
}
|
|
212
216
|
logs(device) {
|
|
213
217
|
if (this.platform.debugMode) {
|
|
214
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
218
|
+
this.deviceLogging = this.accessory.context.logging = "debugMode";
|
|
215
219
|
this.debugLog(`Other: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
216
220
|
}
|
|
217
221
|
else if (device.logging) {
|
|
@@ -219,17 +223,18 @@ class Others {
|
|
|
219
223
|
this.debugLog(`Other: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
220
224
|
}
|
|
221
225
|
else if (this.platform.config.options?.logging) {
|
|
222
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
226
|
+
this.deviceLogging = this.accessory.context.logging =
|
|
227
|
+
this.platform.config.options?.logging;
|
|
223
228
|
this.debugLog(`Other: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
224
229
|
}
|
|
225
230
|
else {
|
|
226
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
231
|
+
this.deviceLogging = this.accessory.context.logging = "standard";
|
|
227
232
|
this.debugLog(`Other: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
228
233
|
}
|
|
229
234
|
}
|
|
230
235
|
/**
|
|
231
|
-
|
|
232
|
-
|
|
236
|
+
* Logging for Device
|
|
237
|
+
*/
|
|
233
238
|
infoLog(...log) {
|
|
234
239
|
if (this.enablingDeviceLogging()) {
|
|
235
240
|
this.platform.log.info(String(...log));
|
|
@@ -247,8 +252,8 @@ class Others {
|
|
|
247
252
|
}
|
|
248
253
|
debugLog(...log) {
|
|
249
254
|
if (this.enablingDeviceLogging()) {
|
|
250
|
-
if (this.deviceLogging ===
|
|
251
|
-
this.platform.log.info(
|
|
255
|
+
if (this.deviceLogging === "debug") {
|
|
256
|
+
this.platform.log.info("[DEBUG]", String(...log));
|
|
252
257
|
}
|
|
253
258
|
else {
|
|
254
259
|
this.platform.log.debug(String(...log));
|
|
@@ -256,7 +261,7 @@ class Others {
|
|
|
256
261
|
}
|
|
257
262
|
}
|
|
258
263
|
enablingDeviceLogging() {
|
|
259
|
-
return this.deviceLogging
|
|
264
|
+
return this.deviceLogging.includes("debug") || this.deviceLogging === "standard";
|
|
260
265
|
}
|
|
261
266
|
}
|
|
262
267
|
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,GA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C,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,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,aAAa,KAAK,UAAU,CAAC;IACnF,CAAC;CACF;AAtVD,wBAsVC"}
|
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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eAAe;IAiBzC,IAAI,CAAC,MAAM,EAAE,QAAQ,GAAG,eAAe;IAyBvC;;OAEG;IACH,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,33 +25,37 @@ 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)),
|
|
38
|
+
accessory.addService(this.platform.Service.Television)),
|
|
39
|
+
`${accessory.displayName} Speaker`;
|
|
39
40
|
break;
|
|
40
|
-
case
|
|
41
|
-
case
|
|
42
|
-
accessory.category =
|
|
41
|
+
case "IPTV":
|
|
42
|
+
case "DIY IPTV":
|
|
43
|
+
accessory.category =
|
|
44
|
+
36 /* TV_STREAMING_STICK */;
|
|
43
45
|
(this.service =
|
|
44
46
|
accessory.getService(this.platform.Service.Television) ||
|
|
45
|
-
accessory.addService(this.platform.Service.Television)),
|
|
47
|
+
accessory.addService(this.platform.Service.Television)),
|
|
48
|
+
`${accessory.displayName} Streaming Stick`;
|
|
46
49
|
break;
|
|
47
|
-
case
|
|
48
|
-
case
|
|
49
|
-
case
|
|
50
|
-
case
|
|
50
|
+
case "DVD":
|
|
51
|
+
case "DIY DVD":
|
|
52
|
+
case "Set Top Box":
|
|
53
|
+
case "DIY Set Top Box":
|
|
51
54
|
accessory.category = 35 /* TV_SET_TOP_BOX */;
|
|
52
55
|
(this.service =
|
|
53
56
|
accessory.getService(this.platform.Service.Television) ||
|
|
54
|
-
accessory.addService(this.platform.Service.Television)),
|
|
57
|
+
accessory.addService(this.platform.Service.Television)),
|
|
58
|
+
`${accessory.displayName} Set Top Box`;
|
|
55
59
|
break;
|
|
56
60
|
default:
|
|
57
61
|
accessory.category = 31 /* TELEVISION */;
|
|
@@ -59,7 +63,8 @@ class TV {
|
|
|
59
63
|
// you can create multiple services for each accessory
|
|
60
64
|
(this.service =
|
|
61
65
|
accessory.getService(this.platform.Service.Television) ||
|
|
62
|
-
accessory.addService(this.platform.Service.Television)),
|
|
66
|
+
accessory.addService(this.platform.Service.Television)),
|
|
67
|
+
`${accessory.displayName} TV`;
|
|
63
68
|
}
|
|
64
69
|
// To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
|
|
65
70
|
// when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
|
|
@@ -70,19 +75,26 @@ class TV {
|
|
|
70
75
|
// set sleep discovery characteristic
|
|
71
76
|
this.service.setCharacteristic(this.platform.Characteristic.SleepDiscoveryMode, this.platform.Characteristic.SleepDiscoveryMode.ALWAYS_DISCOVERABLE);
|
|
72
77
|
// handle on / off events using the Active characteristic
|
|
73
|
-
this.service
|
|
78
|
+
this.service
|
|
79
|
+
.getCharacteristic(this.platform.Characteristic.Active)
|
|
80
|
+
.onSet(this.ActiveSet.bind(this));
|
|
74
81
|
this.service.setCharacteristic(this.platform.Characteristic.ActiveIdentifier, 1);
|
|
75
82
|
// handle input source changes
|
|
76
|
-
this.service
|
|
83
|
+
this.service
|
|
84
|
+
.getCharacteristic(this.platform.Characteristic.ActiveIdentifier)
|
|
85
|
+
.onSet(this.ActiveIdentifierSet.bind(this));
|
|
77
86
|
// handle remote control input
|
|
78
|
-
this.service
|
|
87
|
+
this.service
|
|
88
|
+
.getCharacteristic(this.platform.Characteristic.RemoteKey)
|
|
89
|
+
.onSet(this.RemoteKeySet.bind(this));
|
|
79
90
|
/**
|
|
80
91
|
* Create a speaker service to allow volume control
|
|
81
92
|
*/
|
|
82
93
|
// create a new Television Speaker service
|
|
83
94
|
(this.speakerService =
|
|
84
95
|
accessory.getService(this.platform.Service.TelevisionSpeaker) ||
|
|
85
|
-
accessory.addService(this.platform.Service.TelevisionSpeaker)),
|
|
96
|
+
accessory.addService(this.platform.Service.TelevisionSpeaker)),
|
|
97
|
+
`${accessory.displayName} Speaker`;
|
|
86
98
|
this.speakerService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Speaker`);
|
|
87
99
|
this.speakerService
|
|
88
100
|
.setCharacteristic(this.platform.Characteristic.Active, this.platform.Characteristic.Active.ACTIVE)
|
|
@@ -195,8 +207,8 @@ class TV {
|
|
|
195
207
|
}
|
|
196
208
|
else {
|
|
197
209
|
this.service?.updateCharacteristic(this.platform.Characteristic.ActiveIdentifier, this.ActiveIdentifier);
|
|
198
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
199
|
-
|
|
210
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}` +
|
|
211
|
+
` updateCharacteristic ActiveIdentifier: ${this.ActiveIdentifier}`);
|
|
200
212
|
}
|
|
201
213
|
}
|
|
202
214
|
/**
|
|
@@ -210,99 +222,101 @@ class TV {
|
|
|
210
222
|
* TV: "command" "channelSub" "default" = previous channel
|
|
211
223
|
*/
|
|
212
224
|
async pushTvOnChanges() {
|
|
213
|
-
if (this.Active !==
|
|
225
|
+
if (this.Active !== this.platform.Characteristic.Active.ACTIVE) {
|
|
214
226
|
const payload = {
|
|
215
|
-
commandType:
|
|
216
|
-
parameter:
|
|
217
|
-
command:
|
|
227
|
+
commandType: "command",
|
|
228
|
+
parameter: "default",
|
|
229
|
+
command: "turnOn",
|
|
218
230
|
};
|
|
219
231
|
await this.pushTVChanges(payload);
|
|
220
232
|
}
|
|
221
233
|
}
|
|
222
234
|
async pushTvOffChanges() {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
235
|
+
if (this.Active !== this.platform.Characteristic.Active.INACTIVE) {
|
|
236
|
+
const payload = {
|
|
237
|
+
commandType: "command",
|
|
238
|
+
parameter: "default",
|
|
239
|
+
command: "turnOff",
|
|
240
|
+
};
|
|
241
|
+
await this.pushTVChanges(payload);
|
|
242
|
+
}
|
|
229
243
|
}
|
|
230
244
|
async pushOkChanges() {
|
|
231
245
|
const payload = {
|
|
232
|
-
commandType:
|
|
233
|
-
parameter:
|
|
234
|
-
command:
|
|
246
|
+
commandType: "command",
|
|
247
|
+
parameter: "default",
|
|
248
|
+
command: "Ok",
|
|
235
249
|
};
|
|
236
250
|
await this.pushTVChanges(payload);
|
|
237
251
|
}
|
|
238
252
|
async pushBackChanges() {
|
|
239
253
|
const payload = {
|
|
240
|
-
commandType:
|
|
241
|
-
parameter:
|
|
242
|
-
command:
|
|
254
|
+
commandType: "command",
|
|
255
|
+
parameter: "default",
|
|
256
|
+
command: "Back",
|
|
243
257
|
};
|
|
244
258
|
await this.pushTVChanges(payload);
|
|
245
259
|
}
|
|
246
260
|
async pushMenuChanges() {
|
|
247
261
|
const payload = {
|
|
248
|
-
commandType:
|
|
249
|
-
parameter:
|
|
250
|
-
command:
|
|
262
|
+
commandType: "command",
|
|
263
|
+
parameter: "default",
|
|
264
|
+
command: "Menu",
|
|
251
265
|
};
|
|
252
266
|
await this.pushTVChanges(payload);
|
|
253
267
|
}
|
|
254
268
|
async pushUpChanges() {
|
|
255
269
|
const payload = {
|
|
256
|
-
commandType:
|
|
257
|
-
parameter:
|
|
258
|
-
command:
|
|
270
|
+
commandType: "command",
|
|
271
|
+
parameter: "default",
|
|
272
|
+
command: "Up",
|
|
259
273
|
};
|
|
260
274
|
await this.pushTVChanges(payload);
|
|
261
275
|
}
|
|
262
276
|
async pushDownChanges() {
|
|
263
277
|
const payload = {
|
|
264
|
-
commandType:
|
|
265
|
-
parameter:
|
|
266
|
-
command:
|
|
278
|
+
commandType: "command",
|
|
279
|
+
parameter: "default",
|
|
280
|
+
command: "Down",
|
|
267
281
|
};
|
|
268
282
|
await this.pushTVChanges(payload);
|
|
269
283
|
}
|
|
270
284
|
async pushRightChanges() {
|
|
271
285
|
const payload = {
|
|
272
|
-
commandType:
|
|
273
|
-
parameter:
|
|
274
|
-
command:
|
|
286
|
+
commandType: "command",
|
|
287
|
+
parameter: "default",
|
|
288
|
+
command: "Right",
|
|
275
289
|
};
|
|
276
290
|
await this.pushTVChanges(payload);
|
|
277
291
|
}
|
|
278
292
|
async pushLeftChanges() {
|
|
279
293
|
const payload = {
|
|
280
|
-
commandType:
|
|
281
|
-
parameter:
|
|
282
|
-
command:
|
|
294
|
+
commandType: "command",
|
|
295
|
+
parameter: "default",
|
|
296
|
+
command: "Left",
|
|
283
297
|
};
|
|
284
298
|
await this.pushTVChanges(payload);
|
|
285
299
|
}
|
|
286
300
|
async pushVolumeUpChanges() {
|
|
287
301
|
const payload = {
|
|
288
|
-
commandType:
|
|
289
|
-
parameter:
|
|
290
|
-
command:
|
|
302
|
+
commandType: "command",
|
|
303
|
+
parameter: "default",
|
|
304
|
+
command: "volumeAdd",
|
|
291
305
|
};
|
|
292
306
|
await this.pushTVChanges(payload);
|
|
293
307
|
}
|
|
294
308
|
async pushVolumeDownChanges() {
|
|
295
309
|
const payload = {
|
|
296
|
-
commandType:
|
|
297
|
-
parameter:
|
|
298
|
-
command:
|
|
310
|
+
commandType: "command",
|
|
311
|
+
parameter: "default",
|
|
312
|
+
command: "volumeSub",
|
|
299
313
|
};
|
|
300
314
|
await this.pushTVChanges(payload);
|
|
301
315
|
}
|
|
302
316
|
async pushTVChanges(payload) {
|
|
303
317
|
try {
|
|
304
|
-
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
|
|
305
|
-
|
|
318
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
|
|
319
|
+
` parameter: ${payload.parameter}, commandType: ${payload.commandType}`);
|
|
306
320
|
// Make the API request
|
|
307
321
|
const push = await this.platform.axios.post(`${settings_1.DeviceURL}/${this.device.deviceId}/commands`, payload);
|
|
308
322
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges: ${push.data}`);
|
|
@@ -311,13 +325,13 @@ class TV {
|
|
|
311
325
|
}
|
|
312
326
|
catch (e) {
|
|
313
327
|
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
|
|
314
|
-
if (this.deviceLogging ===
|
|
315
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
316
|
-
|
|
328
|
+
if (this.deviceLogging === "debug") {
|
|
329
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
|
|
330
|
+
` Error Message: ${JSON.stringify(e.message)}`);
|
|
317
331
|
}
|
|
318
332
|
if (this.platform.debugMode) {
|
|
319
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
320
|
-
|
|
333
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
|
|
334
|
+
` Error: ${JSON.stringify(e)}`);
|
|
321
335
|
}
|
|
322
336
|
this.apiError(e);
|
|
323
337
|
}
|
|
@@ -340,9 +354,9 @@ class TV {
|
|
|
340
354
|
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
341
355
|
break;
|
|
342
356
|
case 190:
|
|
343
|
-
this.errorLog(`${this.device.remoteType}: `
|
|
344
|
-
|
|
345
|
-
|
|
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`);
|
|
346
360
|
break;
|
|
347
361
|
case 100:
|
|
348
362
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Command successfully sent.`);
|
|
@@ -362,7 +376,7 @@ class TV {
|
|
|
362
376
|
config = device.irtv;
|
|
363
377
|
}
|
|
364
378
|
if (device.logging !== undefined) {
|
|
365
|
-
config[
|
|
379
|
+
config["logging"] = device.logging;
|
|
366
380
|
}
|
|
367
381
|
if (Object.entries(config).length !== 0) {
|
|
368
382
|
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
@@ -370,7 +384,7 @@ class TV {
|
|
|
370
384
|
}
|
|
371
385
|
logs(device) {
|
|
372
386
|
if (this.platform.debugMode) {
|
|
373
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
387
|
+
this.deviceLogging = this.accessory.context.logging = "debugMode";
|
|
374
388
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
375
389
|
}
|
|
376
390
|
else if (device.logging) {
|
|
@@ -378,17 +392,18 @@ class TV {
|
|
|
378
392
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
379
393
|
}
|
|
380
394
|
else if (this.platform.config.options?.logging) {
|
|
381
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
395
|
+
this.deviceLogging = this.accessory.context.logging =
|
|
396
|
+
this.platform.config.options?.logging;
|
|
382
397
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
383
398
|
}
|
|
384
399
|
else {
|
|
385
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
400
|
+
this.deviceLogging = this.accessory.context.logging = "standard";
|
|
386
401
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
387
402
|
}
|
|
388
403
|
}
|
|
389
404
|
/**
|
|
390
|
-
|
|
391
|
-
|
|
405
|
+
* Logging for Device
|
|
406
|
+
*/
|
|
392
407
|
infoLog(...log) {
|
|
393
408
|
if (this.enablingDeviceLogging()) {
|
|
394
409
|
this.platform.log.info(String(...log));
|
|
@@ -406,8 +421,8 @@ class TV {
|
|
|
406
421
|
}
|
|
407
422
|
debugLog(...log) {
|
|
408
423
|
if (this.enablingDeviceLogging()) {
|
|
409
|
-
if (this.deviceLogging ===
|
|
410
|
-
this.platform.log.info(
|
|
424
|
+
if (this.deviceLogging === "debug") {
|
|
425
|
+
this.platform.log.info("[DEBUG]", String(...log));
|
|
411
426
|
}
|
|
412
427
|
else {
|
|
413
428
|
this.platform.log.debug(String(...log));
|
|
@@ -415,7 +430,7 @@ class TV {
|
|
|
415
430
|
}
|
|
416
431
|
}
|
|
417
432
|
enablingDeviceLogging() {
|
|
418
|
-
return this.deviceLogging
|
|
433
|
+
return this.deviceLogging.includes("debug") || this.deviceLogging === "standard";
|
|
419
434
|
}
|
|
420
435
|
}
|
|
421
436
|
exports.TV = TV;
|