@switchbot/homebridge-switchbot 1.8.3-beta.0 → 1.10.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.
Files changed (122) hide show
  1. package/.eslintrc +14 -45
  2. package/.github/ISSUE_TEMPLATE/bug-report.yml +3 -3
  3. package/.github/ISSUE_TEMPLATE/feature-request.yml +2 -2
  4. package/.github/ISSUE_TEMPLATE/support-request.yml +3 -3
  5. package/.github/labeler.yml +1 -1
  6. package/.github/workflows/codeql-analysis.yml +29 -29
  7. package/.github/workflows/nodejs-beta.yml +1 -1
  8. package/.github/workflows/prerelease-beta.js +1 -1
  9. package/.github/workflows/stale.yml +1 -1
  10. package/.prettierrc +9 -0
  11. package/.vscode/extensions.json +2 -4
  12. package/.vscode/settings.json +14 -2
  13. package/CHANGELOG.md +16 -0
  14. package/README.md +100 -99
  15. package/SECURITY.md +2 -2
  16. package/config.schema.json +17 -0
  17. package/dist/devices/bots.d.ts +35 -32
  18. package/dist/devices/bots.d.ts.map +1 -1
  19. package/dist/devices/bots.js +168 -210
  20. package/dist/devices/bots.js.map +1 -1
  21. package/dist/devices/colorbulb.d.ts +35 -35
  22. package/dist/devices/colorbulb.d.ts.map +1 -1
  23. package/dist/devices/colorbulb.js +83 -108
  24. package/dist/devices/colorbulb.js.map +1 -1
  25. package/dist/devices/contact.d.ts +27 -25
  26. package/dist/devices/contact.d.ts.map +1 -1
  27. package/dist/devices/contact.js +110 -131
  28. package/dist/devices/contact.js.map +1 -1
  29. package/dist/devices/curtains.d.ts +29 -27
  30. package/dist/devices/curtains.d.ts.map +1 -1
  31. package/dist/devices/curtains.js +147 -182
  32. package/dist/devices/curtains.js.map +1 -1
  33. package/dist/devices/humidifiers.d.ts +31 -31
  34. package/dist/devices/humidifiers.d.ts.map +1 -1
  35. package/dist/devices/humidifiers.js +154 -181
  36. package/dist/devices/humidifiers.js.map +1 -1
  37. package/dist/devices/meters.d.ts +29 -28
  38. package/dist/devices/meters.d.ts.map +1 -1
  39. package/dist/devices/meters.js +98 -120
  40. package/dist/devices/meters.js.map +1 -1
  41. package/dist/devices/motion.d.ts +24 -23
  42. package/dist/devices/motion.d.ts.map +1 -1
  43. package/dist/devices/motion.js +97 -113
  44. package/dist/devices/motion.js.map +1 -1
  45. package/dist/devices/plugs.d.ts +16 -16
  46. package/dist/devices/plugs.d.ts.map +1 -1
  47. package/dist/devices/plugs.js +48 -71
  48. package/dist/devices/plugs.js.map +1 -1
  49. package/dist/index.d.ts +2 -2
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +3 -22
  52. package/dist/index.js.map +1 -1
  53. package/dist/irdevices/airconditioners.d.ts +7 -4
  54. package/dist/irdevices/airconditioners.d.ts.map +1 -1
  55. package/dist/irdevices/airconditioners.js +72 -93
  56. package/dist/irdevices/airconditioners.js.map +1 -1
  57. package/dist/irdevices/airpurifiers.d.ts +3 -3
  58. package/dist/irdevices/airpurifiers.d.ts.map +1 -1
  59. package/dist/irdevices/airpurifiers.js +32 -51
  60. package/dist/irdevices/airpurifiers.js.map +1 -1
  61. package/dist/irdevices/cameras.d.ts +3 -3
  62. package/dist/irdevices/cameras.d.ts.map +1 -1
  63. package/dist/irdevices/cameras.js +19 -26
  64. package/dist/irdevices/cameras.js.map +1 -1
  65. package/dist/irdevices/fans.d.ts +3 -3
  66. package/dist/irdevices/fans.d.ts.map +1 -1
  67. package/dist/irdevices/fans.js +35 -44
  68. package/dist/irdevices/fans.js.map +1 -1
  69. package/dist/irdevices/lights.d.ts +3 -3
  70. package/dist/irdevices/lights.d.ts.map +1 -1
  71. package/dist/irdevices/lights.js +25 -32
  72. package/dist/irdevices/lights.js.map +1 -1
  73. package/dist/irdevices/others.d.ts +3 -3
  74. package/dist/irdevices/others.d.ts.map +1 -1
  75. package/dist/irdevices/others.js +21 -29
  76. package/dist/irdevices/others.js.map +1 -1
  77. package/dist/irdevices/tvs.d.ts +3 -3
  78. package/dist/irdevices/tvs.d.ts.map +1 -1
  79. package/dist/irdevices/tvs.js +66 -89
  80. package/dist/irdevices/tvs.js.map +1 -1
  81. package/dist/irdevices/vacuumcleaners.d.ts +3 -3
  82. package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
  83. package/dist/irdevices/vacuumcleaners.js +18 -24
  84. package/dist/irdevices/vacuumcleaners.js.map +1 -1
  85. package/dist/irdevices/waterheaters.d.ts +3 -3
  86. package/dist/irdevices/waterheaters.d.ts.map +1 -1
  87. package/dist/irdevices/waterheaters.js +19 -26
  88. package/dist/irdevices/waterheaters.js.map +1 -1
  89. package/dist/platform.d.ts +10 -10
  90. package/dist/platform.d.ts.map +1 -1
  91. package/dist/platform.js +163 -233
  92. package/dist/platform.js.map +1 -1
  93. package/dist/settings.d.ts +3 -1
  94. package/dist/settings.d.ts.map +1 -1
  95. package/dist/settings.js +4 -4
  96. package/dist/settings.js.map +1 -1
  97. package/homebridge-ui/public/index.html +231 -245
  98. package/homebridge-ui/server.js +2 -4
  99. package/nodemon.json +2 -4
  100. package/package.json +17 -12
  101. package/src/devices/bots.ts +411 -854
  102. package/src/devices/colorbulb.ts +187 -408
  103. package/src/devices/contact.ts +210 -376
  104. package/src/devices/curtains.ts +288 -563
  105. package/src/devices/humidifiers.ts +291 -537
  106. package/src/devices/meters.ts +189 -331
  107. package/src/devices/motion.ts +188 -322
  108. package/src/devices/plugs.ts +88 -160
  109. package/src/index.ts +5 -5
  110. package/src/irdevices/airconditioners.ts +139 -318
  111. package/src/irdevices/airpurifiers.ts +71 -170
  112. package/src/irdevices/cameras.ts +44 -103
  113. package/src/irdevices/fans.ts +70 -165
  114. package/src/irdevices/lights.ts +49 -104
  115. package/src/irdevices/others.ts +55 -131
  116. package/src/irdevices/tvs.ts +114 -247
  117. package/src/irdevices/vacuumcleaners.ts +44 -104
  118. package/src/irdevices/waterheaters.ts +49 -121
  119. package/src/platform.ts +341 -753
  120. package/src/settings.ts +8 -11
  121. package/tsconfig.json +5 -14
  122. package/.github/PULL_REQUEST_TEMPLATE/pull_requests.md +0 -27
@@ -1,13 +1,7 @@
1
- import { AxiosResponse } from "axios";
2
- import { SwitchBotPlatform } from "../platform";
3
- import { CharacteristicValue, PlatformAccessory, Service } from "homebridge";
4
- import {
5
- DeviceURL,
6
- irdevice,
7
- deviceStatusResponse,
8
- irDevicesConfig,
9
- payload,
10
- } from "../settings";
1
+ import { AxiosResponse } from 'axios';
2
+ import { SwitchBotPlatform } from '../platform';
3
+ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
4
+ import { DeviceURL, irdevice, deviceStatusResponse, irDevicesConfig, payload } from '../settings';
11
5
 
12
6
  /**
13
7
  * Platform Accessory
@@ -30,11 +24,7 @@ export class TV {
30
24
  // Config
31
25
  deviceLogging!: string;
32
26
 
33
- constructor(
34
- private readonly platform: SwitchBotPlatform,
35
- private accessory: PlatformAccessory,
36
- public device: irdevice & irDevicesConfig,
37
- ) {
27
+ constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
38
28
  // default placeholders
39
29
  this.logs(device);
40
30
  this.config(device);
@@ -47,44 +37,31 @@ export class TV {
47
37
  // set accessory information
48
38
  accessory
49
39
  .getService(this.platform.Service.AccessoryInformation)!
50
- .setCharacteristic(
51
- this.platform.Characteristic.Name,
52
- `${device.deviceName} ${device.remoteType}`,
53
- )
54
- .setCharacteristic(this.platform.Characteristic.Manufacturer, "SwitchBot")
40
+ .setCharacteristic(this.platform.Characteristic.Name, `${device.deviceName} ${device.remoteType}`)
41
+ .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
55
42
  .setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
56
- .setCharacteristic(
57
- this.platform.Characteristic.SerialNumber,
58
- device.deviceId!,
59
- );
43
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
60
44
 
61
45
  // set the accessory category
62
46
  switch (device.remoteType) {
63
- case "Speaker":
64
- case "DIY Speaker":
47
+ case 'Speaker':
48
+ case 'DIY Speaker':
65
49
  accessory.category = this.platform.api.hap.Categories.SPEAKER;
66
- (this.service =
67
- accessory.getService(this.platform.Service.Television) ||
68
- accessory.addService(this.platform.Service.Television)),
50
+ (this.service = accessory.getService(this.platform.Service.Television) || accessory.addService(this.platform.Service.Television)),
69
51
  `${accessory.displayName} Speaker`;
70
52
  break;
71
- case "IPTV":
72
- case "DIY IPTV":
73
- accessory.category =
74
- this.platform.api.hap.Categories.TV_STREAMING_STICK;
75
- (this.service =
76
- accessory.getService(this.platform.Service.Television) ||
77
- accessory.addService(this.platform.Service.Television)),
53
+ case 'IPTV':
54
+ case 'DIY IPTV':
55
+ accessory.category = this.platform.api.hap.Categories.TV_STREAMING_STICK;
56
+ (this.service = accessory.getService(this.platform.Service.Television) || accessory.addService(this.platform.Service.Television)),
78
57
  `${accessory.displayName} Streaming Stick`;
79
58
  break;
80
- case "DVD":
81
- case "DIY DVD":
82
- case "Set Top Box":
83
- case "DIY Set Top Box":
59
+ case 'DVD':
60
+ case 'DIY DVD':
61
+ case 'Set Top Box':
62
+ case 'DIY Set Top Box':
84
63
  accessory.category = this.platform.api.hap.Categories.TV_SET_TOP_BOX;
85
- (this.service =
86
- accessory.getService(this.platform.Service.Television) ||
87
- accessory.addService(this.platform.Service.Television)),
64
+ (this.service = accessory.getService(this.platform.Service.Television) || accessory.addService(this.platform.Service.Television)),
88
65
  `${accessory.displayName} Set Top Box`;
89
66
  break;
90
67
  default:
@@ -92,9 +69,7 @@ export class TV {
92
69
 
93
70
  // get the Television service if it exists, otherwise create a new Television service
94
71
  // you can create multiple services for each accessory
95
- (this.service =
96
- accessory.getService(this.platform.Service.Television) ||
97
- accessory.addService(this.platform.Service.Television)),
72
+ (this.service = accessory.getService(this.platform.Service.Television) || accessory.addService(this.platform.Service.Television)),
98
73
  `${accessory.displayName} TV`;
99
74
  }
100
75
 
@@ -113,59 +88,36 @@ export class TV {
113
88
  );
114
89
 
115
90
  // handle on / off events using the Active characteristic
116
- this.service
117
- .getCharacteristic(this.platform.Characteristic.Active)
118
- .onSet(this.ActiveSet.bind(this));
91
+ this.service.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
119
92
 
120
- this.service.setCharacteristic(
121
- this.platform.Characteristic.ActiveIdentifier,
122
- 1,
123
- );
93
+ this.service.setCharacteristic(this.platform.Characteristic.ActiveIdentifier, 1);
124
94
 
125
95
  // handle input source changes
126
- this.service
127
- .getCharacteristic(this.platform.Characteristic.ActiveIdentifier)
128
- .onSet(this.ActiveIdentifierSet.bind(this));
96
+ this.service.getCharacteristic(this.platform.Characteristic.ActiveIdentifier).onSet(this.ActiveIdentifierSet.bind(this));
129
97
 
130
98
  // handle remote control input
131
- this.service
132
- .getCharacteristic(this.platform.Characteristic.RemoteKey)
133
- .onSet(this.RemoteKeySet.bind(this));
99
+ this.service.getCharacteristic(this.platform.Characteristic.RemoteKey).onSet(this.RemoteKeySet.bind(this));
134
100
 
135
101
  /**
136
102
  * Create a speaker service to allow volume control
137
103
  */
138
104
  // create a new Television Speaker service
139
105
  (this.speakerService =
140
- accessory.getService(this.platform.Service.TelevisionSpeaker) ||
141
- accessory.addService(this.platform.Service.TelevisionSpeaker)),
106
+ accessory.getService(this.platform.Service.TelevisionSpeaker) || accessory.addService(this.platform.Service.TelevisionSpeaker)),
142
107
  `${accessory.displayName} Speaker`;
143
108
 
144
- this.speakerService.setCharacteristic(
145
- this.platform.Characteristic.Name,
146
- `${accessory.displayName} Speaker`,
147
- );
109
+ this.speakerService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Speaker`);
148
110
 
149
111
  this.speakerService
150
- .setCharacteristic(
151
- this.platform.Characteristic.Active,
152
- this.platform.Characteristic.Active.ACTIVE,
153
- )
154
- .setCharacteristic(
155
- this.platform.Characteristic.VolumeControlType,
156
- this.platform.Characteristic.VolumeControlType.ABSOLUTE,
157
- );
112
+ .setCharacteristic(this.platform.Characteristic.Active, this.platform.Characteristic.Active.ACTIVE)
113
+ .setCharacteristic(this.platform.Characteristic.VolumeControlType, this.platform.Characteristic.VolumeControlType.ABSOLUTE);
158
114
 
159
115
  // handle volume control
160
- this.speakerService
161
- .getCharacteristic(this.platform.Characteristic.VolumeSelector)
162
- .onSet(this.VolumeSelectorSet.bind(this));
116
+ this.speakerService.getCharacteristic(this.platform.Characteristic.VolumeSelector).onSet(this.VolumeSelectorSet.bind(this));
163
117
  }
164
118
 
165
119
  private VolumeSelectorSet(value: CharacteristicValue) {
166
- this.debugLog(
167
- `${this.device.remoteType}: ${this.accessory.displayName} VolumeSelector: ${value}`,
168
- );
120
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} VolumeSelector: ${value}`);
169
121
  if (value === this.platform.Characteristic.VolumeSelector.INCREMENT) {
170
122
  this.pushVolumeUpChanges();
171
123
  } else {
@@ -176,87 +128,61 @@ export class TV {
176
128
  private RemoteKeySet(value: CharacteristicValue) {
177
129
  switch (value) {
178
130
  case this.platform.Characteristic.RemoteKey.REWIND: {
179
- this.debugLog(
180
- `${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: REWIND`,
181
- );
131
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: REWIND`);
182
132
  break;
183
133
  }
184
134
  case this.platform.Characteristic.RemoteKey.FAST_FORWARD: {
185
- this.debugLog(
186
- `${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: FAST_FORWARD`,
187
- );
135
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: FAST_FORWARD`);
188
136
  break;
189
137
  }
190
138
  case this.platform.Characteristic.RemoteKey.NEXT_TRACK: {
191
- this.debugLog(
192
- `${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: NEXT_TRACK`,
193
- );
139
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: NEXT_TRACK`);
194
140
  break;
195
141
  }
196
142
  case this.platform.Characteristic.RemoteKey.PREVIOUS_TRACK: {
197
- this.debugLog(
198
- `${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: PREVIOUS_TRACK`,
199
- );
143
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: PREVIOUS_TRACK`);
200
144
  break;
201
145
  }
202
146
  case this.platform.Characteristic.RemoteKey.ARROW_UP: {
203
- this.debugLog(
204
- `${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: ARROW_UP`,
205
- );
147
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: ARROW_UP`);
206
148
  //this.pushUpChanges();
207
149
  break;
208
150
  }
209
151
  case this.platform.Characteristic.RemoteKey.ARROW_DOWN: {
210
- this.debugLog(
211
- `${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: ARROW_DOWN`,
212
- );
152
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: ARROW_DOWN`);
213
153
  //this.pushDownChanges();
214
154
  break;
215
155
  }
216
156
  case this.platform.Characteristic.RemoteKey.ARROW_LEFT: {
217
- this.debugLog(
218
- `${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: ARROW_LEFT`,
219
- );
157
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: ARROW_LEFT`);
220
158
  //this.pushLeftChanges();
221
159
  break;
222
160
  }
223
161
  case this.platform.Characteristic.RemoteKey.ARROW_RIGHT: {
224
- this.debugLog(
225
- `${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: ARROW_RIGHT`,
226
- );
162
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: ARROW_RIGHT`);
227
163
  //this.pushRightChanges();
228
164
  break;
229
165
  }
230
166
  case this.platform.Characteristic.RemoteKey.SELECT: {
231
- this.debugLog(
232
- `${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: SELECT`,
233
- );
167
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: SELECT`);
234
168
  //this.pushOkChanges();
235
169
  break;
236
170
  }
237
171
  case this.platform.Characteristic.RemoteKey.BACK: {
238
- this.debugLog(
239
- `${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: BACK`,
240
- );
172
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: BACK`);
241
173
  //this.pushBackChanges();
242
174
  break;
243
175
  }
244
176
  case this.platform.Characteristic.RemoteKey.EXIT: {
245
- this.debugLog(
246
- `${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: EXIT`,
247
- );
177
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: EXIT`);
248
178
  break;
249
179
  }
250
180
  case this.platform.Characteristic.RemoteKey.PLAY_PAUSE: {
251
- this.debugLog(
252
- `${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: PLAY_PAUSE`,
253
- );
181
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: PLAY_PAUSE`);
254
182
  break;
255
183
  }
256
184
  case this.platform.Characteristic.RemoteKey.INFORMATION: {
257
- this.debugLog(
258
- `${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: INFORMATION`,
259
- );
185
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: INFORMATION`);
260
186
  //this.pushMenuChanges();
261
187
  break;
262
188
  }
@@ -264,16 +190,12 @@ export class TV {
264
190
  }
265
191
 
266
192
  private ActiveIdentifierSet(value: CharacteristicValue) {
267
- this.debugLog(
268
- `${this.device.remoteType}: ${this.accessory.displayName} ActiveIdentifier: ${value}`,
269
- );
193
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ActiveIdentifier: ${value}`);
270
194
  this.ActiveIdentifier = value;
271
195
  }
272
196
 
273
197
  private ActiveSet(value: CharacteristicValue) {
274
- this.debugLog(
275
- `${this.device.remoteType}: ${this.accessory.displayName} Active: ${value}`,
276
- );
198
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${value}`);
277
199
  if (!this.device.irtv?.disable_power) {
278
200
  if (value === this.platform.Characteristic.Active.INACTIVE) {
279
201
  this.pushTvOffChanges();
@@ -288,31 +210,16 @@ export class TV {
288
210
 
289
211
  private updateHomeKitCharacteristics() {
290
212
  if (this.Active === undefined) {
291
- this.debugLog(
292
- `${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.Active}`,
293
- );
213
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.Active}`);
294
214
  } else {
295
- this.service?.updateCharacteristic(
296
- this.platform.Characteristic.Active,
297
- this.Active,
298
- );
299
- this.debugLog(
300
- `${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`,
301
- );
215
+ this.service?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
216
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
302
217
  }
303
218
  if (this.ActiveIdentifier === undefined) {
304
- this.debugLog(
305
- `${this.device.remoteType}: ${this.accessory.displayName} ActiveIdentifier: ${this.ActiveIdentifier}`,
306
- );
219
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ActiveIdentifier: ${this.ActiveIdentifier}`);
307
220
  } else {
308
- this.service?.updateCharacteristic(
309
- this.platform.Characteristic.ActiveIdentifier,
310
- this.ActiveIdentifier,
311
- );
312
- this.debugLog(
313
- `${this.device.remoteType}: ${this.accessory.displayName}` +
314
- ` updateCharacteristic ActiveIdentifier: ${this.ActiveIdentifier}`,
315
- );
221
+ this.service?.updateCharacteristic(this.platform.Characteristic.ActiveIdentifier, this.ActiveIdentifier);
222
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}` + ` updateCharacteristic ActiveIdentifier: ${this.ActiveIdentifier}`);
316
223
  }
317
224
  }
318
225
 
@@ -327,104 +234,102 @@ export class TV {
327
234
  * TV: "command" "channelSub" "default" = previous channel
328
235
  */
329
236
  async pushTvOnChanges() {
330
- if (this.Active !== this.platform.Characteristic.Active.ACTIVE) {
237
+ if (this.Active !== 1) {
331
238
  const payload = {
332
- commandType: "command",
333
- parameter: "default",
334
- command: "turnOn",
239
+ commandType: 'command',
240
+ parameter: 'default',
241
+ command: 'turnOn',
335
242
  } as payload;
336
243
  await this.pushTVChanges(payload);
337
244
  }
338
245
  }
339
246
 
340
247
  async pushTvOffChanges() {
341
- if (this.Active !== this.platform.Characteristic.Active.INACTIVE) {
342
- const payload = {
343
- commandType: "command",
344
- parameter: "default",
345
- command: "turnOff",
346
- } as payload;
347
- await this.pushTVChanges(payload);
348
- }
248
+ const payload = {
249
+ commandType: 'command',
250
+ parameter: 'default',
251
+ command: 'turnOff',
252
+ } as payload;
253
+ await this.pushTVChanges(payload);
349
254
  }
350
255
 
351
256
  async pushOkChanges() {
352
257
  const payload = {
353
- commandType: "command",
354
- parameter: "default",
355
- command: "Ok",
258
+ commandType: 'command',
259
+ parameter: 'default',
260
+ command: 'Ok',
356
261
  } as payload;
357
262
  await this.pushTVChanges(payload);
358
263
  }
359
264
 
360
265
  async pushBackChanges() {
361
266
  const payload = {
362
- commandType: "command",
363
- parameter: "default",
364
- command: "Back",
267
+ commandType: 'command',
268
+ parameter: 'default',
269
+ command: 'Back',
365
270
  } as payload;
366
271
  await this.pushTVChanges(payload);
367
272
  }
368
273
 
369
274
  async pushMenuChanges() {
370
275
  const payload = {
371
- commandType: "command",
372
- parameter: "default",
373
- command: "Menu",
276
+ commandType: 'command',
277
+ parameter: 'default',
278
+ command: 'Menu',
374
279
  } as payload;
375
280
  await this.pushTVChanges(payload);
376
281
  }
377
282
 
378
283
  async pushUpChanges() {
379
284
  const payload = {
380
- commandType: "command",
381
- parameter: "default",
382
- command: "Up",
285
+ commandType: 'command',
286
+ parameter: 'default',
287
+ command: 'Up',
383
288
  } as payload;
384
289
  await this.pushTVChanges(payload);
385
290
  }
386
291
 
387
292
  async pushDownChanges() {
388
293
  const payload = {
389
- commandType: "command",
390
- parameter: "default",
391
- command: "Down",
294
+ commandType: 'command',
295
+ parameter: 'default',
296
+ command: 'Down',
392
297
  } as payload;
393
298
  await this.pushTVChanges(payload);
394
299
  }
395
300
 
396
301
  async pushRightChanges() {
397
302
  const payload = {
398
- commandType: "command",
399
- parameter: "default",
400
- command: "Right",
303
+ commandType: 'command',
304
+ parameter: 'default',
305
+ command: 'Right',
401
306
  } as payload;
402
307
  await this.pushTVChanges(payload);
403
308
  }
404
309
 
405
310
  async pushLeftChanges() {
406
311
  const payload = {
407
- commandType: "command",
408
- parameter: "default",
409
- command: "Left",
312
+ commandType: 'command',
313
+ parameter: 'default',
314
+ command: 'Left',
410
315
  } as payload;
411
316
  await this.pushTVChanges(payload);
412
317
  }
413
318
 
414
319
  async pushVolumeUpChanges() {
415
320
  const payload = {
416
- commandType: "command",
417
- parameter: "default",
418
- command: "volumeAdd",
321
+ commandType: 'command',
322
+ parameter: 'default',
323
+ command: 'volumeAdd',
419
324
  } as payload;
420
325
  await this.pushTVChanges(payload);
421
326
  }
422
327
 
423
328
  async pushVolumeDownChanges() {
424
329
  const payload = {
425
- commandType: "command",
426
- parameter: "default",
427
- command: "volumeSub",
330
+ commandType: 'command',
331
+ parameter: 'default',
332
+ command: 'volumeSub',
428
333
  } as payload;
429
334
  await this.pushTVChanges(payload);
430
335
  }
@@ -437,20 +342,13 @@ export class TV {
437
342
  );
438
343
 
439
344
  // Make the API request
440
- const push = await this.platform.axios.post(
441
- `${DeviceURL}/${this.device.deviceId}/commands`,
442
- payload,
443
- );
444
- this.debugLog(
445
- `${this.device.remoteType}: ${this.accessory.displayName} pushChanges: ${push.data}`,
446
- );
345
+ const push = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
346
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges: ${push.data}`);
447
347
  this.statusCode(push);
448
348
  this.updateHomeKitCharacteristics();
449
349
  } catch (e: any) {
450
- this.errorLog(
451
- `${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`,
452
- );
453
- if (this.deviceLogging === "debug") {
350
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
351
+ if (this.deviceLogging === 'debug') {
454
352
  this.errorLog(
455
353
  `${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
456
354
  ` Error Message: ${JSON.stringify(e.message)}`,
@@ -458,8 +356,7 @@ export class TV {
458
356
  }
459
357
  if (this.platform.debugMode) {
460
358
  this.errorLog(
461
- `${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
462
- ` Error: ${JSON.stringify(e)}`,
359
+ `${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`,
463
360
  );
464
361
  }
465
362
  this.apiError(e);
@@ -469,29 +366,19 @@ export class TV {
469
366
  private statusCode(push: AxiosResponse<{ statusCode: number }>) {
470
367
  switch (push.data.statusCode) {
471
368
  case 151:
472
- this.errorLog(
473
- `${this.device.remoteType}: ${this.accessory.displayName} Command not supported by this device type.`,
474
- );
369
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command not supported by this device type.`);
475
370
  break;
476
371
  case 152:
477
- this.errorLog(
478
- `${this.device.remoteType}: ${this.accessory.displayName} Device not found.`,
479
- );
372
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device not found.`);
480
373
  break;
481
374
  case 160:
482
- this.errorLog(
483
- `${this.device.remoteType}: ${this.accessory.displayName} Command is not supported.`,
484
- );
375
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command is not supported.`);
485
376
  break;
486
377
  case 161:
487
- this.errorLog(
488
- `${this.device.remoteType}: ${this.accessory.displayName} Device is offline.`,
489
- );
378
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline.`);
490
379
  break;
491
380
  case 171:
492
- this.errorLog(
493
- `${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`,
494
- );
381
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
495
382
  break;
496
383
  case 190:
497
384
  this.errorLog(
@@ -501,23 +388,16 @@ export class TV {
501
388
  );
502
389
  break;
503
390
  case 100:
504
- this.debugLog(
505
- `${this.device.remoteType}: ${this.accessory.displayName} Command successfully sent.`,
506
- );
391
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Command successfully sent.`);
507
392
  break;
508
393
  default:
509
- this.debugLog(
510
- `${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode.`,
511
- );
394
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode.`);
512
395
  }
513
396
  }
514
397
 
515
398
  public apiError(e: any) {
516
399
  this.service.updateCharacteristic(this.platform.Characteristic.Active, e);
517
- this.service.updateCharacteristic(
518
- this.platform.Characteristic.ActiveIdentifier,
519
- e,
520
- );
400
+ this.service.updateCharacteristic(this.platform.Characteristic.ActiveIdentifier, e);
521
401
  //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
522
402
  }
523
403
 
@@ -527,39 +407,26 @@ export class TV {
527
407
  config = device.irtv;
528
408
  }
529
409
  if (device.logging !== undefined) {
530
- config["logging"] = device.logging;
410
+ config['logging'] = device.logging;
531
411
  }
532
412
  if (Object.entries(config).length !== 0) {
533
- this.warnLog(
534
- `${this.device.remoteType}: ${
535
- this.accessory.displayName
536
- } Config: ${JSON.stringify(config)}`,
537
- );
413
+ this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
538
414
  }
539
415
  }
540
416
 
541
417
  logs(device: irdevice & irDevicesConfig) {
542
418
  if (this.platform.debugMode) {
543
- this.deviceLogging = this.accessory.context.logging = "debugMode";
544
- this.debugLog(
545
- `${this.device.remoteType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`,
546
- );
419
+ this.deviceLogging = this.accessory.context.logging = 'debugMode';
420
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
547
421
  } else if (device.logging) {
548
422
  this.deviceLogging = this.accessory.context.logging = device.logging;
549
- this.debugLog(
550
- `${this.device.remoteType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`,
551
- );
423
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
552
424
  } else if (this.platform.config.options?.logging) {
553
- this.deviceLogging = this.accessory.context.logging =
554
- this.platform.config.options?.logging;
555
- this.debugLog(
556
- `${this.device.remoteType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`,
557
- );
425
+ this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
426
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
558
427
  } else {
559
- this.deviceLogging = this.accessory.context.logging = "standard";
560
- this.debugLog(
561
- `${this.device.remoteType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`,
562
- );
428
+ this.deviceLogging = this.accessory.context.logging = 'standard';
429
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
563
430
  }
564
431
  }
565
432
 
@@ -586,8 +453,8 @@ export class TV {
586
453
 
587
454
  debugLog(...log: any[]) {
588
455
  if (this.enablingDeviceLogging()) {
589
- if (this.deviceLogging === "debug") {
590
- this.platform.log.info("[DEBUG]", String(...log));
456
+ if (this.deviceLogging === 'debug') {
457
+ this.platform.log.info('[DEBUG]', String(...log));
591
458
  } else {
592
459
  this.platform.log.debug(String(...log));
593
460
  }
@@ -595,6 +462,6 @@ export class TV {
595
462
  }
596
463
 
597
464
  enablingDeviceLogging(): boolean {
598
- return this.deviceLogging.includes("debug") || this.deviceLogging === "standard";
465
+ return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
599
466
  }
600
467
  }