@o-lukas/homebridge-smartthings-tv 2.1.3 → 2.2.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 +26 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -1
- package/dist/settings.d.ts +0 -1
- package/dist/settings.js +2 -5
- package/dist/settings.js.map +1 -1
- package/dist/sliderAccessory.d.ts +2 -3
- package/dist/sliderAccessory.js +14 -11
- package/dist/sliderAccessory.js.map +1 -1
- package/dist/smartThingsAccessory.d.ts +1 -2
- package/dist/smartThingsAccessory.js +15 -18
- package/dist/smartThingsAccessory.js.map +1 -1
- package/dist/smartThingsPlatform.d.ts +9 -1
- package/dist/smartThingsPlatform.js +75 -38
- package/dist/smartThingsPlatform.js.map +1 -1
- package/dist/soundbarAccessory.d.ts +127 -0
- package/dist/soundbarAccessory.js +353 -0
- package/dist/soundbarAccessory.js.map +1 -0
- package/dist/switchAccessory.d.ts +2 -3
- package/dist/switchAccessory.js +8 -8
- package/dist/switchAccessory.js.map +1 -1
- package/dist/tvAccessory.d.ts +2 -3
- package/dist/tvAccessory.js +47 -48
- package/dist/tvAccessory.js.map +1 -1
- package/eslint.config.js +35 -0
- package/package.json +30 -22
- package/dist/index.d.ts.map +0 -1
- package/dist/settings.d.ts.map +0 -1
- package/dist/sliderAccessory.d.ts.map +0 -1
- package/dist/smartThingsAccessory.d.ts.map +0 -1
- package/dist/smartThingsPlatform.d.ts.map +0 -1
- package/dist/switchAccessory.d.ts.map +0 -1
- package/dist/tvAccessory.d.ts.map +0 -1
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { PlatformAccessory, Logger } from 'homebridge';
|
|
2
|
+
import { SmartThingsPlatform } from './smartThingsPlatform.js';
|
|
3
|
+
import { SmartThingsClient, Device, Component } from '@smartthings/core-sdk';
|
|
4
|
+
import { SmartThingsAccessory } from './smartThingsAccessory.js';
|
|
5
|
+
/**
|
|
6
|
+
* Class implements a SmartThings soundbar accessory.
|
|
7
|
+
*/
|
|
8
|
+
export declare class SoundbarAccessory extends SmartThingsAccessory {
|
|
9
|
+
private readonly logCapabilities;
|
|
10
|
+
private readonly pollingInterval;
|
|
11
|
+
private readonly cyclicCallsLogging;
|
|
12
|
+
private readonly macAddress;
|
|
13
|
+
private readonly ipAddress;
|
|
14
|
+
private readonly inputSources;
|
|
15
|
+
private service;
|
|
16
|
+
private speakerService;
|
|
17
|
+
private inputSourceServices;
|
|
18
|
+
private capabilities;
|
|
19
|
+
private activeIdentifierChangeTime;
|
|
20
|
+
private activeIdentifierChangeValue;
|
|
21
|
+
constructor(name: string, device: Device, component: Component, client: SmartThingsClient, log: Logger, platform: SmartThingsPlatform, accessory: PlatformAccessory, logCapabilities: boolean, pollingInterval: number | undefined, cyclicCallsLogging: boolean, macAddress?: string | undefined, ipAddress?: string | undefined, inputSources?: [{
|
|
22
|
+
name: string;
|
|
23
|
+
id: string;
|
|
24
|
+
}] | undefined);
|
|
25
|
+
/**
|
|
26
|
+
* Registers all available capabilities of the SmartThings Component.
|
|
27
|
+
*/
|
|
28
|
+
registerCapabilities(): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Registers the SmartThings Capablity if it's functionality is implemented.
|
|
31
|
+
*
|
|
32
|
+
* @param capability the Capability
|
|
33
|
+
*/
|
|
34
|
+
private registerCapability;
|
|
35
|
+
/**
|
|
36
|
+
* Setter for Homebridge accessory Active property.
|
|
37
|
+
*
|
|
38
|
+
* @param value the CharacteristicValue
|
|
39
|
+
*/
|
|
40
|
+
private setActive;
|
|
41
|
+
/**
|
|
42
|
+
* Getter for Homebridge accessory Active property.
|
|
43
|
+
*
|
|
44
|
+
* @param log flag to turn logging on/off
|
|
45
|
+
* @returns the CharacteristicValue
|
|
46
|
+
*/
|
|
47
|
+
private getActive;
|
|
48
|
+
/**
|
|
49
|
+
* Setter for Homebridge accessory VolumeSelector property.
|
|
50
|
+
*
|
|
51
|
+
* @param value the CharacteristicValue
|
|
52
|
+
*/
|
|
53
|
+
private setVolumeSelector;
|
|
54
|
+
/**
|
|
55
|
+
* Setter for Homebridge accessory Volume property.
|
|
56
|
+
*
|
|
57
|
+
* @param value the CharacteristicValue
|
|
58
|
+
*/
|
|
59
|
+
private setVolume;
|
|
60
|
+
/**
|
|
61
|
+
* Getter for Homebridge accessory Volume property.
|
|
62
|
+
*
|
|
63
|
+
* @param log flag to turn logging on/off
|
|
64
|
+
* @returns the CharacteristicValue
|
|
65
|
+
*/
|
|
66
|
+
private getVolume;
|
|
67
|
+
/**
|
|
68
|
+
* Setter for Homebridge accessory Mute property.
|
|
69
|
+
*
|
|
70
|
+
* @param value the CharacteristicValue
|
|
71
|
+
*/
|
|
72
|
+
private setMute;
|
|
73
|
+
/**
|
|
74
|
+
* Getter for Homebridge accessory Mute property.
|
|
75
|
+
*
|
|
76
|
+
* @param log flag to turn logging on/off
|
|
77
|
+
* @returns the CharacteristicValue
|
|
78
|
+
*/
|
|
79
|
+
private getMute;
|
|
80
|
+
/**
|
|
81
|
+
* Setter for Homebridge accessory ActiveIdentifier property.
|
|
82
|
+
*
|
|
83
|
+
* @param value the CharacteristicValue
|
|
84
|
+
*/
|
|
85
|
+
private setActiveIdentifier;
|
|
86
|
+
/**
|
|
87
|
+
* Getter for Homebridge accessory ActiveIdentifier property.
|
|
88
|
+
*
|
|
89
|
+
* @param log flag to turn logging on/off
|
|
90
|
+
* @returns the CharacteristicValue
|
|
91
|
+
*/
|
|
92
|
+
private getActiveIdentifier;
|
|
93
|
+
/**
|
|
94
|
+
* Setter for Homebridge accessory RemoteKey property.
|
|
95
|
+
*
|
|
96
|
+
* @param value the CharacteristicValue
|
|
97
|
+
*/
|
|
98
|
+
private setRemoteKey;
|
|
99
|
+
/**
|
|
100
|
+
* Validates that the SmartThings Capability needed to execute the remote key is available.
|
|
101
|
+
*
|
|
102
|
+
* @param capabilityId the identifier of the SmartThings Capablity
|
|
103
|
+
* @param remoteKey the remote key
|
|
104
|
+
* @returns TRUE in case capability is available - FALSE otherwise
|
|
105
|
+
*/
|
|
106
|
+
private validateRemoteKeyCapability;
|
|
107
|
+
/**
|
|
108
|
+
* Registers all available media input sources (e.g. HDMI inputs).
|
|
109
|
+
*/
|
|
110
|
+
private registerAvailableInputSources;
|
|
111
|
+
/**
|
|
112
|
+
* Registers a Homebridge input source.
|
|
113
|
+
*
|
|
114
|
+
* @param id the input source id
|
|
115
|
+
* @param name the input source display name
|
|
116
|
+
* @param inputSource the InputSourceType or @code undefined @endcode to use @link guessInputSourceType @endlink
|
|
117
|
+
* to determine InputSourceType
|
|
118
|
+
*/
|
|
119
|
+
private registerInputSource;
|
|
120
|
+
/**
|
|
121
|
+
* Guesses the InputSourceType from the identifier of the input source.
|
|
122
|
+
*
|
|
123
|
+
* @param inputSourceId the identifier of the input source
|
|
124
|
+
* @returns the InputSourceType (HDMI|TUNER|OTHER)
|
|
125
|
+
*/
|
|
126
|
+
private guessInputSourceType;
|
|
127
|
+
}
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { wake } from 'wol';
|
|
2
|
+
import ping from 'ping';
|
|
3
|
+
import { SmartThingsAccessory } from './smartThingsAccessory.js';
|
|
4
|
+
/**
|
|
5
|
+
* Class implements a SmartThings soundbar accessory.
|
|
6
|
+
*/
|
|
7
|
+
export class SoundbarAccessory extends SmartThingsAccessory {
|
|
8
|
+
logCapabilities;
|
|
9
|
+
pollingInterval;
|
|
10
|
+
cyclicCallsLogging;
|
|
11
|
+
macAddress;
|
|
12
|
+
ipAddress;
|
|
13
|
+
inputSources;
|
|
14
|
+
service;
|
|
15
|
+
speakerService;
|
|
16
|
+
inputSourceServices = [];
|
|
17
|
+
capabilities = [];
|
|
18
|
+
activeIdentifierChangeTime = 0;
|
|
19
|
+
activeIdentifierChangeValue = 0;
|
|
20
|
+
constructor(name, device, component, client, log, platform, accessory, logCapabilities, pollingInterval, cyclicCallsLogging, macAddress = undefined, ipAddress = undefined, inputSources = undefined) {
|
|
21
|
+
super(device, component, client, platform, accessory, log);
|
|
22
|
+
this.logCapabilities = logCapabilities;
|
|
23
|
+
this.pollingInterval = pollingInterval;
|
|
24
|
+
this.cyclicCallsLogging = cyclicCallsLogging;
|
|
25
|
+
this.macAddress = macAddress;
|
|
26
|
+
this.ipAddress = ipAddress;
|
|
27
|
+
this.inputSources = inputSources;
|
|
28
|
+
this.accessory.getService(this.platform.Service.AccessoryInformation)
|
|
29
|
+
.setCharacteristic(this.platform.Characteristic.Name, name);
|
|
30
|
+
this.service = this.accessory.getService(this.platform.Service.Television)
|
|
31
|
+
?? this.accessory.addService(this.platform.Service.Television);
|
|
32
|
+
this.service
|
|
33
|
+
.setCharacteristic(this.platform.Characteristic.SleepDiscoveryMode, this.platform.Characteristic.SleepDiscoveryMode.ALWAYS_DISCOVERABLE)
|
|
34
|
+
.setCharacteristic(this.platform.Characteristic.ConfiguredName, name);
|
|
35
|
+
this.service.getCharacteristic(this.platform.Characteristic.RemoteKey)
|
|
36
|
+
.onSet(this.setRemoteKey.bind(this));
|
|
37
|
+
this.speakerService = this.accessory.getService(this.platform.Service.TelevisionSpeaker)
|
|
38
|
+
?? this.accessory.addService(this.platform.Service.TelevisionSpeaker);
|
|
39
|
+
this.service.addLinkedService(this.speakerService);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Registers all available capabilities of the SmartThings Component.
|
|
43
|
+
*/
|
|
44
|
+
async registerCapabilities() {
|
|
45
|
+
this.logInfo('Registering capabilities for component %s', this.component.id);
|
|
46
|
+
for (const reference of this.component.capabilities) {
|
|
47
|
+
await this.registerCapability(await this.client.capabilities.get(reference.id, reference.version ?? 0));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Registers the SmartThings Capablity if it's functionality is implemented.
|
|
52
|
+
*
|
|
53
|
+
* @param capability the Capability
|
|
54
|
+
*/
|
|
55
|
+
async registerCapability(capability) {
|
|
56
|
+
let inputSourcePollingStarted = false;
|
|
57
|
+
if (this.logCapabilities) {
|
|
58
|
+
this.logDebug('Available capability: %s', JSON.stringify(capability, null, 2));
|
|
59
|
+
}
|
|
60
|
+
if (capability.id && !this.capabilities.includes(capability.id)) {
|
|
61
|
+
this.capabilities.push(capability.id);
|
|
62
|
+
}
|
|
63
|
+
switch (capability.id) {
|
|
64
|
+
case 'switch':
|
|
65
|
+
this.logCapabilityRegistration(capability);
|
|
66
|
+
this.service.getCharacteristic(this.platform.Characteristic.Active)
|
|
67
|
+
.onSet(this.setActive.bind(this))
|
|
68
|
+
.onGet(this.getActive.bind(this));
|
|
69
|
+
this.startStatusPolling(capability.name, this.service, this.platform.Characteristic.Active, this.getActive.bind(this, this.cyclicCallsLogging), this.pollingInterval);
|
|
70
|
+
break;
|
|
71
|
+
case 'audioVolume':
|
|
72
|
+
this.logCapabilityRegistration(capability);
|
|
73
|
+
this.speakerService
|
|
74
|
+
.setCharacteristic(this.platform.Characteristic.Active, this.platform.Characteristic.Active.ACTIVE);
|
|
75
|
+
this.speakerService
|
|
76
|
+
.setCharacteristic(this.platform.Characteristic.VolumeControlType, this.platform.Characteristic.VolumeControlType.ABSOLUTE);
|
|
77
|
+
this.speakerService
|
|
78
|
+
.getCharacteristic(this.platform.Characteristic.Volume)
|
|
79
|
+
.onGet(this.getVolume.bind(this))
|
|
80
|
+
.onSet(this.setVolume.bind(this));
|
|
81
|
+
this.speakerService.getCharacteristic(this.platform.Characteristic.VolumeSelector)
|
|
82
|
+
.onSet(this.setVolumeSelector.bind(this));
|
|
83
|
+
this.startStatusPolling(capability.name, this.speakerService, this.platform.Characteristic.Volume, this.getVolume.bind(this, this.cyclicCallsLogging), this.pollingInterval);
|
|
84
|
+
break;
|
|
85
|
+
case 'audioMute':
|
|
86
|
+
this.logCapabilityRegistration(capability);
|
|
87
|
+
this.speakerService.getCharacteristic(this.platform.Characteristic.Mute)
|
|
88
|
+
.onSet(this.setMute.bind(this))
|
|
89
|
+
.onGet(this.getMute.bind(this));
|
|
90
|
+
this.startStatusPolling(capability.name, this.speakerService, this.platform.Characteristic.Mute, this.getMute.bind(this, this.cyclicCallsLogging), this.pollingInterval);
|
|
91
|
+
break;
|
|
92
|
+
case 'samsungvd.audioInputSource':
|
|
93
|
+
this.logCapabilityRegistration(capability);
|
|
94
|
+
await this.registerAvailableInputSources();
|
|
95
|
+
if (this.inputSourceServices.length > 0) {
|
|
96
|
+
this.service.getCharacteristic(this.platform.Characteristic.ActiveIdentifier)
|
|
97
|
+
.onSet(this.setActiveIdentifier.bind(this))
|
|
98
|
+
.onGet(this.getActiveIdentifier.bind(this));
|
|
99
|
+
if (!inputSourcePollingStarted) {
|
|
100
|
+
inputSourcePollingStarted = true;
|
|
101
|
+
this.startStatusPolling('activeIdentifier', this.service, this.platform.Characteristic.ActiveIdentifier, this.getActiveIdentifier.bind(this, this.cyclicCallsLogging), this.pollingInterval);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Setter for Homebridge accessory Active property.
|
|
109
|
+
*
|
|
110
|
+
* @param value the CharacteristicValue
|
|
111
|
+
*/
|
|
112
|
+
async setActive(value) {
|
|
113
|
+
this.logDebug('Set active to: %s', value);
|
|
114
|
+
if (value) {
|
|
115
|
+
if (this.macAddress) {
|
|
116
|
+
this.logDebug('Use wake-on-lan functionality because mac-address has been configured');
|
|
117
|
+
if (await wake(this.macAddress)) {
|
|
118
|
+
this.logDebug('Successfully woke device');
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
this.logError('Could not wake device - if this error keeps occuring try to disable wake-on-lan functionality');
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
await this.executeCommand('switch', 'on');
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
await this.executeCommand('switch', 'off');
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Getter for Homebridge accessory Active property.
|
|
134
|
+
*
|
|
135
|
+
* @param log flag to turn logging on/off
|
|
136
|
+
* @returns the CharacteristicValue
|
|
137
|
+
*/
|
|
138
|
+
async getActive(log = true) {
|
|
139
|
+
if (this.ipAddress) {
|
|
140
|
+
try {
|
|
141
|
+
const status = await ping.promise.probe(this.ipAddress);
|
|
142
|
+
if (log) {
|
|
143
|
+
this.logDebug('ping status: %s', status);
|
|
144
|
+
}
|
|
145
|
+
return status?.alive;
|
|
146
|
+
}
|
|
147
|
+
catch (exc) {
|
|
148
|
+
this.logError('error when pinging device: %s\n\
|
|
149
|
+
ping command fails mostly because of permission issues - falling back to SmartThings API for getting active state', exc);
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const status = await this.getCapabilityStatus('switch', log);
|
|
154
|
+
return status?.switch.value === 'on' ? true : false;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Setter for Homebridge accessory VolumeSelector property.
|
|
158
|
+
*
|
|
159
|
+
* @param value the CharacteristicValue
|
|
160
|
+
*/
|
|
161
|
+
async setVolumeSelector(value) {
|
|
162
|
+
const increment = value === this.platform.Characteristic.VolumeSelector.INCREMENT;
|
|
163
|
+
this.logDebug('%s volume', increment ? 'Increasing' : 'Decreasing');
|
|
164
|
+
await this.executeCommand('audioVolume', increment ? 'volumeUp' : 'volumeDown');
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Setter for Homebridge accessory Volume property.
|
|
168
|
+
*
|
|
169
|
+
* @param value the CharacteristicValue
|
|
170
|
+
*/
|
|
171
|
+
async setVolume(value) {
|
|
172
|
+
this.logDebug('Set volume to: %s', value);
|
|
173
|
+
await this.executeCommand('audioVolume', 'setVolume', [value]);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Getter for Homebridge accessory Volume property.
|
|
177
|
+
*
|
|
178
|
+
* @param log flag to turn logging on/off
|
|
179
|
+
* @returns the CharacteristicValue
|
|
180
|
+
*/
|
|
181
|
+
async getVolume(log = true) {
|
|
182
|
+
const status = await this.getCapabilityStatus('audioVolume', log);
|
|
183
|
+
return status?.volume.value;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Setter for Homebridge accessory Mute property.
|
|
187
|
+
*
|
|
188
|
+
* @param value the CharacteristicValue
|
|
189
|
+
*/
|
|
190
|
+
async setMute(value) {
|
|
191
|
+
this.logDebug('Set mute to: %s', value);
|
|
192
|
+
await this.executeCommand('audioMute', value ? 'mute' : 'unmute');
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Getter for Homebridge accessory Mute property.
|
|
196
|
+
*
|
|
197
|
+
* @param log flag to turn logging on/off
|
|
198
|
+
* @returns the CharacteristicValue
|
|
199
|
+
*/
|
|
200
|
+
async getMute(log = true) {
|
|
201
|
+
const status = await this.getCapabilityStatus('audioMute', log);
|
|
202
|
+
return status?.mute.value === 'muted' ? true : false;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Setter for Homebridge accessory ActiveIdentifier property.
|
|
206
|
+
*
|
|
207
|
+
* @param value the CharacteristicValue
|
|
208
|
+
*/
|
|
209
|
+
async setActiveIdentifier(value) {
|
|
210
|
+
this.logDebug('Set active identifier to: %s', value);
|
|
211
|
+
const inputSource = this.inputSourceServices[value];
|
|
212
|
+
this.activeIdentifierChangeTime = Date.now();
|
|
213
|
+
this.activeIdentifierChangeValue = value;
|
|
214
|
+
// HACK: because samsungvd.audioInputSource does not support setting input source use
|
|
215
|
+
// mediaInputSource samsungvd.audioInputSource to get list of supported sources
|
|
216
|
+
await this.executeCommand('mediaInputSource', 'setInputSource', [inputSource.name ?? '']);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Getter for Homebridge accessory ActiveIdentifier property.
|
|
220
|
+
*
|
|
221
|
+
* @param log flag to turn logging on/off
|
|
222
|
+
* @returns the CharacteristicValue
|
|
223
|
+
*/
|
|
224
|
+
async getActiveIdentifier(log = true) {
|
|
225
|
+
const status = await this.getCapabilityStatus('samsungvd.audioInputSource', log);
|
|
226
|
+
if (Date.parse(status?.inputSource.timestamp ?? '') > this.activeIdentifierChangeTime) {
|
|
227
|
+
const id = this.inputSourceServices.findIndex(inputSource => inputSource.name === status?.inputSource.value);
|
|
228
|
+
if (log) {
|
|
229
|
+
this.logDebug('ActiveIdentifier has been changed on the device - using API result: %s', id);
|
|
230
|
+
}
|
|
231
|
+
if (id < 0) {
|
|
232
|
+
this.logWarn('Could not find input source for name \'%s\' - using first input source \'%s\' as active identifier', status?.inputSource.value, this.inputSourceServices[0].name);
|
|
233
|
+
return 0;
|
|
234
|
+
}
|
|
235
|
+
return id;
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
if (log) {
|
|
239
|
+
this.logDebug('ActiveIdentifier has not been changed on the device - using temporary result: %s', this.activeIdentifierChangeValue);
|
|
240
|
+
}
|
|
241
|
+
return this.activeIdentifierChangeValue;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Setter for Homebridge accessory RemoteKey property.
|
|
246
|
+
*
|
|
247
|
+
* @param value the CharacteristicValue
|
|
248
|
+
*/
|
|
249
|
+
async setRemoteKey(value) {
|
|
250
|
+
switch (value) {
|
|
251
|
+
case this.platform.Characteristic.RemoteKey.REWIND:
|
|
252
|
+
if (this.validateRemoteKeyCapability('mediaPlayback', 'REWIND')) {
|
|
253
|
+
await this.executeCommand('mediaPlayback', 'rewind');
|
|
254
|
+
}
|
|
255
|
+
break;
|
|
256
|
+
case this.platform.Characteristic.RemoteKey.FAST_FORWARD:
|
|
257
|
+
if (this.validateRemoteKeyCapability('mediaPlayback', 'FAST_FORWARD')) {
|
|
258
|
+
await this.executeCommand('mediaPlayback', 'fastForward');
|
|
259
|
+
}
|
|
260
|
+
break;
|
|
261
|
+
case this.platform.Characteristic.RemoteKey.PLAY_PAUSE:
|
|
262
|
+
if (this.validateRemoteKeyCapability('mediaPlayback', 'PLAY_PAUSE')) {
|
|
263
|
+
await this.executeCommand('mediaPlayback', 'play');
|
|
264
|
+
}
|
|
265
|
+
break;
|
|
266
|
+
case this.platform.Characteristic.RemoteKey.EXIT:
|
|
267
|
+
if (this.validateRemoteKeyCapability('mediaPlayback', 'EXIT')) {
|
|
268
|
+
await this.executeCommand('mediaPlayback', 'stop');
|
|
269
|
+
}
|
|
270
|
+
break;
|
|
271
|
+
case this.platform.Characteristic.RemoteKey.BACK:
|
|
272
|
+
if (this.validateRemoteKeyCapability('mediaPlayback', 'BACK')) {
|
|
273
|
+
await this.executeCommand('mediaPlayback', 'stop');
|
|
274
|
+
}
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Validates that the SmartThings Capability needed to execute the remote key is available.
|
|
280
|
+
*
|
|
281
|
+
* @param capabilityId the identifier of the SmartThings Capablity
|
|
282
|
+
* @param remoteKey the remote key
|
|
283
|
+
* @returns TRUE in case capability is available - FALSE otherwise
|
|
284
|
+
*/
|
|
285
|
+
validateRemoteKeyCapability(capabilityId, remoteKey) {
|
|
286
|
+
if (this.capabilities.includes(capabilityId)) {
|
|
287
|
+
return true;
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
this.logError('can\'t handle RemoteKey %s because %s capability is not available', remoteKey, capabilityId);
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Registers all available media input sources (e.g. HDMI inputs).
|
|
296
|
+
*/
|
|
297
|
+
async registerAvailableInputSources() {
|
|
298
|
+
const status = await this.client.devices.getCapabilityStatus(this.device.deviceId, this.component.id, 'samsungvd.audioInputSource');
|
|
299
|
+
const supportedInputSources = [...new Set(status.supportedInputSources.value)].map((s) => {
|
|
300
|
+
return {
|
|
301
|
+
name: s,
|
|
302
|
+
id: s,
|
|
303
|
+
};
|
|
304
|
+
});
|
|
305
|
+
if (this.inputSources) {
|
|
306
|
+
this.logInfo('Overriding default input sources map "%s" with custom map "%s"', JSON.stringify(supportedInputSources, null, 2), JSON.stringify(this.inputSources, null, 2));
|
|
307
|
+
}
|
|
308
|
+
for (const inputSource of this.inputSources ?? supportedInputSources) {
|
|
309
|
+
this.registerInputSource(inputSource.id, inputSource.name);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Registers a Homebridge input source.
|
|
314
|
+
*
|
|
315
|
+
* @param id the input source id
|
|
316
|
+
* @param name the input source display name
|
|
317
|
+
* @param inputSource the InputSourceType or @code undefined @endcode to use @link guessInputSourceType @endlink
|
|
318
|
+
* to determine InputSourceType
|
|
319
|
+
*/
|
|
320
|
+
registerInputSource(id, name, inputSource = undefined) {
|
|
321
|
+
this.logInfo('Registering input source: %s (%s)', name, id);
|
|
322
|
+
let inputSourceType = inputSource;
|
|
323
|
+
if (inputSourceType === undefined) {
|
|
324
|
+
inputSourceType = this.guessInputSourceType(id);
|
|
325
|
+
this.logDebug('Guessed input source type for %s is: %i', name, inputSourceType);
|
|
326
|
+
}
|
|
327
|
+
const inputSourceService = this.accessory.getService(id)
|
|
328
|
+
?? this.accessory.addService(this.platform.Service.InputSource, id, id);
|
|
329
|
+
inputSourceService.name = id;
|
|
330
|
+
inputSourceService
|
|
331
|
+
.setCharacteristic(this.platform.Characteristic.Identifier, this.inputSourceServices.length)
|
|
332
|
+
.setCharacteristic(this.platform.Characteristic.ConfiguredName, name)
|
|
333
|
+
.setCharacteristic(this.platform.Characteristic.IsConfigured, this.platform.Characteristic.IsConfigured.CONFIGURED)
|
|
334
|
+
.setCharacteristic(this.platform.Characteristic.InputSourceType, inputSourceType);
|
|
335
|
+
this.service.addLinkedService(inputSourceService);
|
|
336
|
+
this.inputSourceServices.push(inputSourceService);
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Guesses the InputSourceType from the identifier of the input source.
|
|
340
|
+
*
|
|
341
|
+
* @param inputSourceId the identifier of the input source
|
|
342
|
+
* @returns the InputSourceType (HDMI|TUNER|OTHER)
|
|
343
|
+
*/
|
|
344
|
+
guessInputSourceType(inputSourceId) {
|
|
345
|
+
if (inputSourceId.startsWith('HDMI')) {
|
|
346
|
+
return this.platform.Characteristic.InputSourceType.HDMI;
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
return this.platform.Characteristic.InputSourceType.OTHER;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
//# sourceMappingURL=soundbarAccessory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"soundbarAccessory.js","sourceRoot":"","sources":["../src/soundbarAccessory.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,oBAAoB;IAgBtC;IACA;IACA;IACA;IACA;IACA;IApBX,OAAO,CAAU;IACjB,cAAc,CAAU;IACxB,mBAAmB,GAAc,EAAE,CAAC;IACpC,YAAY,GAAa,EAAE,CAAC;IAC5B,0BAA0B,GAAG,CAAC,CAAC;IAC/B,2BAA2B,GAAG,CAAC,CAAC;IAExC,YACE,IAAY,EACZ,MAAc,EACd,SAAoB,EACpB,MAAyB,EACzB,GAAW,EACX,QAA6B,EAC7B,SAA4B,EACX,eAAwB,EACxB,eAAmC,EACnC,kBAA2B,EAC3B,aAAiC,SAAS,EAC1C,YAAgC,SAAS,EACzC,eAA2D,SAAS;QAErF,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;QAP1C,oBAAe,GAAf,eAAe,CAAS;QACxB,oBAAe,GAAf,eAAe,CAAoB;QACnC,uBAAkB,GAAlB,kBAAkB,CAAS;QAC3B,eAAU,GAAV,UAAU,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,OAAO,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QAC1E,kBAAkB,CAAC,IAAI,GAAG,EAAE,CAAC;QAC7B,kBAAkB;aACf,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,UAAU,EAAE,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC;aAC3F,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,cAAc,EAAE,IAAI,CAAC;aACpE,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,YAAY,CAAC,UAAU,CAAC;aAClH,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC;QACpF,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;QAElD,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IACpD,CAAC;IAED;;;;;OAKG;IACK,oBAAoB,CAAC,aAAqB;QAChD,IAAI,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YACrC,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,eAAe,CAAC,IAAI,CAAC;QAC3D,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,eAAe,CAAC,KAAK,CAAC;QAC5D,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PlatformAccessory, Logger } from 'homebridge';
|
|
2
|
-
import { SmartThingsPlatform } from './smartThingsPlatform';
|
|
2
|
+
import { SmartThingsPlatform } from './smartThingsPlatform.js';
|
|
3
3
|
import { SmartThingsClient, Device, Component } from '@smartthings/core-sdk';
|
|
4
|
-
import { SmartThingsAccessory } from './smartThingsAccessory';
|
|
4
|
+
import { SmartThingsAccessory } from './smartThingsAccessory.js';
|
|
5
5
|
/**
|
|
6
6
|
* Class implements a stateless switch accessory to execute a capability commmand.
|
|
7
7
|
*/
|
|
@@ -14,4 +14,3 @@ export declare class SwitchAccessory extends SmartThingsAccessory {
|
|
|
14
14
|
private handleGet;
|
|
15
15
|
private handleSet;
|
|
16
16
|
}
|
|
17
|
-
//# sourceMappingURL=switchAccessory.d.ts.map
|
package/dist/switchAccessory.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SwitchAccessory = void 0;
|
|
4
|
-
const smartThingsAccessory_1 = require("./smartThingsAccessory");
|
|
1
|
+
import { SmartThingsAccessory } from './smartThingsAccessory.js';
|
|
5
2
|
/**
|
|
6
3
|
* Class implements a stateless switch accessory to execute a capability commmand.
|
|
7
4
|
*/
|
|
8
|
-
class SwitchAccessory extends
|
|
5
|
+
export class SwitchAccessory extends SmartThingsAccessory {
|
|
6
|
+
capability;
|
|
7
|
+
command;
|
|
8
|
+
value;
|
|
9
|
+
service;
|
|
9
10
|
constructor(device, component, client, log, platform, accessory, capability, command, value) {
|
|
10
|
-
var _a;
|
|
11
11
|
super(device, component, client, platform, accessory, log);
|
|
12
12
|
this.capability = capability;
|
|
13
13
|
this.command = command;
|
|
14
14
|
this.value = value;
|
|
15
|
-
this.service =
|
|
15
|
+
this.service = this.accessory.getService(this.platform.Service.Switch) ??
|
|
16
|
+
this.accessory.addService(this.platform.Service.Switch);
|
|
16
17
|
this.service.getCharacteristic(this.platform.Characteristic.On)
|
|
17
18
|
.onGet(this.handleGet.bind(this))
|
|
18
19
|
.onSet(this.handleSet.bind(this));
|
|
@@ -30,5 +31,4 @@ class SwitchAccessory extends smartThingsAccessory_1.SmartThingsAccessory {
|
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
|
-
exports.SwitchAccessory = SwitchAccessory;
|
|
34
34
|
//# sourceMappingURL=switchAccessory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switchAccessory.js","sourceRoot":"","sources":["../src/switchAccessory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"switchAccessory.js","sourceRoot":"","sources":["../src/switchAccessory.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,oBAAoB;IAUpC;IACA;IACA;IAXF,OAAO,CAAU;IAElC,YACE,MAAc,EACd,SAAoB,EACpB,MAAyB,EACzB,GAAW,EACX,QAA6B,EAC7B,SAA4B,EACX,UAAkB,EAClB,OAAe,EACf,KAAa;QAE9B,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;QAJ1C,eAAU,GAAV,UAAU,CAAQ;QAClB,YAAO,GAAP,OAAO,CAAQ;QACf,UAAK,GAAL,KAAK,CAAQ;QAI9B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC;YACpE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC1D,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;aAC5D,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAChC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACtC,CAAC;IAEO,SAAS;QACf,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,KAAK,CAAC,SAAS,CAAC,KAA0B;QAChD,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,IAAI,CAAC,QAAQ,CAAC,oBAAoB,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;YACjE,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;YAEvE,UAAU,CAAC,GAAG,EAAE;gBACd,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;YACzE,CAAC,EAAE,GAAG,CAAC,CAAC;QACV,CAAC;IACH,CAAC;CACF"}
|
package/dist/tvAccessory.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PlatformAccessory, Logger } from 'homebridge';
|
|
2
|
-
import { SmartThingsPlatform } from './smartThingsPlatform';
|
|
2
|
+
import { SmartThingsPlatform } from './smartThingsPlatform.js';
|
|
3
3
|
import { SmartThingsClient, Device, Component } from '@smartthings/core-sdk';
|
|
4
|
-
import { SmartThingsAccessory } from './smartThingsAccessory';
|
|
4
|
+
import { SmartThingsAccessory } from './smartThingsAccessory.js';
|
|
5
5
|
/**
|
|
6
6
|
* Class implements a SmartThings TV accessory.
|
|
7
7
|
*/
|
|
@@ -173,4 +173,3 @@ export declare class TvAccessory extends SmartThingsAccessory {
|
|
|
173
173
|
*/
|
|
174
174
|
private guessInputSourceType;
|
|
175
175
|
}
|
|
176
|
-
//# sourceMappingURL=tvAccessory.d.ts.map
|