Skip to content

Commit

Permalink
feat: add property to control info key behavior
Browse files Browse the repository at this point in the history
closes #368
  • Loading branch information
o-lukas committed Jun 28, 2024
1 parent 9d34b29 commit c34159d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ The following snippets shows all available properties you can use for the plugin
"macAddress": "xx:xx:xx:xx:xx:xx",
"ping": true,
"ipAddress": "xx:xx:xx:xx:xx:xx",
"infoKey": "MENU",
"inputSources": [
{
"name": "xxxx",
Expand Down Expand Up @@ -164,6 +165,10 @@ Enables usage of ping functionality to determine if device is turned on. Use onl

The IP address of the device (assign a static IP address to make sure it does not change) to determine the status using ping.

### infoKey

The key to be emulated when pressing info button in HomeKit remote. The list of valid values must be read from the log as it differs per device. To do so enable capabilityLogging and look for log entry containing the possible values.

### inputSources

Overrides the device's default input sources map to add custom input sources. Check the log for information about the default input sources.
Expand Down
5 changes: 5 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@
"functionBody": "return model.deviceMappings[arrayIndices].ping === true;"
}
},
"infoKey": {
"title": "Info key",
"type": "string",
"description": "The key to be emulated when pressing info button in HomeKit remote. The list of valid values must be read from the log as it differs per device. To do so enable capabilityLogging and look for log entry containing the possible values."
},
"inputSources": {
"title": "Custom input sources list",
"type": "array",
Expand Down
7 changes: 5 additions & 2 deletions src/smartThingsPlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class DeviceMapping {
public readonly macAddress: string,
public readonly ipAddress: string,
public readonly inputSources: [{name: string; id: string}],
public readonly applications: [{name: string; ids: [string]}]) {
public readonly applications: [{name: string; ids: [string]}],
public readonly infoKey: string) {
}
}

Expand Down Expand Up @@ -162,7 +163,9 @@ export class SmartThingsPlatform implements DynamicPlatformPlugin {
deviceMapping?.macAddress,
deviceMapping?.ipAddress,
deviceMapping?.inputSources,
deviceMapping?.applications);
deviceMapping?.applications,
deviceMapping?.infoKey,
);
await tv.registerCapabilities();

if (this.config.registerPictureModes) {
Expand Down
8 changes: 7 additions & 1 deletion src/tvAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class TvAccessory extends SmartThingsAccessory {
private readonly ipAddress: string | undefined = undefined,
private readonly inputSources: [{name: string; id: string}] | undefined = undefined,
private readonly applications: [{name: string; ids: [string]}] | undefined = undefined,
private readonly informationKey: string | undefined = undefined,
) {
super(device, component, client, platform, accessory, log);

Expand Down Expand Up @@ -217,6 +218,11 @@ export class TvAccessory extends SmartThingsAccessory {
this.logInfo('Not registering capability because registering of applications has been disabled: %s', capability.name);
}
break;

case 'samsungvd.remoteControl':
this.logError('Possible infoKey values are: %s',
JSON.stringify(capability.commands?.send.arguments?.find(a => a.name === 'keyValue')?.schema.enum, null, 2));
break;
}
}

Expand Down Expand Up @@ -455,7 +461,7 @@ ping command fails mostly because of permission issues - falling back to SmartTh

case this.platform.Characteristic.RemoteKey.INFORMATION:
if (this.validateRemoteKeyCapability('samsungvd.remoteControl', 'INFORMATION')) {
await this.executeCommand('samsungvd.remoteControl', 'send', ['MENU']);
await this.executeCommand('samsungvd.remoteControl', 'send', [this.informationKey ?? 'MENU']);
}
break;
}
Expand Down

0 comments on commit c34159d

Please sign in to comment.