@o-lukas/homebridge-smartthings-tv 2.2.0-next.1 → 2.3.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/README.md CHANGED
@@ -214,6 +214,10 @@ The application's name.
214
214
 
215
215
  The application's possible ids. Since some applications have different ids for different versions of TVs you can provide a list here so the plugin will try every id and use the one that's working.
216
216
 
217
+ #### category
218
+
219
+ The icon to be used as a hint to iOS clients about what type of Accessory this represents. Can be used to override default values.
220
+
217
221
  ## Common issues
218
222
 
219
223
  ### TV does not show in HomeKit
@@ -71,6 +71,7 @@
71
71
  "deviceId": {
72
72
  "title": "Device Id",
73
73
  "type": "string",
74
+ "required": true,
74
75
  "description": "The SmartThings device id. Check the log or go to https://account.smartthings.com/ and get the device id."
75
76
  },
76
77
  "nameOverride": {
@@ -153,6 +154,74 @@
153
154
  },
154
155
  "required": false,
155
156
  "description": "Overrides the default application mapping list to add custom applications."
157
+ },
158
+ "category": {
159
+ "title": "Display icon",
160
+ "type": "integer",
161
+ "description": "The icon to be used as a hint to iOS clients about what type of Accessory this represents. Can be used to override default values.",
162
+ "required": false,
163
+ "oneOf": [
164
+ {
165
+ "title": "AppleTV",
166
+ "enum": [
167
+ "24"
168
+ ]
169
+ },
170
+ {
171
+ "title": "HomePod",
172
+ "enum": [
173
+ "25"
174
+ ]
175
+ },
176
+ {
177
+ "title": "Speaker",
178
+ "enum": [
179
+ "26"
180
+ ]
181
+ },
182
+ {
183
+ "title": "AirPort",
184
+ "enum": [
185
+ "27"
186
+ ]
187
+ },
188
+ {
189
+ "title": "Television",
190
+ "enum": [
191
+ "31"
192
+ ]
193
+ },
194
+ {
195
+ "title": "Remote Control",
196
+ "enum": [
197
+ "32"
198
+ ]
199
+ },
200
+ {
201
+ "title": "Router",
202
+ "enum": [
203
+ "33"
204
+ ]
205
+ },
206
+ {
207
+ "title": "Audio Receiver",
208
+ "enum": [
209
+ "34"
210
+ ]
211
+ },
212
+ {
213
+ "title": "TV Set Top Box",
214
+ "enum": [
215
+ "35"
216
+ ]
217
+ },
218
+ {
219
+ "title": "TV Streaming Stick",
220
+ "enum": [
221
+ "36"
222
+ ]
223
+ }
224
+ ]
156
225
  }
157
226
  }
158
227
  }
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { API } from 'homebridge';
1
+ import type { API } from 'homebridge';
2
2
  /**
3
3
  * This method registers the platform with Homebridge
4
4
  */
5
5
  declare const _default: (api: API) => void;
6
- export = _default;
7
- //# sourceMappingURL=index.d.ts.map
6
+ export default _default;
package/dist/index.js CHANGED
@@ -1,7 +1,9 @@
1
- "use strict";
2
- const settings_1 = require("./settings");
3
- const smartThingsPlatform_1 = require("./smartThingsPlatform");
4
- module.exports = (api) => {
5
- api.registerPlatform(settings_1.PLATFORM_NAME, smartThingsPlatform_1.SmartThingsPlatform);
1
+ import { SmartThingsPlatform } from './smartThingsPlatform.js';
2
+ import { PLATFORM_NAME } from './settings.js';
3
+ /**
4
+ * This method registers the platform with Homebridge
5
+ */
6
+ export default (api) => {
7
+ api.registerPlatform(PLATFORM_NAME, SmartThingsPlatform);
6
8
  };
7
9
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,yCAA2C;AAC3C,+DAA4D;AAK5D,iBAAS,CAAC,GAAQ,EAAE,EAAE;IACpB,GAAG,CAAC,gBAAgB,CAAC,wBAAa,EAAE,yCAAmB,CAAC,CAAC;AAC3D,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C;;GAEG;AACH,eAAe,CAAC,GAAQ,EAAE,EAAE;IAC1B,GAAG,CAAC,gBAAgB,CAAC,aAAa,EAAE,mBAAmB,CAAC,CAAC;AAC3D,CAAC,CAAC"}
@@ -6,4 +6,3 @@ export declare const PLATFORM_NAME = "smartthings-tv";
6
6
  * This must match the name of your plugin as defined the package.json
7
7
  */
8
8
  export declare const PLUGIN_NAME = "@o-lukas/homebridge-smartthings-tv";
9
- //# sourceMappingURL=settings.d.ts.map
package/dist/settings.js CHANGED
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PLUGIN_NAME = exports.PLATFORM_NAME = void 0;
4
1
  /**
5
2
  * This is the name of the platform that users will use to register the plugin in the Homebridge config.json
6
3
  */
7
- exports.PLATFORM_NAME = 'smartthings-tv';
4
+ export const PLATFORM_NAME = 'smartthings-tv';
8
5
  /**
9
6
  * This must match the name of your plugin as defined the package.json
10
7
  */
11
- exports.PLUGIN_NAME = '@o-lukas/homebridge-smartthings-tv';
8
+ export const PLUGIN_NAME = '@o-lukas/homebridge-smartthings-tv';
12
9
  //# sourceMappingURL=settings.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,aAAa,GAAG,gBAAgB,CAAC;AAE9C;;GAEG;AACU,QAAA,WAAW,GAAG,oCAAoC,CAAC"}
1
+ {"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,gBAAgB,CAAC;AAE9C;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,oCAAoC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { PlatformAccessory, CharacteristicValue, Logger } from 'homebridge';
2
- import { SmartThingsPlatform } from './smartThingsPlatform';
2
+ import { SmartThingsPlatform } from './smartThingsPlatform.js';
3
3
  import { SmartThingsClient, Device, Component, CapabilityStatus } from '@smartthings/core-sdk';
4
- import { SmartThingsAccessory } from './smartThingsAccessory';
4
+ import { SmartThingsAccessory } from './smartThingsAccessory.js';
5
5
  /**
6
6
  * Class implements a slider accessory to execute a capability commmand.
7
7
  */
@@ -20,4 +20,3 @@ export declare class SliderAccessory extends SmartThingsAccessory {
20
20
  private handleGetBrightness;
21
21
  private handleSetBrightness;
22
22
  }
23
- //# sourceMappingURL=sliderAccessory.d.ts.map
@@ -1,13 +1,19 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SliderAccessory = void 0;
4
- const smartThingsAccessory_1 = require("./smartThingsAccessory");
1
+ import { SmartThingsAccessory } from './smartThingsAccessory.js';
5
2
  /**
6
3
  * Class implements a slider accessory to execute a capability commmand.
7
4
  */
8
- class SliderAccessory extends smartThingsAccessory_1.SmartThingsAccessory {
5
+ export class SliderAccessory extends SmartThingsAccessory {
6
+ capability;
7
+ command;
8
+ onGet;
9
+ onSet;
10
+ pollingInterval;
11
+ cyclicCallsLogging;
12
+ service;
13
+ // stores the last value before the off functionality has been used
14
+ // so this value can be restored when turning back on
15
+ lastValueBeforeOff = 0;
9
16
  constructor(device, component, client, log, platform, accessory, capability, command, onGet, onSet, pollingInterval, cyclicCallsLogging) {
10
- var _a;
11
17
  super(device, component, client, platform, accessory, log);
12
18
  this.capability = capability;
13
19
  this.command = command;
@@ -15,10 +21,8 @@ class SliderAccessory extends smartThingsAccessory_1.SmartThingsAccessory {
15
21
  this.onSet = onSet;
16
22
  this.pollingInterval = pollingInterval;
17
23
  this.cyclicCallsLogging = cyclicCallsLogging;
18
- // stores the last value before the off functionality has been used
19
- // so this value can be restored when turning back on
20
- this.lastValueBeforeOff = 0;
21
- this.service = (_a = this.accessory.getService(this.platform.Service.Lightbulb)) !== null && _a !== void 0 ? _a : this.accessory.addService(this.platform.Service.Lightbulb);
24
+ this.service = this.accessory.getService(this.platform.Service.Lightbulb) ??
25
+ this.accessory.addService(this.platform.Service.Lightbulb);
22
26
  this.service.getCharacteristic(this.platform.Characteristic.On)
23
27
  .onGet(this.handleGetOn.bind(this))
24
28
  .onSet(this.handleSetOn.bind(this));
@@ -55,5 +59,4 @@ class SliderAccessory extends smartThingsAccessory_1.SmartThingsAccessory {
55
59
  await this.executeCommand(this.capability, this.command, apiValue);
56
60
  }
57
61
  }
58
- exports.SliderAccessory = SliderAccessory;
59
62
  //# sourceMappingURL=sliderAccessory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sliderAccessory.js","sourceRoot":"","sources":["../src/sliderAccessory.ts"],"names":[],"mappings":";;;AAIA,iEAA8D;AAE9D;;GAEG;AACH,MAAa,eAAgB,SAAQ,2CAAoB;IAMvD,YACE,MAAc,EACd,SAAoB,EACpB,MAAyB,EACzB,GAAW,EACX,QAA6B,EAC7B,SAA4B,EACX,UAAkB,EAClB,OAAe,EACf,KAA8D,EAC9D,KAAmE,EACnE,eAAmC,EACnC,kBAA2B;;QAE5C,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;QAP1C,eAAU,GAAV,UAAU,CAAQ;QAClB,YAAO,GAAP,OAAO,CAAQ;QACf,UAAK,GAAL,KAAK,CAAyD;QAC9D,UAAK,GAAL,KAAK,CAA8D;QACnE,oBAAe,GAAf,eAAe,CAAoB;QACnC,uBAAkB,GAAlB,kBAAkB,CAAS;QAhB9C,mEAAmE;QACnE,qDAAqD;QAC7C,uBAAkB,GAAG,CAAC,CAAC;QAkB7B,IAAI,CAAC,OAAO,GAAG,MAAA,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,mCACvE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;aAC5D,K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AAC,gEAAgE,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC;YAC7H,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,mBAAmB,CAAC,GAAG,GAAG,IAAI;QAC1C,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC;QAClF,IAAI,GAAG,EAAE,CAAC;YACR,IAAI,CAAC,QAAQ,CAAC,kBAAkB,EAAE,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEO,KAAK,CAAC,mBAAmB,CAAC,KAA0B;QAC1D,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC1D,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACrE,CAAC;CACF"}
@@ -1,5 +1,5 @@
1
1
  import { Characteristic, CharacteristicValue, Logger, PlatformAccessory, Service, WithUUID } from 'homebridge';
2
- import { SmartThingsPlatform } from './smartThingsPlatform';
2
+ import { SmartThingsPlatform } from './smartThingsPlatform.js';
3
3
  import { SmartThingsClient, Device, Component, CapabilityStatus, Capability } from '@smartthings/core-sdk';
4
4
  /**
5
5
  * Class implements a base class for SmartThings accessories.
@@ -47,4 +47,3 @@ export declare abstract class SmartThingsAccessory {
47
47
  protected logError(message: string, ...parameters: unknown[]): void;
48
48
  protected logDebug(message: string, ...parameters: unknown[]): void;
49
49
  }
50
- //# sourceMappingURL=smartThingsAccessory.d.ts.map
@@ -1,13 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SmartThingsAccessory = void 0;
4
- const core_sdk_1 = require("@smartthings/core-sdk");
1
+ import { CustomCapabilityStatus } from '@smartthings/core-sdk';
5
2
  /**
6
3
  * Class implements a base class for SmartThings accessories.
7
4
  */
8
- class SmartThingsAccessory {
5
+ export class SmartThingsAccessory {
6
+ device;
7
+ component;
8
+ client;
9
+ platform;
10
+ accessory;
11
+ log;
9
12
  constructor(device, component, client, platform, accessory, log) {
10
- var _a, _b, _c, _d;
11
13
  this.device = device;
12
14
  this.component = component;
13
15
  this.client = client;
@@ -15,9 +17,9 @@ class SmartThingsAccessory {
15
17
  this.accessory = accessory;
16
18
  this.log = log;
17
19
  this.accessory.getService(this.platform.Service.AccessoryInformation)
18
- .setCharacteristic(this.platform.Characteristic.FirmwareRevision, (_b = (_a = device.ocf) === null || _a === void 0 ? void 0 : _a.firmwareVersion) !== null && _b !== void 0 ? _b : 'Unknown')
20
+ .setCharacteristic(this.platform.Characteristic.FirmwareRevision, device.ocf?.firmwareVersion ?? 'Unknown')
19
21
  .setCharacteristic(this.platform.Characteristic.Manufacturer, device.manufacturerName)
20
- .setCharacteristic(this.platform.Characteristic.Model, (_d = (_c = device.ocf) === null || _c === void 0 ? void 0 : _c.modelNumber) !== null && _d !== void 0 ? _d : 'Unknown')
22
+ .setCharacteristic(this.platform.Characteristic.Model, device.ocf?.modelNumber ?? 'Unknown')
21
23
  .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId);
22
24
  }
23
25
  /**
@@ -98,26 +100,21 @@ class SmartThingsAccessory {
98
100
  }
99
101
  logCapabilityRegistration(capability) {
100
102
  this.logInfo('Registering capability:', capability.name);
101
- if (capability.status !== core_sdk_1.CustomCapabilityStatus.LIVE) {
103
+ if (capability.status !== CustomCapabilityStatus.LIVE) {
102
104
  this.logWarn('Capability %s might not work as expected because it\'s status is: %s', capability.name, capability.status);
103
105
  }
104
106
  }
105
107
  logInfo(message, ...parameters) {
106
- var _a;
107
- this.log.info('[' + ((_a = this.device.name) !== null && _a !== void 0 ? _a : this.device.deviceId) + '] ' + message, ...parameters);
108
+ this.log.info('[' + (this.device.name ?? this.device.deviceId) + '] ' + message, ...parameters);
108
109
  }
109
110
  logWarn(message, ...parameters) {
110
- var _a;
111
- this.log.warn('[' + ((_a = this.device.name) !== null && _a !== void 0 ? _a : this.device.deviceId) + '] ' + message, ...parameters);
111
+ this.log.warn('[' + (this.device.name ?? this.device.deviceId) + '] ' + message, ...parameters);
112
112
  }
113
113
  logError(message, ...parameters) {
114
- var _a;
115
- this.log.error('[' + ((_a = this.device.name) !== null && _a !== void 0 ? _a : this.device.deviceId) + '] ' + message, ...parameters);
114
+ this.log.error('[' + (this.device.name ?? this.device.deviceId) + '] ' + message, ...parameters);
116
115
  }
117
116
  logDebug(message, ...parameters) {
118
- var _a;
119
- this.log.debug('[' + ((_a = this.device.name) !== null && _a !== void 0 ? _a : this.device.deviceId) + '] ' + message, ...parameters);
117
+ this.log.debug('[' + (this.device.name ?? this.device.deviceId) + '] ' + message, ...parameters);
120
118
  }
121
119
  }
122
- exports.SmartThingsAccessory = SmartThingsAccessory;
123
120
  //# sourceMappingURL=smartThingsAccessory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"smartThingsAccessory.js","sourceRoot":"","sources":["../src/smartThingsAccessory.ts"],"names":[],"mappings":";;;AAIA,oDAA+D;AAE/D;;GAEG;AACH,MAAsB,oBAAoB;IACxC,YACqB,MAAc,EACd,SAAoB,EACpB,MAAyB,EACzB,QAA6B,EAC7B,SAA4B,EAC9B,GAAW;;QALT,WAAM,GAAN,MAAM,CAAQ;QACd,cAAS,GAAT,SAAS,CAAW;QACpB,WAAM,GAAN,MAAM,CAAmB;QACzB,aAAQ,GAAR,QAAQ,CAAqB;QAC7B,cAAS,GAAT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EAAsE,EAAE,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;QAC3H,CAAC;IACH,CAAC;IAES,OAAO,CAAC,OAAe,EAAE,GAAG,UAAqB;QACzD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAI,GAAG,OAAO,EAAE,GAAG,UAAU,CAAC,CAAC;IAClG,CAAC;IAES,OAAO,CAAC,OAAe,EAAE,GAAG,UAAqB;QACzD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAI,GAAG,OAAO,EAAE,GAAG,UAAU,CAAC,CAAC;IAClG,CAAC;IAES,QAAQ,CAAC,OAAe,EAAE,GAAG,UAAqB;QAC1D,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAI,GAAG,OAAO,EAAE,GAAG,UAAU,CAAC,CAAC;IACnG,CAAC;IAES,QAAQ,CAAC,OAAe,EAAE,GAAG,UAAqB;QAC1D,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAI,GAAG,OAAO,EAAE,GAAG,UAAU,CAAC,CAAC;IACnG,CAAC;CACF"}
@@ -17,13 +17,14 @@ declare class DeviceMapping {
17
17
  ids: [string];
18
18
  }];
19
19
  readonly infoKey: string;
20
+ readonly category: number;
20
21
  constructor(deviceId: string, nameOverride: string, macAddress: string, ipAddress: string, inputSources: [{
21
22
  name: string;
22
23
  id: string;
23
24
  }], applications: [{
24
25
  name: string;
25
26
  ids: [string];
26
- }], infoKey: string);
27
+ }], infoKey: string, category: number);
27
28
  }
28
29
  /**
29
30
  * Class implements the plugin platform.
@@ -103,4 +104,3 @@ export declare class SmartThingsPlatform implements DynamicPlatformPlugin {
103
104
  registerVolumeSlider(client: SmartThingsClient, device: Device, component: Component): void;
104
105
  }
105
106
  export {};
106
- //# sourceMappingURL=smartThingsPlatform.d.ts.map
@@ -1,17 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SmartThingsPlatform = void 0;
4
- const settings_1 = require("./settings");
5
- const tvAccessory_1 = require("./tvAccessory");
6
- const core_sdk_1 = require("@smartthings/core-sdk");
7
- const switchAccessory_1 = require("./switchAccessory");
8
- const sliderAccessory_1 = require("./sliderAccessory");
9
- const soundbarAccessory_1 = require("./soundbarAccessory");
1
+ import { PLATFORM_NAME, PLUGIN_NAME } from './settings.js';
2
+ import { TvAccessory } from './tvAccessory.js';
3
+ import { SmartThingsClient, BearerTokenAuthenticator } from '@smartthings/core-sdk';
4
+ import { SwitchAccessory } from './switchAccessory.js';
5
+ import { SliderAccessory } from './sliderAccessory.js';
6
+ import { SoundbarAccessory } from './soundbarAccessory.js';
10
7
  /**
11
8
  * Class implements the configured Device to mac and ip address mappings.
12
9
  */
13
10
  class DeviceMapping {
14
- constructor(deviceId, nameOverride, macAddress, ipAddress, inputSources, applications, infoKey) {
11
+ deviceId;
12
+ nameOverride;
13
+ macAddress;
14
+ ipAddress;
15
+ inputSources;
16
+ applications;
17
+ infoKey;
18
+ category;
19
+ constructor(deviceId, nameOverride, macAddress, ipAddress, inputSources, applications, infoKey, category) {
15
20
  this.deviceId = deviceId;
16
21
  this.nameOverride = nameOverride;
17
22
  this.macAddress = macAddress;
@@ -19,27 +24,32 @@ class DeviceMapping {
19
24
  this.inputSources = inputSources;
20
25
  this.applications = applications;
21
26
  this.infoKey = infoKey;
27
+ this.category = category;
22
28
  }
23
29
  }
24
30
  /**
25
31
  * Class implements the plugin platform.
26
32
  */
27
- class SmartThingsPlatform {
33
+ export class SmartThingsPlatform {
34
+ log;
35
+ config;
36
+ api;
37
+ Service;
38
+ Characteristic;
39
+ // this is used to track restored cached accessories
40
+ accessories = [];
28
41
  constructor(log, config, api) {
29
42
  this.log = log;
30
43
  this.config = config;
31
44
  this.api = api;
45
+ this.log.debug('Finished initializing platform: %s', this.config.name);
32
46
  this.Service = this.api.hap.Service;
33
47
  this.Characteristic = this.api.hap.Characteristic;
34
- // this is used to track restored cached accessories
35
- this.accessories = [];
36
- this.log.debug('Finished initializing platform: %s', this.config.name);
37
48
  if (!config.token) {
38
49
  this.log.error('SmartThings API token must be configured');
39
50
  return;
40
51
  }
41
52
  this.api.on('didFinishLaunching', () => {
42
- var _a;
43
53
  this.log.debug('Executed didFinishLaunching callback');
44
54
  let deviceBlocklist = config.deviceBlocklist;
45
55
  if (this.config.deviceBlacklist) {
@@ -47,13 +57,12 @@ class SmartThingsPlatform {
47
57
  this.log.warn('Config property deviceBlacklist has been renamed to deviceBlocklist \
48
58
  - adjust your configuration because deviceBlacklist will be removed in future versions');
49
59
  }
50
- void this.discoverDevices(config.token, deviceBlocklist !== null && deviceBlocklist !== void 0 ? deviceBlocklist : [], (_a = config.deviceMappings) !== null && _a !== void 0 ? _a : []);
60
+ void this.discoverDevices(config.token, deviceBlocklist ?? [], config.deviceMappings ?? []);
51
61
  });
52
62
  }
53
63
  /**
54
64
  * @inheritdoc
55
65
  */
56
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
57
66
  configureAccessory(accessory) {
58
67
  this.log.info('Loading accessory from cache: %s', accessory.displayName);
59
68
  // add the restored accessory to the accessories cache so we can track if it has already been registered
@@ -67,7 +76,7 @@ class SmartThingsPlatform {
67
76
  * @param deviceMappings the array of configured DeviceMapping
68
77
  */
69
78
  async discoverDevices(token, deviceBlocklist, deviceMappings) {
70
- const client = new core_sdk_1.SmartThingsClient(new core_sdk_1.BearerTokenAuthenticator(token));
79
+ const client = new SmartThingsClient(new BearerTokenAuthenticator(token));
71
80
  try {
72
81
  for (const device of await client.devices.list()) {
73
82
  if (deviceBlocklist.includes(device.deviceId)) {
@@ -94,8 +103,7 @@ class SmartThingsPlatform {
94
103
  * @param deviceMappings the array of configured DeviceMapping
95
104
  */
96
105
  async registerDevice(client, device, deviceMappings) {
97
- var _a, _b;
98
- switch ((_a = device.ocf) === null || _a === void 0 ? void 0 : _a.ocfDeviceType) {
106
+ switch (device.ocf?.ocfDeviceType) {
99
107
  case 'oic.d.tv':
100
108
  case 'x.com.st.d.monitor':
101
109
  await this.registerTvDevice(client, device, deviceMappings.find(mapping => mapping.deviceId === device.deviceId));
@@ -104,7 +112,7 @@ class SmartThingsPlatform {
104
112
  await this.registerSoundbarDevice(client, device, deviceMappings.find(mapping => mapping.deviceId === device.deviceId));
105
113
  break;
106
114
  default:
107
- this.log.debug('Ignoring SmartThings device %s because device type %s is not implemented: %s', device.name ? device.name + ' (' + device.deviceId + ')' : device.deviceId, (_b = device.ocf) === null || _b === void 0 ? void 0 : _b.ocfDeviceType, JSON.stringify(device, null, 2));
115
+ this.log.debug('Ignoring SmartThings device %s because device type %s is not implemented: %s', device.name ? device.name + ' (' + device.deviceId + ')' : device.deviceId, device.ocf?.ocfDeviceType, JSON.stringify(device, null, 2));
108
116
  break;
109
117
  }
110
118
  }
@@ -117,23 +125,22 @@ class SmartThingsPlatform {
117
125
  * @param deviceMappings the array of configured DeviceMapping
118
126
  */
119
127
  async registerTvDevice(client, device, deviceMapping) {
120
- var _a, _b, _c, _d, _e, _f;
121
128
  this.log.info('Adding new TV accessory: %s', device.name ? device.name + ' (' + device.deviceId + ')' : device.deviceId);
122
- const component = (_a = device.components) === null || _a === void 0 ? void 0 : _a.at(0);
129
+ const component = device.components?.at(0);
123
130
  if (!component) {
124
131
  this.log.info('Can\'t register TV accessory because (main) component does not exist');
125
132
  return;
126
133
  }
127
- let displayName = (_b = device.name) !== null && _b !== void 0 ? _b : device.deviceId;
128
- if (deviceMapping === null || deviceMapping === void 0 ? void 0 : deviceMapping.nameOverride) {
134
+ let displayName = device.name ?? device.deviceId;
135
+ if (deviceMapping?.nameOverride) {
129
136
  this.log.info('Overriding device default name \'%s\' with configured display name \'%s\'', device.name, deviceMapping.nameOverride);
130
137
  displayName = deviceMapping.nameOverride;
131
138
  }
132
139
  const accessory = new this.api.platformAccessory(displayName, device.deviceId);
133
140
  accessory.context.device = device;
134
- accessory.category = 31 /* this.api.hap.Categories.TELEVISION */;
135
- this.api.publishExternalAccessories(settings_1.PLUGIN_NAME, [accessory]);
136
- const tv = new tvAccessory_1.TvAccessory(displayName, device, component, client, this.log, this, accessory, (_c = this.config.capabilityLogging) !== null && _c !== void 0 ? _c : false, (_d = this.config.registerApplications) !== null && _d !== void 0 ? _d : false, (_e = this.config.pollInterval) !== null && _e !== void 0 ? _e : undefined, (_f = this.config.cyclicCallsLogging) !== null && _f !== void 0 ? _f : false, deviceMapping === null || deviceMapping === void 0 ? void 0 : deviceMapping.macAddress, deviceMapping === null || deviceMapping === void 0 ? void 0 : deviceMapping.ipAddress, deviceMapping === null || deviceMapping === void 0 ? void 0 : deviceMapping.inputSources, deviceMapping === null || deviceMapping === void 0 ? void 0 : deviceMapping.applications, deviceMapping === null || deviceMapping === void 0 ? void 0 : deviceMapping.infoKey);
141
+ accessory.category = deviceMapping?.category ?? 31 /* this.api.hap.Categories.TELEVISION */;
142
+ this.api.publishExternalAccessories(PLUGIN_NAME, [accessory]);
143
+ const tv = new TvAccessory(displayName, device, component, client, this.log, this, accessory, this.config.capabilityLogging ?? false, this.config.registerApplications ?? false, this.config.pollInterval ?? undefined, this.config.cyclicCallsLogging ?? false, deviceMapping?.macAddress, deviceMapping?.ipAddress, deviceMapping?.inputSources, deviceMapping?.applications, deviceMapping?.infoKey);
137
144
  await tv.registerCapabilities();
138
145
  if (this.config.registerPictureModes) {
139
146
  const modes = await tv.getPictureModes();
@@ -165,23 +172,22 @@ class SmartThingsPlatform {
165
172
  * @param deviceMappings the array of configured DeviceMapping
166
173
  */
167
174
  async registerSoundbarDevice(client, device, deviceMapping) {
168
- var _a, _b, _c, _d, _e;
169
175
  this.log.info('Adding new soundbar accessory: %s', device.name ? device.name + ' (' + device.deviceId + ')' : device.deviceId);
170
- const component = (_a = device.components) === null || _a === void 0 ? void 0 : _a.at(0);
176
+ const component = device.components?.at(0);
171
177
  if (!component) {
172
178
  this.log.info('Can\'t register soundbar accessory because (main) component does not exist');
173
179
  return;
174
180
  }
175
- let displayName = (_b = device.name) !== null && _b !== void 0 ? _b : device.deviceId;
176
- if (deviceMapping === null || deviceMapping === void 0 ? void 0 : deviceMapping.nameOverride) {
181
+ let displayName = device.name ?? device.deviceId;
182
+ if (deviceMapping?.nameOverride) {
177
183
  this.log.info('Overriding device default name \'%s\' with configured display name \'%s\'', device.name, deviceMapping.nameOverride);
178
184
  displayName = deviceMapping.nameOverride;
179
185
  }
180
186
  const accessory = new this.api.platformAccessory(displayName, device.deviceId);
181
187
  accessory.context.device = device;
182
- accessory.category = 31 /* this.api.hap.Categories.TELEVISION */;
183
- this.api.publishExternalAccessories(settings_1.PLUGIN_NAME, [accessory]);
184
- const tv = new soundbarAccessory_1.SoundbarAccessory(displayName, device, component, client, this.log, this, accessory, (_c = this.config.capabilityLogging) !== null && _c !== void 0 ? _c : false, (_d = this.config.pollInterval) !== null && _d !== void 0 ? _d : undefined, (_e = this.config.cyclicCallsLogging) !== null && _e !== void 0 ? _e : false, deviceMapping === null || deviceMapping === void 0 ? void 0 : deviceMapping.macAddress, deviceMapping === null || deviceMapping === void 0 ? void 0 : deviceMapping.ipAddress, deviceMapping === null || deviceMapping === void 0 ? void 0 : deviceMapping.inputSources);
188
+ accessory.category = deviceMapping?.category ?? 35 /* this.api.hap.Categories.TV_SET_TOP_BOX */;
189
+ this.api.publishExternalAccessories(PLUGIN_NAME, [accessory]);
190
+ const tv = new SoundbarAccessory(displayName, device, component, client, this.log, this, accessory, this.config.capabilityLogging ?? false, this.config.pollInterval ?? undefined, this.config.cyclicCallsLogging ?? false, deviceMapping?.macAddress, deviceMapping?.ipAddress, deviceMapping?.inputSources);
185
191
  await tv.registerCapabilities();
186
192
  if (this.config.registerVolumeSlider) {
187
193
  this.registerVolumeSlider(client, device, component);
@@ -203,14 +209,14 @@ class SmartThingsPlatform {
203
209
  const existingAccessory = this.accessories.find(accessory => accessory.UUID === id);
204
210
  if (existingAccessory) {
205
211
  this.log.info('Restoring existing accessory from cache: %s', existingAccessory.displayName);
206
- new switchAccessory_1.SwitchAccessory(device, component, client, this.log, this, existingAccessory, modes.capability, modes.command, mode.name);
212
+ new SwitchAccessory(device, component, client, this.log, this, existingAccessory, modes.capability, modes.command, mode.name);
207
213
  }
208
214
  else {
209
215
  const accessory = new this.api.platformAccessory(name, id);
210
216
  accessory.context.device = device;
211
217
  accessory.category = 8 /* this.api.hap.Categories.SWITCH */;
212
- new switchAccessory_1.SwitchAccessory(device, component, client, this.log, this, accessory, modes.capability, modes.command, mode.name);
213
- this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
218
+ new SwitchAccessory(device, component, client, this.log, this, accessory, modes.capability, modes.command, mode.name);
219
+ this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
214
220
  }
215
221
  }
216
222
  }
@@ -223,30 +229,28 @@ class SmartThingsPlatform {
223
229
  * @param component the SmartThings Device's Component
224
230
  */
225
231
  registerVolumeSlider(client, device, component) {
226
- var _a, _b, _c, _d;
227
232
  const id = this.api.hap.uuid.generate(`${device.deviceId}volume`);
228
233
  const name = 'Volume';
229
234
  const existingAccessory = this.accessories.find(accessory => accessory.UUID === id);
230
235
  if (existingAccessory) {
231
236
  this.log.info('Restoring existing accessory from cache: %s', existingAccessory.displayName);
232
- new sliderAccessory_1.SliderAccessory(device, component, client, this.log, this, existingAccessory, 'audioVolume', 'setVolume', (value) => {
233
- return value === null || value === void 0 ? void 0 : value.volume.value;
237
+ new SliderAccessory(device, component, client, this.log, this, existingAccessory, 'audioVolume', 'setVolume', (value) => {
238
+ return value?.volume.value;
234
239
  }, (value) => {
235
240
  return [value];
236
- }, (_a = this.config.pollInterval) !== null && _a !== void 0 ? _a : undefined, (_b = this.config.cyclicCallsLogging) !== null && _b !== void 0 ? _b : false);
241
+ }, this.config.pollInterval ?? undefined, this.config.cyclicCallsLogging ?? false);
237
242
  }
238
243
  else {
239
244
  const accessory = new this.api.platformAccessory(name, id);
240
245
  accessory.context.device = device;
241
246
  accessory.category = 5 /* this.api.hap.Categories.LIGHTBULB */;
242
- new sliderAccessory_1.SliderAccessory(device, component, client, this.log, this, accessory, 'audioVolume', 'setVolume', (value) => {
243
- return value === null || value === void 0 ? void 0 : value.volume.value;
247
+ new SliderAccessory(device, component, client, this.log, this, accessory, 'audioVolume', 'setVolume', (value) => {
248
+ return value?.volume.value;
244
249
  }, (value) => {
245
250
  return [value];
246
- }, (_c = this.config.pollInterval) !== null && _c !== void 0 ? _c : undefined, (_d = this.config.cyclicCallsLogging) !== null && _d !== void 0 ? _d : false);
247
- this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
251
+ }, this.config.pollInterval ?? undefined, this.config.cyclicCallsLogging ?? false);
252
+ this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
248
253
  }
249
254
  }
250
255
  }
251
- exports.SmartThingsPlatform = SmartThingsPlatform;
252
256
  //# sourceMappingURL=smartThingsPlatform.js.map