Skip to content

Commit

Permalink
New: Added support for Samsung vendor specific media input sources
Browse files Browse the repository at this point in the history
  • Loading branch information
petarhristov94 committed Apr 25, 2024
1 parent 828a65a commit b01e27e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
10 changes: 7 additions & 3 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
},
"input": {
"type": "string",
"enum": ["digitalTv", "HDMI1", "HDMI2", "HDMI3", "HDMI4", "HDMI5", "HDMI6", "USB", "AM", "FM"]
"enum": ["digitalTv", "HDMI1", "HDMI2", "HDMI3", "HDMI4", "HDMI5", "HDMI6", "Display Port", "USB", "USB-C", "AM", "FM"]
},
"sleep": {
"type": "integer"
Expand Down Expand Up @@ -254,7 +254,7 @@
},
{
"key": "devices[].mac",
"title": "MAC Address",
"title": "Network MAC Address",
"placeholder": "A0:B1:C2:D3:E4:F5"
}
]
Expand Down Expand Up @@ -327,7 +327,7 @@
"condition": {
"functionBody": "return model.devices[arrayIndices[0]].inputs[arrayIndices[1]].type == 'input';"
},
"enum": ["digitalTv", "HDMI1", "HDMI2", "HDMI3", "HDMI4", "HDMI5", "HDMI6", "USB", "AM", "FM"],
"enum": ["digitalTv", "HDMI1", "HDMI2", "HDMI3", "HDMI4", "HDMI5", "HDMI6", "Display Port", "USB", "USB-C", "AM", "FM"],
"titleMap": {
"digitalTv": "Live TV",
"HDMI1": "HDMI 1",
Expand All @@ -336,7 +336,9 @@
"HDMI4": "HDMI 4",
"HDMI5": "HDMI 5",
"HDMI6": "HDMI 6",
"Display Port": "Display Port",
"USB": "USB",
"USB-C": "USB-C",
"AM": "AM",
"FM": "FM"
}
Expand Down Expand Up @@ -391,6 +393,8 @@
"titleMap": {
"digitalTv": "Live TV",
"USB": "USB",
"USB-C": "USB-C",
"Display Port": "Display Port",
"HDMI1": "HDMI 1",
"HDMI2": "HDMI 2",
"HDMI3": "HDMI 3",
Expand Down
2 changes: 1 addition & 1 deletion lib/services/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = class Input {
return Hap.Characteristic.InputSourceType.TUNER;
}

if (this.config.value == 'USB') {
if (this.config.value && this.config.value.startsWith('USB')) {
return Hap.Characteristic.InputSourceType.USB;
}

Expand Down
8 changes: 7 additions & 1 deletion lib/smartthings.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ module.exports = class SmartThings {
}

setInputSource(value) {
return this.sendCommands({component: 'main', capability: 'mediaInputSource', command: 'setInputSource', arguments: [value]});
// Try to set input source with Samsung-specific vendor extended capability (used in e.g. smart monitors)
return this.sendCommands({component: 'main', capability: 'samsungvd.mediaInputSource', command: 'setInputSource', arguments: [value]})
.catch((error) => {
// Catch errors (422) potentially due to unsupported capability and fallback to standard capability (used in most Samsung TVs)
this.device.log.debug('Failed to set input source with Samsung-specific vendor extended capability, falling back to standard capability.', error);
return this.sendCommands({component: 'main', capability: 'mediaInputSource', command: 'setInputSource', arguments: [value]});
});
}

setPictureMode(value) {
Expand Down

0 comments on commit b01e27e

Please sign in to comment.