@o-lukas/homebridge-smartthings-tv 0.0.1

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.
@@ -0,0 +1,13 @@
1
+ FROM mcr.microsoft.com/devcontainers/javascript-node:0-18-bullseye
2
+
3
+ # Install homebridge
4
+ RUN npm install -g --unsafe-perm homebridge homebridge-config-ui-x
5
+
6
+ # Copy the default homebridge config
7
+ RUN mkdir /home/node/.homebridge \
8
+ && chown node /home/node/.homebridge
9
+ COPY homebridge-config/config.json /home/node/.homebridge/config.json
10
+ COPY homebridge-config/auth.json /home/node/.homebridge/auth.json
11
+
12
+ # Enable usage of ping command
13
+ RUN apt-get update && apt-get install iputils-ping
@@ -0,0 +1,22 @@
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the
2
+ // README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
3
+ {
4
+ "name": "Homebridge",
5
+ "dockerComposeFile": "docker-compose.yml",
6
+ "service": "homebridge",
7
+ "features": {
8
+ // "ghcr.io/devcontainers/features/node:1": {}
9
+ },
10
+ "forwardPorts": [
11
+ 51826,
12
+ 8581
13
+ ],
14
+ "customizations": {
15
+ "vscode": {
16
+ "extensions": [
17
+ "dbaeumer.vscode-eslint",
18
+ "eamodio.gitlens"
19
+ ]
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,9 @@
1
+ version: '2'
2
+ services:
3
+ homebridge:
4
+ build:
5
+ context: .
6
+ dockerfile: Dockerfile
7
+ restart: always
8
+ network_mode: host
9
+ command: sleep infinity
@@ -0,0 +1,10 @@
1
+ [
2
+ {
3
+ "id": 1,
4
+ "username": "admin",
5
+ "name": "admin",
6
+ "hashedPassword": "2a739a8c9faf3f58d1f1662c0ad09508125c46a1e306621ae89b7cb3ad43e074a09819e75a6b30a99c949a9abafd3dcf9f8a88e2f49b044d8ae1436fa46ccb30",
7
+ "salt": "82fdb7ee9d19003dbbe302bc14a00025f7dc982341abf8ac02d386648561124b",
8
+ "admin": true
9
+ }
10
+ ]
@@ -0,0 +1,27 @@
1
+ {
2
+ "bridge": {
3
+ "name": "Homebridge",
4
+ "username": "0E:DD:19:D5:34:EA",
5
+ "manufacturer": "homebridge.io",
6
+ "model": "homebridge",
7
+ "port": 51826,
8
+ "pin": "674-49-017",
9
+ "advertiser": "ciao"
10
+ },
11
+ "accessories": [],
12
+ "platforms": [
13
+ {
14
+ "name": "Config",
15
+ "port": 8581,
16
+ "auth": "none",
17
+ "theme": "auto",
18
+ "tempUnits": "c",
19
+ "lang": "en",
20
+ "platform": "config"
21
+ },
22
+ {
23
+ "name": "homebridge-smartthings-tv",
24
+ "platform": "smartthings-tv"
25
+ }
26
+ ]
27
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 o-lukas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Homebridge SmartThings TV
2
+
3
+ This is a plugin for [Homebridge](https://github.com/homebridge/homebridge). It offers some basic functions to control Samsung TVs using the SmartThings API.
4
+
5
+ # Configuration
6
+
7
+ The easiest way to configure the plugin is to use [Homebridge Config UI X](https://github.com/oznu/homebridge-config-ui-x) which should contain a description for every needed property. The only property needed to make the plugin work is the SmartThings API token. The other properties enable some additional functions but are not mandatory for the plugin to work.
8
+
9
+ If you don't use the [Homebridge Config UI X](https://github.com/oznu/homebridge-config-ui-x) see the following example for configuration:
10
+
11
+ ```json
12
+ {
13
+ "bridge": {
14
+ ...
15
+ },
16
+ "accessories": [],
17
+ "platforms": [
18
+ ...
19
+ {
20
+ "token": "your SmartThings API token",
21
+ "deviceMappings": [
22
+ {
23
+ "deviceId": "the SmartThings device ID",
24
+ "macAddress": "the mac address of the device (needed for wake-on-lan functionality)",
25
+ "ipAddress": "the ip address of the device (needed for ping functionality)"
26
+ }
27
+ ],
28
+ "platform": "smartthings-tv"
29
+ }
30
+ ...
31
+ ]
32
+ }
33
+ ```
34
+
35
+ ***
36
+
37
+ Since this is my first plugin it may contain some problems. Feel free to create an issue or pull request and I will try to help and fix the problems.
38
+
39
+ But since this plugin is developed in my spare time don't expect a quick fix.
@@ -0,0 +1,37 @@
1
+ {
2
+ "pluginAlias": "smartthings-tv",
3
+ "pluginType": "platform",
4
+ "singular": true,
5
+ "schema": {
6
+ "type": "object",
7
+ "properties": {
8
+ "token": {
9
+ "title": "SmartThings API token",
10
+ "type": "string",
11
+ "required": true,
12
+ "description": "The SmartThings API token is needed to authenticate the requests sent to the SmartThings API. To generate a token open https://account.smartthings.com/tokens and generate a new one (make sure at least devices is selected)."
13
+ },
14
+ "deviceMappings": {
15
+ "type": "array",
16
+ "items": {
17
+ "type": "object",
18
+ "description": "Use the device mappings when e.g. turning on the accessory does not work as expected. When a device mapping is available the wake-on-lan functionality is used to turn on the device instead of the SmartThings API. To make use of the functionality you must enter the mapping using the SmartThings device ID and the mac address of the device. If status does not show up properly you can use the ping functionality to determine the device status. To make use of it you must enter the SmartThings device ID and the ip address of the device.",
19
+ "properties": {
20
+ "deviceId": {
21
+ "type": "string",
22
+ "description": "The SmartThings device id. Check the log or go to https://account.smartthings.com/ and get the device id."
23
+ },
24
+ "macAddress": {
25
+ "type": "string",
26
+ "description": "The mac address of the device to turn device on using wake-on-lan functionality."
27
+ },
28
+ "ipAddress": {
29
+ "type": "string",
30
+ "description": "The IP address of the device (assign a static IP address to make sure it does not change) to determine the status using ping."
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,7 @@
1
+ import { API } from 'homebridge';
2
+ declare const _default: (api: API) => void;
3
+ /**
4
+ * This method registers the platform with Homebridge
5
+ */
6
+ export = _default;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;8BAQlB,GAAG;AAHlB;;GAEG;AACH,kBAEE"}
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ const settings_1 = require("./settings");
3
+ const platform_1 = require("./platform");
4
+ module.exports = (api) => {
5
+ api.registerPlatform(settings_1.PLATFORM_NAME, platform_1.SmartThingsPlatform);
6
+ };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,yCAA2C;AAC3C,yCAAiD;AAKjD,iBAAS,CAAC,GAAQ,EAAE,EAAE;IACpB,GAAG,CAAC,gBAAgB,CAAC,wBAAa,EAAE,8BAAmB,CAAC,CAAC;AAC3D,CAAC,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { API, DynamicPlatformPlugin, Logger, PlatformAccessory, PlatformConfig, Service, Characteristic, UnknownContext } from 'homebridge';
2
+ import { SmartThingsClient, Device } from '@smartthings/core-sdk';
3
+ /**
4
+ * Class implements the configured Device to mac and ip address mappings.
5
+ */
6
+ declare class DeviceMapping {
7
+ readonly deviceId: string;
8
+ readonly macAddress: string;
9
+ readonly ipAddress: string;
10
+ constructor(deviceId: string, macAddress: string, ipAddress: string);
11
+ }
12
+ /**
13
+ * Class implements the plugin platform.
14
+ */
15
+ export declare class SmartThingsPlatform implements DynamicPlatformPlugin {
16
+ readonly log: Logger;
17
+ readonly config: PlatformConfig;
18
+ readonly api: API;
19
+ readonly Service: typeof Service;
20
+ readonly Characteristic: typeof Characteristic;
21
+ readonly accessories: PlatformAccessory[];
22
+ constructor(log: Logger, config: PlatformConfig, api: API);
23
+ /**
24
+ * @inheritdoc
25
+ */
26
+ configureAccessory(accessory: PlatformAccessory): void;
27
+ /**
28
+ * Uses the SmartThings API to discover and register the available devices.
29
+ *
30
+ * @param token the SmartThings API token
31
+ * @param deviceMappings the array of configured DeviceMapping
32
+ */
33
+ discoverDevices(token: string, deviceMappings: [DeviceMapping]): void;
34
+ /**
35
+ * Registers a SmartThings Device for Homebridge.
36
+ *
37
+ * @param client the SmartThingsClient used to send API calls
38
+ * @param device the SmartThings Device
39
+ * @param deviceMappings the array of configured DeviceMapping
40
+ */
41
+ registerDevice(client: SmartThingsClient, device: Device, deviceMappings: [DeviceMapping]): void;
42
+ /**
43
+ * Registers a SmartThings TV Device for Homebridge.
44
+ *
45
+ * @param client the SmartThingsClient used to send API calls
46
+ * @param device the SmartThings Device
47
+ * @param accessory the cached PlatformAccessory or undefined if no cached PlatformAccessory exists
48
+ * @param deviceMappings the array of configured DeviceMapping
49
+ */
50
+ registerTvDevice(client: SmartThingsClient, device: Device, accessory: PlatformAccessory<UnknownContext> | undefined, deviceMapping: DeviceMapping | undefined): void;
51
+ }
52
+ export {};
53
+ //# sourceMappingURL=platform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAA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ingsPlatform = void 0;
4
+ const settings_1 = require("./settings");
5
+ const tvAccessory_1 = require("./tvAccessory");
6
+ const core_sdk_1 = require("@smartthings/core-sdk");
7
+ /**
8
+ * Class implements the configured Device to mac and ip address mappings.
9
+ */
10
+ class DeviceMapping {
11
+ constructor(deviceId, macAddress, ipAddress) {
12
+ this.deviceId = deviceId;
13
+ this.macAddress = macAddress;
14
+ this.ipAddress = ipAddress;
15
+ }
16
+ }
17
+ /**
18
+ * Class implements the plugin platform.
19
+ */
20
+ class SmartThingsPlatform {
21
+ constructor(log, config, api) {
22
+ this.log = log;
23
+ this.config = config;
24
+ this.api = api;
25
+ this.Service = this.api.hap.Service;
26
+ this.Characteristic = this.api.hap.Characteristic;
27
+ // this is used to track restored cached accessories
28
+ this.accessories = [];
29
+ this.log.debug('Finished initializing platform:', this.config.name);
30
+ if (!config.token) {
31
+ this.log.error('SmartThings API token must be configured');
32
+ return;
33
+ }
34
+ this.api.on('didFinishLaunching', () => {
35
+ log.debug('Executed didFinishLaunching callback');
36
+ this.discoverDevices(config.token, config.deviceMappings);
37
+ });
38
+ }
39
+ /**
40
+ * @inheritdoc
41
+ */
42
+ configureAccessory(accessory) {
43
+ this.log.info('Loading accessory from cache:', accessory.displayName);
44
+ this.accessories.push(accessory);
45
+ }
46
+ /**
47
+ * Uses the SmartThings API to discover and register the available devices.
48
+ *
49
+ * @param token the SmartThings API token
50
+ * @param deviceMappings the array of configured DeviceMapping
51
+ */
52
+ discoverDevices(token, deviceMappings) {
53
+ const client = new core_sdk_1.SmartThingsClient(new core_sdk_1.BearerTokenAuthenticator(token));
54
+ client.devices.list().then(devices => {
55
+ devices.forEach(device => {
56
+ this.registerDevice(client, device, deviceMappings);
57
+ });
58
+ });
59
+ }
60
+ /**
61
+ * Registers a SmartThings Device for Homebridge.
62
+ *
63
+ * @param client the SmartThingsClient used to send API calls
64
+ * @param device the SmartThings Device
65
+ * @param deviceMappings the array of configured DeviceMapping
66
+ */
67
+ registerDevice(client, device, deviceMappings) {
68
+ var _a, _b;
69
+ const existingAccessory = this.accessories.find(a => a.UUID === device.deviceId);
70
+ switch ((_a = device.ocf) === null || _a === void 0 ? void 0 : _a.ocfDeviceType) {
71
+ case 'oic.d.tv':
72
+ this.registerTvDevice(client, device, existingAccessory, deviceMappings.find(mapping => mapping.deviceId === device.deviceId));
73
+ break;
74
+ default:
75
+ this.log.info('Ignoring SmartThingsDevice:', device, 'because device type', (_b = device.ocf) === null || _b === void 0 ? void 0 : _b.ocfDeviceType, 'is not implemented');
76
+ break;
77
+ }
78
+ }
79
+ /**
80
+ * Registers a SmartThings TV Device for Homebridge.
81
+ *
82
+ * @param client the SmartThingsClient used to send API calls
83
+ * @param device the SmartThings Device
84
+ * @param accessory the cached PlatformAccessory or undefined if no cached PlatformAccessory exists
85
+ * @param deviceMappings the array of configured DeviceMapping
86
+ */
87
+ registerTvDevice(client, device, accessory, deviceMapping) {
88
+ var _a, _b;
89
+ this.log.info(accessory ? 'Restoring existing accessory from cache:' : 'Adding new accessory:', device.name ? device.name + ' (' + device.deviceId + ')' : device.deviceId);
90
+ const component = (_a = device.components) === null || _a === void 0 ? void 0 : _a.at(0);
91
+ if (!component) {
92
+ this.log.info('Can\'t register TV accessory because (main) component does not exist');
93
+ return;
94
+ }
95
+ if (!accessory) {
96
+ accessory = new this.api.platformAccessory((_b = device.name) !== null && _b !== void 0 ? _b : device.deviceId, device.deviceId);
97
+ accessory.context.device = device;
98
+ accessory.category = 31 /* TELEVISION */;
99
+ this.api.publishExternalAccessories(settings_1.PLUGIN_NAME, [accessory]);
100
+ }
101
+ new tvAccessory_1.TvAccessory(this.log, this, accessory, device, component, client, deviceMapping === null || deviceMapping === void 0 ? void 0 : deviceMapping.macAddress, deviceMapping === null || deviceMapping === void 0 ? void 0 : deviceMapping.ipAddress);
102
+ }
103
+ }
104
+ exports.SmartThingsPlatform = SmartThingsPlatform;
105
+ //# sourceMappingURL=platform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.js","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GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,0CAA0C,CAAC,CAAC,CAAC,uBAAuB,EAC5F,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAE9E,MAAM,SAAS,GAAG,MAAA,MAAM,CAAC,UAAU,0CAAE,EAAE,CAAC,CAAC,CAAC,CAAC;QAC3C,IAAI,CAAC,SAAS,EAAE;YACd,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,sEAAsE,CAAC,CAAC;YACtF,OAAO;SACR;QAED,IAAI,CAAC,SAAS,EAAE;YACd,SAAS,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,MAAA,MAAM,CAAC,IAAI,mCAAI,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC5F,SAAS,CAAC,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;YAClC,SAAS,CAAC,QAAQ,sBAAqC,CAAC;YACxD,IAAI,CAAC,GAAG,CAAC,0BAA0B,CAAC,sBAAW,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;SAC/D;QAED,IAAI,yBAAW,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,UAAU,EAAE,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,SAAS,CAAC,CAAC;IAC7H,CAAC;CACF;AApGD,kDAoGC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This is the name of the platform that users will use to register the plugin in the Homebridge config.json
3
+ */
4
+ export declare const PLATFORM_NAME = "smartthings-tv";
5
+ /**
6
+ * This must match the name of your plugin as defined the package.json
7
+ */
8
+ export declare const PLUGIN_NAME = "@o-lukas/homebridge-smartthings-tv";
9
+ //# sourceMappingURL=settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,aAAa,mBAAmB,CAAC;AAE9C;;GAEG;AACH,eAAO,MAAM,WAAW,uCAAuC,CAAC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PLUGIN_NAME = exports.PLATFORM_NAME = void 0;
4
+ /**
5
+ * This is the name of the platform that users will use to register the plugin in the Homebridge config.json
6
+ */
7
+ exports.PLATFORM_NAME = 'smartthings-tv';
8
+ /**
9
+ * This must match the name of your plugin as defined the package.json
10
+ */
11
+ exports.PLUGIN_NAME = '@o-lukas/homebridge-smartthings-tv';
12
+ //# sourceMappingURL=settings.js.map
@@ -0,0 +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"}
@@ -0,0 +1,134 @@
1
+ import { PlatformAccessory, Logger } from 'homebridge';
2
+ import { SmartThingsPlatform } from './platform';
3
+ import { SmartThingsClient, Device, Component } from '@smartthings/core-sdk';
4
+ /**
5
+ * Class implements a SmartThings TV accessory.
6
+ */
7
+ export declare class TvAccessory {
8
+ private readonly log;
9
+ private readonly platform;
10
+ private readonly accessory;
11
+ private readonly device;
12
+ private readonly component;
13
+ private readonly client;
14
+ private readonly macAddress;
15
+ private readonly ipAddress;
16
+ private service;
17
+ private speakerService;
18
+ private inputSources;
19
+ private capabilities;
20
+ constructor(log: Logger, platform: SmartThingsPlatform, accessory: PlatformAccessory, device: Device, component: Component, client: SmartThingsClient, macAddress?: string | undefined, ipAddress?: string | undefined);
21
+ /**
22
+ * Registers all available capabilities of the SmartThings Component.
23
+ *
24
+ * @param component the SmartThings Component
25
+ */
26
+ private registerCapabilities;
27
+ /**
28
+ * Registers the SmartThings Capablity if it's functionality is implemented.
29
+ *
30
+ * @param capability the Capability
31
+ */
32
+ private registerCapability;
33
+ /**
34
+ * Setter for Homebridge accessory Active property.
35
+ *
36
+ * @param value the CharacteristicValue
37
+ */
38
+ private setActive;
39
+ /**
40
+ * Getter for Homebridge accessory Active property.
41
+ *
42
+ * @returns the CharacteristicValue
43
+ */
44
+ private getActive;
45
+ /**
46
+ * Setter for Homebridge accessory VolumeSelector property.
47
+ *
48
+ * @param value the CharacteristicValue
49
+ */
50
+ private setVolumeSelector;
51
+ /**
52
+ * Setter for Homebridge accessory Volume property.
53
+ *
54
+ * @param value the CharacteristicValue
55
+ */
56
+ private setVolume;
57
+ /**
58
+ * Getter for Homebridge accessory Volume property.
59
+ *
60
+ * @returns the CharacteristicValue
61
+ */
62
+ private getVolume;
63
+ /**
64
+ * Setter for Homebridge accessory Mute property.
65
+ *
66
+ * @param value the CharacteristicValue
67
+ */
68
+ private setMute;
69
+ /**
70
+ * Getter for Homebridge accessory Mute property.
71
+ *
72
+ * @returns the CharacteristicValue
73
+ */
74
+ private getMute;
75
+ /**
76
+ * Setter for Homebridge accessory ActiveIdentifier property.
77
+ *
78
+ * @param value the CharacteristicValue
79
+ */
80
+ private setActiveIdentifier;
81
+ /**
82
+ * Getter for Homebridge accessory ActiveIdentifier property.
83
+ *
84
+ * @returns the CharacteristicValue
85
+ */
86
+ private getActiveIdentifier;
87
+ /**
88
+ * Setter for Homebridge accessory RemoteKey property.
89
+ *
90
+ * @param value the CharacteristicValue
91
+ */
92
+ private setRemoteKey;
93
+ /**
94
+ * Validates that the SmartThings Capability needed to execute the remote key is available.
95
+ *
96
+ * @param capabilityId the identifier of the SmartThings Capablity
97
+ * @param remoteKey the remote key
98
+ * @returns TRUE in case capability is available - FALSE otherwise
99
+ */
100
+ private validateRemoteKeyCapability;
101
+ /**
102
+ * Registers all available input sources.
103
+ */
104
+ private registerInputSources;
105
+ /**
106
+ * Guesses the InputSourceType from the identifier of the input source.
107
+ *
108
+ * @param inputSourceId the identifier of the input source
109
+ * @returns the InputSourceType (HDMI|TUNER|APPLICATION)
110
+ */
111
+ private guessInputSourceType;
112
+ /**
113
+ * Executes the command of the capability passed in using the arguments passed in.
114
+ * Handles error values returned by api.
115
+ *
116
+ * @param capability the capability identifier
117
+ * @param command the command identifier
118
+ * @param args the command arguments
119
+ */
120
+ private executeCommand;
121
+ /**
122
+ * Returns the status of the capability passed in.
123
+ * Handles error values returned by api.
124
+ *
125
+ * @param capability the capability identifier
126
+ * @returns the capability status or undefined for errors returned by API
127
+ */
128
+ private getCapabilityStatus;
129
+ private logInfo;
130
+ private logWarn;
131
+ private logError;
132
+ private logDebug;
133
+ }
134
+ //# sourceMappingURL=tvAccessory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tvAccessory.d.ts","sourceRoot":"","sources":["../src/tvAccessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,iBAAiB,EAAuB,MAAM,EAAE,MAAM,YAAY,CAAC;AAErF,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,SAAS,EAAc,MAAM,uBAAuB,CAAC;AAczF;;GAEG;AACH,qBAAa,WAAW;IAOpB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAb5B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,cAAc,CAAU;IAChC,OAAO,CAAC,YAAY,CAAiB;IACrC,OAAO,CAAC,YAAY,CAAgB;gBAGjB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,mBAAmB,EAC7B,SAAS,EAAE,iBAAiB,EAC5B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,iBAAiB,EACzB,UAAU,GAAE,MAAM,GAAG,SAAqB,EAC1C,SAAS,GAAE,MAAM,GAAG,SAAqB;IAwB5D;;;;OAIG;YACW,oBAAoB;IASlC;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IA4C1B;;;;OAIG;YACW,SAAS;IAcvB;;;;OAIG;YACW,SAAS;IAiBvB;;;;OAIG;YACW,iBAAiB;IAM/B;;;;OAIG;YACW,SAAS;IAKvB;;;;OAIG;YACW,SAAS;IAKvB;;;;OAIG;YACW,OAAO;IAKrB;;;;OAIG;YACW,OAAO;IAKrB;;;;OAIG;YACW,mBAAmB;IAKjC;;;;OAIG;YACW,mBAAmB;IAKjC;;;;OAIG;YACW,YAAY;IAkF1B;;;;;;OAMG;IACH,OAAO,CAAC,2BAA2B;IASnC;;OAEG;YACW,oBAAoB;IA0BlC;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IAU5B;;;;;;;OAOG;YACW,cAAc;IAY5B;;;;;;OAMG;YACW,mBAAmB;IAYjC,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,QAAQ;CAGjB"}
@@ -0,0 +1,397 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TvAccessory = void 0;
7
+ const wol_1 = require("wol");
8
+ const ping_1 = __importDefault(require("ping"));
9
+ class SamsungVdMediaInputSource {
10
+ constructor(id, name) {
11
+ this.id = id;
12
+ this.name = name;
13
+ }
14
+ }
15
+ /**
16
+ * Class implements a SmartThings TV accessory.
17
+ */
18
+ class TvAccessory {
19
+ constructor(log, platform, accessory, device, component, client, macAddress = undefined, ipAddress = undefined) {
20
+ var _a, _b, _c, _d, _e, _f;
21
+ this.log = log;
22
+ this.platform = platform;
23
+ this.accessory = accessory;
24
+ this.device = device;
25
+ this.component = component;
26
+ this.client = client;
27
+ this.macAddress = macAddress;
28
+ this.ipAddress = ipAddress;
29
+ this.inputSources = [];
30
+ this.capabilities = [];
31
+ this.accessory.getService(this.platform.Service.AccessoryInformation)
32
+ .setCharacteristic(this.platform.Characteristic.Name, (_a = device.name) !== null && _a !== void 0 ? _a : device.deviceId)
33
+ .setCharacteristic(this.platform.Characteristic.FirmwareRevision, (_c = (_b = device.ocf) === null || _b === void 0 ? void 0 : _b.firmwareVersion) !== null && _c !== void 0 ? _c : 'Unknown')
34
+ .setCharacteristic(this.platform.Characteristic.Manufacturer, device.manufacturerName)
35
+ .setCharacteristic(this.platform.Characteristic.Model, (_e = (_d = device.ocf) === null || _d === void 0 ? void 0 : _d.modelNumber) !== null && _e !== void 0 ? _e : 'Unknown');
36
+ this.service = this.accessory.getService(this.platform.Service.Television)
37
+ || this.accessory.addService(this.platform.Service.Television);
38
+ this.service
39
+ .setCharacteristic(this.platform.Characteristic.SleepDiscoveryMode, this.platform.Characteristic.SleepDiscoveryMode.ALWAYS_DISCOVERABLE)
40
+ .setCharacteristic(this.platform.Characteristic.ConfiguredName, (_f = device.name) !== null && _f !== void 0 ? _f : device.deviceId);
41
+ this.service.getCharacteristic(this.platform.Characteristic.RemoteKey)
42
+ .onSet(this.setRemoteKey.bind(this));
43
+ this.speakerService = this.accessory.getService(this.platform.Service.TelevisionSpeaker)
44
+ || this.accessory.addService(this.platform.Service.TelevisionSpeaker);
45
+ this.service.addLinkedService(this.speakerService);
46
+ this.registerCapabilities(component);
47
+ }
48
+ /**
49
+ * Registers all available capabilities of the SmartThings Component.
50
+ *
51
+ * @param component the SmartThings Component
52
+ */
53
+ async registerCapabilities(component) {
54
+ this.logInfo('Registering capabilities for component:', component.id);
55
+ component.capabilities.forEach(reference => {
56
+ var _a;
57
+ this.client.capabilities.get(reference.id, (_a = reference.version) !== null && _a !== void 0 ? _a : 0)
58
+ .then(capability => this.registerCapability(capability));
59
+ });
60
+ }
61
+ /**
62
+ * Registers the SmartThings Capablity if it's functionality is implemented.
63
+ *
64
+ * @param capability the Capability
65
+ */
66
+ registerCapability(capability) {
67
+ if (capability.id && !this.capabilities.includes(capability.id)) {
68
+ this.capabilities.push(capability.id);
69
+ }
70
+ switch (capability.id) {
71
+ case 'switch':
72
+ this.logInfo('Registering capability:', capability.name);
73
+ this.service.getCharacteristic(this.platform.Characteristic.Active)
74
+ .onSet(this.setActive.bind(this))
75
+ .onGet(this.getActive.bind(this));
76
+ break;
77
+ case 'audioVolume':
78
+ this.logInfo('Registering capability:', capability.name);
79
+ this.speakerService
80
+ .setCharacteristic(this.platform.Characteristic.Active, this.platform.Characteristic.Active.ACTIVE);
81
+ this.speakerService
82
+ .setCharacteristic(this.platform.Characteristic.VolumeControlType, this.platform.Characteristic.VolumeControlType.ABSOLUTE);
83
+ this.speakerService
84
+ .getCharacteristic(this.platform.Characteristic.Volume)
85
+ .onGet(this.getVolume.bind(this))
86
+ .onSet(this.setVolume.bind(this));
87
+ this.speakerService.getCharacteristic(this.platform.Characteristic.VolumeSelector)
88
+ .onSet(this.setVolumeSelector.bind(this));
89
+ break;
90
+ case 'audioMute':
91
+ this.logInfo('Registering capability:', capability.name);
92
+ this.speakerService.getCharacteristic(this.platform.Characteristic.Mute)
93
+ .onSet(this.setMute.bind(this))
94
+ .onGet(this.getMute.bind(this));
95
+ break;
96
+ case 'samsungvd.mediaInputSource':
97
+ this.logInfo('Registering capability:', capability.name);
98
+ this.registerInputSources();
99
+ this.service.getCharacteristic(this.platform.Characteristic.ActiveIdentifier)
100
+ .onSet(this.setActiveIdentifier.bind(this))
101
+ .onGet(this.getActiveIdentifier.bind(this));
102
+ break;
103
+ }
104
+ }
105
+ /**
106
+ * Setter for Homebridge accessory Active property.
107
+ *
108
+ * @param value the CharacteristicValue
109
+ */
110
+ async setActive(value) {
111
+ this.logDebug('Set active to:', value);
112
+ if (value) {
113
+ if (this.macAddress) {
114
+ this.logDebug('Use wake-on-lan functionality because mac-address has been configured');
115
+ (0, wol_1.wake)(this.macAddress);
116
+ }
117
+ else {
118
+ this.executeCommand('switch', 'on');
119
+ }
120
+ }
121
+ else {
122
+ this.executeCommand('switch', 'off');
123
+ }
124
+ }
125
+ /**
126
+ * Getter for Homebridge accessory Active property.
127
+ *
128
+ * @returns the CharacteristicValue
129
+ */
130
+ async getActive() {
131
+ if (this.ipAddress) {
132
+ try {
133
+ return ping_1.default.promise.probe(this.ipAddress).then(status => {
134
+ this.logDebug('ping status:', status);
135
+ return status === null || status === void 0 ? void 0 : status.alive;
136
+ });
137
+ }
138
+ catch (exc) {
139
+ this.logError('error when pinging device:', exc, '\nping command fails mostly because of permission issues - falling back to SmartThings API for getting active state');
140
+ }
141
+ }
142
+ const status = await this.getCapabilityStatus('switch');
143
+ return (status === null || status === void 0 ? void 0 : status.switch.value) === 'on' ? true : false;
144
+ }
145
+ /**
146
+ * Setter for Homebridge accessory VolumeSelector property.
147
+ *
148
+ * @param value the CharacteristicValue
149
+ */
150
+ async setVolumeSelector(value) {
151
+ const increment = value === this.platform.Characteristic.VolumeSelector.INCREMENT;
152
+ this.logDebug(increment ? 'Increasing' : 'Decreasing' + ' volume');
153
+ this.executeCommand('audioVolume', increment ? 'volumeUp' : 'volumeDown');
154
+ }
155
+ /**
156
+ * Setter for Homebridge accessory Volume property.
157
+ *
158
+ * @param value the CharacteristicValue
159
+ */
160
+ async setVolume(value) {
161
+ this.logDebug('Set volume to:', value);
162
+ this.executeCommand('audioVolume', 'setVolume', [value]);
163
+ }
164
+ /**
165
+ * Getter for Homebridge accessory Volume property.
166
+ *
167
+ * @returns the CharacteristicValue
168
+ */
169
+ async getVolume() {
170
+ const status = await this.getCapabilityStatus('audioVolume');
171
+ return status === null || status === void 0 ? void 0 : status.volume.value;
172
+ }
173
+ /**
174
+ * Setter for Homebridge accessory Mute property.
175
+ *
176
+ * @param value the CharacteristicValue
177
+ */
178
+ async setMute(value) {
179
+ this.logDebug('Set mute to:', value);
180
+ this.executeCommand('audioMute', value ? 'mute' : 'unmute');
181
+ }
182
+ /**
183
+ * Getter for Homebridge accessory Mute property.
184
+ *
185
+ * @returns the CharacteristicValue
186
+ */
187
+ async getMute() {
188
+ const status = await this.getCapabilityStatus('audioMute');
189
+ return (status === null || status === void 0 ? void 0 : status.mute.value) === 'muted' ? true : false;
190
+ }
191
+ /**
192
+ * Setter for Homebridge accessory ActiveIdentifier property.
193
+ *
194
+ * @param value the CharacteristicValue
195
+ */
196
+ async setActiveIdentifier(value) {
197
+ var _a;
198
+ this.logDebug('Set active identifier to:', value);
199
+ this.executeCommand('samsungvd.mediaInputSource', 'setInputSource', [(_a = this.inputSources[value].name) !== null && _a !== void 0 ? _a : '']);
200
+ }
201
+ /**
202
+ * Getter for Homebridge accessory ActiveIdentifier property.
203
+ *
204
+ * @returns the CharacteristicValue
205
+ */
206
+ async getActiveIdentifier() {
207
+ const status = await this.getCapabilityStatus('samsungvd.mediaInputSource');
208
+ return this.inputSources.findIndex(inputSource => inputSource.name === (status === null || status === void 0 ? void 0 : status.inputSource.value));
209
+ }
210
+ /**
211
+ * Setter for Homebridge accessory RemoteKey property.
212
+ *
213
+ * @param value the CharacteristicValue
214
+ */
215
+ async setRemoteKey(value) {
216
+ switch (value) {
217
+ case this.platform.Characteristic.RemoteKey.REWIND:
218
+ if (this.validateRemoteKeyCapability('mediaPlayback', 'REWIND')) {
219
+ this.executeCommand('mediaPlayback', 'rewind');
220
+ }
221
+ break;
222
+ case this.platform.Characteristic.RemoteKey.FAST_FORWARD:
223
+ if (this.validateRemoteKeyCapability('mediaPlayback', 'FAST_FORWARD')) {
224
+ this.executeCommand('mediaPlayback', 'fastForward');
225
+ }
226
+ break;
227
+ case this.platform.Characteristic.RemoteKey.NEXT_TRACK:
228
+ if (this.validateRemoteKeyCapability('mediaTrackControl', 'NEXT_TRACK')) {
229
+ this.executeCommand('mediaTrackControl', 'nextTrack');
230
+ }
231
+ break;
232
+ case this.platform.Characteristic.RemoteKey.PREVIOUS_TRACK:
233
+ if (this.validateRemoteKeyCapability('mediaTrackControl', 'PREVIOUS_TRACK')) {
234
+ this.executeCommand('mediaTrackControl', 'previousTrack');
235
+ }
236
+ break;
237
+ case this.platform.Characteristic.RemoteKey.ARROW_UP:
238
+ if (this.validateRemoteKeyCapability('samsungvd.remoteControl', 'ARROW_UP')) {
239
+ this.executeCommand('samsungvd.remoteControl', 'send', ['UP']);
240
+ }
241
+ break;
242
+ case this.platform.Characteristic.RemoteKey.ARROW_DOWN:
243
+ if (this.validateRemoteKeyCapability('samsungvd.remoteControl', 'ARROW_DOWN')) {
244
+ this.executeCommand('samsungvd.remoteControl', 'send', ['DOWN']);
245
+ }
246
+ break;
247
+ case this.platform.Characteristic.RemoteKey.ARROW_LEFT:
248
+ if (this.validateRemoteKeyCapability('samsungvd.remoteControl', 'ARROW_LEFT')) {
249
+ this.executeCommand('samsungvd.remoteControl', 'send', ['LEFT']);
250
+ }
251
+ break;
252
+ case this.platform.Characteristic.RemoteKey.ARROW_RIGHT:
253
+ if (this.validateRemoteKeyCapability('samsungvd.remoteControl', 'ARROW_RIGHT')) {
254
+ this.executeCommand('samsungvd.remoteControl', 'send', ['RIGHT']);
255
+ }
256
+ break;
257
+ case this.platform.Characteristic.RemoteKey.SELECT:
258
+ if (this.validateRemoteKeyCapability('samsungvd.remoteControl', 'SELECT')) {
259
+ this.executeCommand('samsungvd.remoteControl', 'send', ['OK']);
260
+ }
261
+ break;
262
+ case this.platform.Characteristic.RemoteKey.BACK:
263
+ if (this.validateRemoteKeyCapability('samsungvd.remoteControl', 'BACK')) {
264
+ this.executeCommand('samsungvd.remoteControl', 'send', ['BACK']);
265
+ }
266
+ break;
267
+ case this.platform.Characteristic.RemoteKey.EXIT:
268
+ if (this.validateRemoteKeyCapability('samsungvd.remoteControl', 'EXIT')) {
269
+ this.executeCommand('samsungvd.remoteControl', 'send', ['HOME']);
270
+ }
271
+ break;
272
+ case this.platform.Characteristic.RemoteKey.PLAY_PAUSE:
273
+ if (this.validateRemoteKeyCapability('mediaPlayback', 'PLAY_PAUSE')) {
274
+ this.executeCommand('mediaPlayback', 'play');
275
+ }
276
+ break;
277
+ case this.platform.Characteristic.RemoteKey.INFORMATION:
278
+ if (this.validateRemoteKeyCapability('samsungvd.remoteControl', 'INFORMATION')) {
279
+ this.executeCommand('samsungvd.remoteControl', 'send', ['MENU']);
280
+ }
281
+ break;
282
+ }
283
+ }
284
+ /**
285
+ * Validates that the SmartThings Capability needed to execute the remote key is available.
286
+ *
287
+ * @param capabilityId the identifier of the SmartThings Capablity
288
+ * @param remoteKey the remote key
289
+ * @returns TRUE in case capability is available - FALSE otherwise
290
+ */
291
+ validateRemoteKeyCapability(capabilityId, remoteKey) {
292
+ if (this.capabilities.includes(capabilityId)) {
293
+ return true;
294
+ }
295
+ else {
296
+ this.logError('can\'t handle RemoteKey', remoteKey, 'because', capabilityId, 'capability is not available');
297
+ return false;
298
+ }
299
+ }
300
+ /**
301
+ * Registers all available input sources.
302
+ */
303
+ async registerInputSources() {
304
+ this.client.devices.getCapabilityStatus(this.device.deviceId, this.component.id, 'samsungvd.mediaInputSource')
305
+ .then(status => {
306
+ const supportedInputSources = [...new Set(status.supportedInputSourcesMap.value)];
307
+ this.inputSources.forEach(inputSource => this.service.removeLinkedService(inputSource));
308
+ this.inputSources = [];
309
+ for (let i = 0; i < supportedInputSources.length; i++) {
310
+ const inputSource = supportedInputSources[i];
311
+ this.logInfo('Registering input source:', inputSource.name);
312
+ const inputSourceService = this.accessory.getService(inputSource.id)
313
+ || this.accessory.addService(this.platform.Service.InputSource, inputSource.id, inputSource.id);
314
+ inputSourceService.name = inputSource.id;
315
+ inputSourceService
316
+ .setCharacteristic(this.platform.Characteristic.Identifier, i)
317
+ .setCharacteristic(this.platform.Characteristic.ConfiguredName, inputSource.name)
318
+ .setCharacteristic(this.platform.Characteristic.IsConfigured, this.platform.Characteristic.IsConfigured.CONFIGURED)
319
+ .setCharacteristic(this.platform.Characteristic.InputSourceType, this.guessInputSourceType(inputSource.id));
320
+ this.service.addLinkedService(inputSourceService);
321
+ this.inputSources[i] = inputSourceService;
322
+ }
323
+ });
324
+ }
325
+ /**
326
+ * Guesses the InputSourceType from the identifier of the input source.
327
+ *
328
+ * @param inputSourceId the identifier of the input source
329
+ * @returns the InputSourceType (HDMI|TUNER|APPLICATION)
330
+ */
331
+ guessInputSourceType(inputSourceId) {
332
+ if (inputSourceId.startsWith('HDMI')) {
333
+ return this.platform.Characteristic.InputSourceType.HDMI;
334
+ }
335
+ else if (inputSourceId === 'dtv') {
336
+ return this.platform.Characteristic.InputSourceType.TUNER;
337
+ }
338
+ else {
339
+ return this.platform.Characteristic.InputSourceType.APPLICATION;
340
+ }
341
+ }
342
+ /**
343
+ * Executes the command of the capability passed in using the arguments passed in.
344
+ * Handles error values returned by api.
345
+ *
346
+ * @param capability the capability identifier
347
+ * @param command the command identifier
348
+ * @param args the command arguments
349
+ */
350
+ async executeCommand(capability, command, args = []) {
351
+ this.client.devices.executeCommand(this.device.deviceId, {
352
+ capability: capability,
353
+ command: command,
354
+ arguments: args,
355
+ }).then(() => {
356
+ this.logDebug('Successfully executed command', capability, '.', command);
357
+ }).catch(error => {
358
+ this.logError('Error when executing', capability, '.', command, ':', error);
359
+ });
360
+ }
361
+ /**
362
+ * Returns the status of the capability passed in.
363
+ * Handles error values returned by api.
364
+ *
365
+ * @param capability the capability identifier
366
+ * @returns the capability status or undefined for errors returned by API
367
+ */
368
+ async getCapabilityStatus(capability) {
369
+ return this.client.devices.getCapabilityStatus(this.device.deviceId, this.component.id, capability)
370
+ .then(status => {
371
+ this.logDebug('Successfully get status of ', capability, ':', status);
372
+ return status;
373
+ })
374
+ .catch(error => {
375
+ this.logError('Error when getting status of', capability, ':', error);
376
+ return undefined;
377
+ });
378
+ }
379
+ logInfo(message, ...parameters) {
380
+ var _a;
381
+ this.log.debug('[' + ((_a = this.device.name) !== null && _a !== void 0 ? _a : this.device.deviceId) + '] ' + message, ...parameters);
382
+ }
383
+ logWarn(message, ...parameters) {
384
+ var _a;
385
+ this.log.warn('[' + ((_a = this.device.name) !== null && _a !== void 0 ? _a : this.device.deviceId) + '] ' + message, ...parameters);
386
+ }
387
+ logError(message, ...parameters) {
388
+ var _a;
389
+ this.log.error('[' + ((_a = this.device.name) !== null && _a !== void 0 ? _a : this.device.deviceId) + '] ' + message, ...parameters);
390
+ }
391
+ logDebug(message, ...parameters) {
392
+ var _a;
393
+ this.log.debug('[' + ((_a = this.device.name) !== null && _a !== void 0 ? _a : this.device.deviceId) + '] ' + message, ...parameters);
394
+ }
395
+ }
396
+ exports.TvAccessory = TvAccessory;
397
+ //# sourceMappingURL=tvAccessory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tvAccessory.js","sourceRoot":"","sources":["../src/tvAccessory.ts"],"names":[],"mappings":";;;;;;AAIA,6BAA2B;AAC3B,gDAAwB;AAExB,MAAM,yBAAyB;IAI7B,YAAY,EAAU,EAAE,IAAY;QAClC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED;;GAEG;AACH,MAAa,WAAW;IAMtB,YACmB,GAAW,EACX,QAA6B,EAC7B,SAA4B,EAC5B,MAAc,EACd,SAAoB,EACpB,MAAyB,EACzB,aAAiC,SAAS,EAC1C,YAAgC,SAAS;;QAPzC,QAAG,GAAH,GAAG,CAAQ;QACX,aAAQ,GAAR,QAAQ,CAAqB;QAC7B,cAAS,GAAT,SAAS,CAAmB;QAC5B,WAAM,GAAN,MAAM,CAAQ;QACd,cAAS,GAAT,SAAS,CAAW;QACpB,WAAM,GAAN,MAAM,CAAmB;QACzB,eAAU,G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MAAM,CAAC,QAAQ,CAAC,GAAG,IAAI,GAAG,OAAO,EAAE,GAAG,UAAU,CAAC,CAAC;IACnG,CAAC;IAEO,QAAQ,CAAC,OAAe,EAAE,GAAG,UAAqB;;QACxD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,MAAA,IAAI,CAAC,MAAM,CAAC,IAAI,mCAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAI,GAAG,OAAO,EAAE,GAAG,UAAU,CAAC,CAAC;IACnG,CAAC;CACF;AA/ZD,kCA+ZC"}
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "displayName": "Homebridge SmartThings TV",
3
+ "name": "@o-lukas/homebridge-smartthings-tv",
4
+ "version": "0.0.1",
5
+ "description": "Plugin to access samsung TVs using the SmartThings API",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/o-lukas/homebridge-smartthings-tv.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/o-lukas/homebridge-smartthings-tv/issues"
13
+ },
14
+ "engines": {
15
+ "node": ">=14.18.1",
16
+ "homebridge": ">=1.3.5"
17
+ },
18
+ "main": "dist/index.js",
19
+ "scripts": {
20
+ "lint": "eslint src/**.ts --max-warnings=0",
21
+ "watch": "npm run build && npm link && nodemon",
22
+ "build": "rimraf ./dist && tsc",
23
+ "prepublishOnly": "npm run lint && npm run build"
24
+ },
25
+ "keywords": [
26
+ "homebridge-plugin"
27
+ ],
28
+ "dependencies": {
29
+ "@smartthings/core-sdk": "^5.2.0",
30
+ "ping": "^0.4.2",
31
+ "wol": "^1.0.7"
32
+ },
33
+ "devDependencies": {
34
+ "@types/node": "^16.10.9",
35
+ "@types/ping": "^0.4.1",
36
+ "@types/wol": "^1.0.1",
37
+ "@typescript-eslint/eslint-plugin": "^5.0.0",
38
+ "@typescript-eslint/parser": "^5.0.0",
39
+ "eslint": "^8.0.1",
40
+ "homebridge": "^1.3.5",
41
+ "nodemon": "^2.0.13",
42
+ "rimraf": "^3.0.2",
43
+ "ts-node": "^10.3.0",
44
+ "typescript": "^4.4.4"
45
+ }
46
+ }