Closed huddx01 closed 2 years ago
Yeah the input source is difficult. On the Samsung Remote the Source button just cycles through all the inputs, one after the other. You cannot even change the cycle direction. So the only applicable name you could ever have on the HomeKit TV controller would be something like "Next Source". And also I only know the Source command for the TV, but not for the Home Theater. I wish I knew if for the Home Theater... Let me look at it again - maybe today as it is raining - and see what I can do.
Oh yeah, this is a bit work in progress, it was a copy-paste from my EOSSTB plugin, and I need to clean it up a bit!
For the Input Source, it would be best just to send a KEY_ Command... Like "KEY_TV" für TV Source or "KEY_HDMI"to switch to HDMI Input...
Yeah that's what I built in. But the Home app only sends the command when the input is changed in the input list, so to cycle through all the sources you need SOURCE and NEXT SOURCE. I'm adding in a double tap and triple tap function on the remote, to allow for a fully customizable remote with multiple layers of buttons.
I'm adding in a double tap and triple tap function on the remote, to allow for a fully customizable remote with multiple layers of buttons.
for me the Remote-App is not so important. Its ok if the Input Sources would work from the Home-App. With the goal to make the inputs (or custom Commands) be accessible directly from Siri...
I tried quickn dirty, to switch to TV-Input...
look at the line in prepareTelevisionService()... of course i always fires
the index 0 from the array.... So TV Switches always to TV Source when any of the input sources is fried up... but its a first step...
.on('set', (newInputIdentifier, callback) => { this.setInput(this.inputList[0], callback); });
//Prepare Television service
prepareTelevisionService() {
if (this.debugLevel > 0) {
this.log.warn('prepareTelevisionService');
}
this.televisionService = new Service.Television(this.name, 'televisionService');
this.televisionService
.setCharacteristic(Characteristic.ConfiguredName, this.name)
.setCharacteristic(Characteristic.SleepDiscoveryMode, Characteristic.SleepDiscoveryMode.ALWAYS_DISCOVERAB$
/* // not yet working
this.televisionService.getCharacteristic(Characteristic.ConfiguredName)
.on('get', this.getDeviceName.bind(this))
.on('set', (newName, callback) => { this.setDeviceName(newName, callback); });
*/
this.televisionService.getCharacteristic(Characteristic.Active)
.on('get', this.getPower.bind(this))
.on('set', this.setPower.bind(this));
this.televisionService.getCharacteristic(Characteristic.ActiveIdentifier)
.on('get', this.getInput.bind(this))
.on('set', (newInputIdentifier, callback) => { this.setInput(this.inputList[0], callback); });
// .on('set', (newInputIdentifier, callback) => { this.setInput(Characteristic.ConfiguredName, callback);$
//.on('set', this.sendKey('KEY_MUTE'));
this.televisionService.getCharacteristic(Characteristic.RemoteKey)
.on('set', this.setRemoteKey.bind(this));
this.televisionService.getCharacteristic(Characteristic.PowerModeSelection)
.on('set', this.setPowerModeSelection.bind(this));
this.televisionService.getCharacteristic(Characteristic.CurrentMediaState)
.on('get', this.getCurrentMediaState.bind(this));
this.televisionService.getCharacteristic(Characteristic.TargetMediaState)
.on('get', this.getTargetMediaState.bind(this))
.on('set', (newMediaState, callback) => { this.setTargetMediaState(newMediaState, callback); });
this.accessory.addService(this.televisionService);
}
and i modified the setInput Function like this...
async setInput(input, callback) {
if (this.debugLevel > 0) {
this.log.warn('setInput input:',input.inputId, input.InputName);
}
callback(null); // for rapid response
var currentInputName = 'UNKNOWN';
var foundIndex = this.inputList.findIndex(input => input.inputId === currentInputId);
if (foundIndex > -1) { currentInputName = this.inputList[foundIndex].InputName; }
this.log('Change input from %s %s to %s %s', currentInputId, currentInputName, input.inputId, input.InputName);
this.sendKey(input.inputId);
//this.switchInput(input.inputId);
}
and the inputList definition...
this.inputList = [
{inputId: "KEY_TV", inputName: "KEY_TV"},
{inputId: "KEY_HDMI", inputName: "KEY_HDMI"},
{inputId: "KEY_MUTE", inputName: "KEY_MUTE"},
];
so it would be necessary to write a function or sth, which dynamicly lets the user define his Inputs and the corresponding "KEY_XYZ" commands for the inputs...
btw we can speak in german here if u want...
Hi @huddx01 German is fine but English is my mother tongue to let's keep this thread in a single language that more people can understand.
I've been working on the remote control over the last few days, adding another key layer activated by double-tap. This means you can map every single remote key to any command you want, and define a command for single-tap or double-tap. I've also done some work on the Input list, basically same as you did. The trouble with the input list is that no change event is triggered when you select the existing input, so if you wish to tap SOURCE to cycle through the TV sources, you have to have 2 x inputs, each named source, so as to capture the event and then send a key press.
An alternative is to use HDMI-CEC. My raspberry pi is connected to the HDMI network, and I can turn on my TV and select an HDMI input via the pi. It's just slow due to the time taken for the HDMI command in the pi to initialize. I'm thinking about how I add that, and I thin a user-defined command line would be the best. That also allows switch on of the TV over HomeKit.
I'd like some feedback so I'll publish a new beta version and you can experiment with the double-tap of the remote keys. I added support for triple-tap but it's not working yet and due to the look-ahead-and-wait for the triple-tap time, I'm starting to think I'd be better of not supporting triple-tap.
I've published 0.0.1-beta.9 for you to try out
Hi @jsiegenthaler,
Thank you so much!
sorry for my late answer, but i just had no time for private projects in the last days... I just installed the new 0.0.1 v15 beta... and for the first:
The free definable KEY_ Commands for remote are perfect! The double tap layer works very fine! But the Inputs in Homekit still do not...
Give me a few hours, maybe 1-2 days to check everything in Detail. Then I will give you a detailed answer, ok?
Its a very good Idea to be able to set a custom command on Power On (like you mentioned via hdmi-cec).. But i my environment the raspi is not connected via hdmi to the tv. My TV is connected via HDMI to an Apple TV... and when the AppleTV is waken up, the TV also starts up. I remember there was once the ability to wakeup the AppleTV by a http or curl command (i dont remember exactly), but i will figure it out. (maybe it changed with the actual tvOS Version?)
We stay in touch...
Thanks again, its almost a perfect plugin for older Samsung TVs...
Regards, huddx01
Thanks. I still want to add the power key to the config.
For power on, you can add an Apple TV remote plugin, which provides a power on switch. You can then add a curl command to turn on the Apple TV, which would then turn on the Samsung tv via HDMI-CEC.
As for channel control, I will add some CEC command capabilities, as well as the primitive source or hdmi controls
I also have Apple TV 4K so I'll make a Wiki page with the correct curl command What model Samsung TV do you have?
I also have Apple TV 4K so I'll make a Wiki page with the correct curl command What model Samsung TV do you have?
Its an ES 8090
Thanks. I still want to add the power key to the config.
What exactly do you mean with "add the power key to the config"?
For power on, you can add an Apple TV remote plugin, which provides a power on switch. You can then add a curl command to turn on the Apple TV, which would then turn on the Samsung tv via HDMI-CEC.
Yes, thats basically what i meant... "an Apple TV remote plugin" - you probably meant another homebridge-appletv plugin? Yes, there exist a few... But I do not like the fact, that it is always necessary to pair my AppleTV with these plugins... I'm a fan of the "keep it as simple as possible - way"... Yesterday, when i was on v15 beta i did a workaround by adding a "TV on" Scene in HK... When this scene gets triggered, the AppleTV continues playing a Track - so it wakes up and also triggers the TV by HDMI-CEC to wake up... (see the screenie)
But now, on v18 beta, it seems that the TV INPUT Sources work partially as expected... give me a few hours to check this in detail.
As for channel control, I will add some CEC command capabilities, as well as the primitive source or hdmi controls I am very excited of the CEC command capabilities
-> I tested a lot samsungtv plugins before... but this is the best for now! Great work!
Ok, I removed the TV from HK and deleted it from Cache of Homebridge. Then readded it in HK...
My Experience: 1) If i rename the Sources in the HK App, it seems that after a hb-restart the Names are reinitialized... 2) It seems that the Names change randomly after some triggering of the Input sources.. 3) On different devices, the order changes randomly - see the screnies (on a mac and on an iPhone). A 2nd iPhone also gets another order 4) But the most important for me: If i choose TV or HDMI -> The TV switches always correctly to the corresponding source, independent which device i use (see the red marked circles in the screenies)
Mac:
iPhone:
OK, I'll check this. I want to make the inputs fully and freely configurable anyway, so the user determines the name and order. And currently nothing is cached, so all names are hard coded.
v19 Beta runs quite good since a few days. Im looking forward for the freely configurable input- keys, names and order.
Thanks again! Great work!
I haven't forgotten you, waiting for the next rainy day where I spend the day inside...
Pushed 0.0.2-beta.0, with fully configurable input sources. Make sure you configure them in the config.json using the gui (documentation needs catching up)
Hi, I just installed v0.0.4... Mhm...
But it seems that the Plugin is not pushing out the corresponding Input Keys, I defined in the config.json... Although I am pressing the Inputs for RPI, ATV, NB, etc...
The log says:
[9/17/2021, 10:49:06 PM] [Samsung TV HT] Fernseher: sendKey KEY_TV
[9/17/2021, 10:49:14 PM] [Samsung TV HT] Fernseher: sendKey KEY_SOURCE
[9/17/2021, 10:49:17 PM] [Samsung TV HT] Fernseher: sendKey KEY_TV
[9/17/2021, 10:49:18 PM] [Samsung TV HT] Fernseher: sendKey KEY_SOURCE
[9/17/2021, 10:49:20 PM] [Samsung TV HT] Fernseher: sendKey KEY_SOURCE
[9/17/2021, 10:49:24 PM] [Samsung TV HT] Fernseher: sendKey KEY_SOURCE
[9/17/2021, 10:49:26 PM] [Samsung TV HT] Fernseher: sendKey KEY_TV
[9/17/2021, 10:49:28 PM] [Samsung TV HT] Fernseher: sendKey KEY_SOURCE
[9/17/2021, 10:49:30 PM] [Samsung TV HT] Fernseher: sendKey KEY_SOURCE
[9/17/2021, 10:49:32 PM] [Samsung TV HT] Fernseher: sendKey KEY_SOURCE
[9/17/2021, 10:50:00 PM] [Samsung TV HT] Fernseher: sendKey KEY_SOURCE
[9/17/2021, 10:50:22 PM] [Samsung TV HT] Fernseher: sendKey KEY_TV
[9/17/2021, 10:51:39 PM] [Samsung TV HT] Fernseher: sendKey KEY_SOURCE
And my config is:
"inputs": [
{
"inputName": "TV",
"inputKeyCode": "KEY_TV",
"inputSourceType": "3",
"inputDeviceType": "0"
},
{
"inputName": "RPI",
"inputKeyCode": "KEY_EXT20",
"inputSourceType": "3",
"inputDeviceType": "0"
},
{
"inputName": "ATV",
"inputKeyCode": "KEY_AUTO_ARC_PIP_WIDE",
"inputSourceType": "3",
"inputDeviceType": "0"
},
{
"inputName": "NB",
"inputKeyCode": "KEY_AUTO_ARC_PIP_RIGHT_BOTTOM",
"inputSourceType": "3",
"inputDeviceType": "0"
},
{
"inputName": "MUTE",
"inputKeyCode": "KEY_MUTE",
"inputSourceType": "3",
"inputDeviceType": "0"
}
],
Btw i figured out that you can directly enter the different HDMI Sources from the s..go Forum by using these keys:
KEY_AUTO_ARC_PIP_RIGHT_BOTTOM # Source: HDMI3
KEY_AUTO_ARC_PIP_WIDE # Source: HDMI2
KEY_EXT20 # Source: HDMI1
But maybe something in Homekit or Homebridge is still persisted/nested although i removed the plugin and the TV Device from Homekit and Homebridge and also the TV Device before reinstalling...
Give me a few days to figure this out... Maybe a rainy day at the weekend :-) cya. Thanks & cheers
Btw... i do not really understand the "inputSourceType" and "inputDeviceType" Parameters... Can you send a link or some explanation about these?
Hi. Thanks for the feedback! Firstly, The key code name and the function that it controls vary a lot from from model to model. The key code name does not always match the function. It is a bit of "try and see" to find out what works. On my TV, a D6000 series, the KEY_AV1 does not activate AV1 input as expected, but instead it switches to the Ext. input. So it is a case of experimenting to find what key code does what on your model.
I just checked my source code and you are 100% right: I forgot to actually change the code that determines what key code to send for the input! Sorry! I'll do it today or tomorrow, watch out for 0.0.5, which I will push as a release.
As for inputSourceType and inputDeviceType: these are defined in the Apple Homekit protocol for TV InputSources: An InputSource (https://developers.homebridge.io/#/service/InputSource) has required and optional characteristics. InputSourceType (https://developers.homebridge.io/#/characteristic/InputSourceType) is mandatory. InputDeviceType (https://developers.homebridge.io/#/characteristic/InputDeviceType) is optional. But Apple does not appear to use these characteristics in their current implementation of a TV accessory in the Home app. But they may use them in the future, who knows? No-one in the Homebridge community really knows what they are supposed to be used for, because no-one has access to the official Apple documentation. So we are all guessing. i have googled a lot but found very little. If you find anything, let me know ;)
I decided the best thing to do is to make the characteristics available and configurable, and the end user can decide how to configure them.
Just like to say THANK YOU, I've just confirmed that my UE40D5000 also uses these key codes for the 4 x HDMI inputs:
KEY_EXT20 # Source: HDMI1
KEY_AUTO_ARC_PIP_WIDE # Source: HDMI2
KEY_AUTO_ARC_PIP_RIGHT_BOTTOM # Source: HDMI3
KEY_AUTO_ARC_AUTOCOLOR_FAIL # Source: HDMI4
I've been hunting for these for a long time....
Pushed v0.0.5 with bugfix for the input sources
Thanks! Seems to work perfectly right now!
Firstly, The key code name and the function that it controls vary a lot from from model to model. The key code name does not always match the function. It is a bit of "try and see" to find out what works. On my TV, a D6000 series, the KEY_AV1 does not activate AV1 input as expected, but instead it switches to the Ext. input. So it is a case of experimenting to find what key code does what on your model.
I know this problem :-)
For me, i had once the s...go stuff installed on on my tv... telnet, nc, ssh and so on... and on the forum, there exists an app/lib called "libLogRCkey", which logs down the keys you press on the remote... that was the way i found out the 3 direct HDMI-Switch-Keys...
I read anywhere that you search for some KEYs for your Blueray Player or something? Maybe i can help out.... let me know. Where is the button to write direct-messages to you?°°
Funny, how it is possible to revoke such an old TV back to modern 2021 homekit-life :-)
Hi, I'd like to know more about the libLogRCkey.
thihi.... you shold got mail now?
yep
closing issue, was resolved in v0.0.5
Describe The Bug:
Hi, this is a perfect and smple plugin for older Samsung TVs... But No INPUT Sources working. When i select a Source in the Homekit app, there comes the message: No response...
Everything else works... ON/OFF and all commands done via the remote in message center in ios
To Reproduce:
In HomeKit App: Try to use an Input Source (HDMI, TV, etc)
Expected behavior:
TV should select the Source/KEY
Would it be also possible to define own (and more than 3) Input KEYs (KEY_xyz) via customized Commands? -> This would be perfect.
Logs:
Plugin Config:
Screenshots:
Environment: