merdok / homebridge-webos-tv

Homebridge plugin for LG webOS TVs
MIT License
663 stars 89 forks source link

[Feature Request] Device Type TV #87

Closed vmax77 closed 5 years ago

vmax77 commented 5 years ago

Hi

I know this is early, but it would nice if the TV was detected as type TV

image

Thank you

merdok commented 5 years ago

When this will be added into HomeKit then I will implement it. I guess this will be available not sooner then with iOS13 so it is still months away...

creinhart commented 5 years ago

Looks like this Support just appeared in the latest iOS 12.2 beta today. Would be great once this plugin is recognized as a TV in HomeKit.

merdok commented 5 years ago

Will keep an eye on it đź‘Ť

akseez commented 5 years ago

Here’s a post of someone showing how it works: https://mobile.twitter.com/KhaosT/status/1088521851750379520

Also, what’s available in the Remote app: https://mobile.twitter.com/KhaosT/status/1088540954892464128

KhaosT commented 5 years ago

Support for TV has been added to hap-nodejs and homebridge :) Please let me know if you have any question about the new services.

https://github.com/KhaosT/HAP-NodeJS/commit/243c112abee13346007db358b13b5bbeda75e0af https://github.com/nfarina/homebridge/commit/27073def733ac94897c57b178a85ee83be46c03c

m11rphy commented 5 years ago

I came to see if you was looking at this seems as though you already are, can't wait to see what you come up with. Also thank you for all your work on this plugin its really great

Hiddecollee commented 5 years ago

Will keep an eye on it đź‘Ť

Are you working on it? I would love to have it.

mcnahum commented 5 years ago

I think everybody was thinking the same with this new feature, that will be really great to have it.

merdok commented 5 years ago

Finally they added a tv device type. I will definitely work on this.

@KhaosT did you add those services? Did you try those services with iOS12.2 Beta? Maybe i will install the beta over the weekend and try it out.

KhaosT commented 5 years ago

@merdok Yeah, TV support is enabled in iOS 12.2 beta in Home and Control Center Remote.

merdok commented 5 years ago

I guess there should not be any issues to add the TV service to HomeKit. About the Control Center Remote i am not sure if i will be able to add this. Need to check how this works...

creinhart commented 5 years ago

TV service is good enough for me, but whatever you can do we appreciate it. Especially since LG won’t update previous models with homekit support. I’m running the 12.2 beta now. Pretty cool being able to tell Siri to play a specific movie on the Apple TV and she just does it.

merdok commented 5 years ago

@KhaosT does the Control Center Remote also use HomeKit to send the commands to the TV?

Ben305 commented 5 years ago

I have already made some progress, buttons UP, DOWN, LEFT, RIGHT, ENTER, BACK, and EXIT are working.

merdok commented 5 years ago

Good to know that the remote also goes through HomeKit. Will be working on the TV service over the weekend.

I will most probably add a switch so people with the Beta installed can already use the new tv service. After iOS12.2 final is released i will switch the plugin completely to the new service.

KhaosT commented 5 years ago

@merdok Yeah, the remote part sends the command via Remote Key characteristic. On webOS side I think you already have the button event in current code.

merdok commented 5 years ago

@KhaosT Yep, tested it and it works fine.

How about the REWIND, FAST_FORWARD, NEXT_TRACK, PREVIOUS_TRACK buttons, i do not see them on the remote... where are they located? Also there are Characteristics like PictureMode or Brightness which i could not find anywhere in the app. Are they just missing in the current beta?

KhaosT commented 5 years ago

Yeah I wasn’t able to have those show up right now, and it doesn’t look like it’s being used in current beta. The only additional characteristic Home app handles is the power mode one, which is really strange…

Hopefully those are tied to current media state characteristic, and a now playing screen can show up with ability to control playback in future beta

merdok commented 5 years ago

@KhaosT As i thought. Well then let's hope more features show up int he next betas. The remote control also just looks like the Apple TV remote control currently so i guess this will be updated with more buttons for the new TVs in the future. Yes, i just found out what the PowerModeSelection service does...

BTW, i was just trying to add the input sources and somehow this didn't work for me using homebridge. I tried to add an input source as a linked service to the Television service but that did nothing. If I add a InputSource as a standalone service then a separate switch for that services appears in the Home app, but i guess that is not what the idea here is...

KhaosT commented 5 years ago

Huh add to linked service is the right way to do this… did you set identifier correctly to all input sources?

merdok commented 5 years ago

Testing currently with one input source. Looks like follows:

var inputHDMI1 = new Service.InputSource("hdmi1", "HDMI 1");

inputHDMI1
.setCharacteristic(Characteristic.Identifier, 1)
.setCharacteristic(Characteristic.ConfiguredName, "HDMI 1")
.setCharacteristic(Characteristic.IsConfigured, Characteristic.IsConfigured.CONFIGURED)
.setCharacteristic(Characteristic.InputSourceType, Characteristic.InputSourceType.HDMI);

this.tvService.addLinkedService(inputHDMI1);

This does not want to show up for me under Inputs in the Home app

KhaosT commented 5 years ago

@merdok did you also include inputHDMI1 in the array you returned for services?

merdok commented 5 years ago

@KhaosT Yes, if add it there then it appears as a new switch on the Home dashboard, but still not as an input for the TV.

KhaosT commented 5 years ago

@merdok is it possible for you to push the current code you have to a branch or something? If you return it in the services array, and add it as a linked service to the tv service itself, Home app should be able to see it and show you an input switch, instead of a separate tile.

merdok commented 5 years ago

@KhaosT This is how the relevant code currently looks:

this.tvService = new Service.Television(this.name, "tvService");

this.tvService
    .setCharacteristic(Characteristic.ConfiguredName, this.name);

this.tvService
    .setCharacteristic(Characteristic.SleepDiscoveryMode, Characteristic.SleepDiscoveryMode.ALWAYS_DISCOVERABLE);

this.tvService
    .getCharacteristic(Characteristic.Active)
        .on('get', this.getPowerState.bind(this))
        .on('set', this.setPowerState.bind(this));

this.tvService
    .setCharacteristic(Characteristic.ActiveIdentifier, 1);

this.enabledServices.push(this.tvService);

var inputHDMI1 = new Service.InputSource("hdmi1", "HDMI 1");

inputHDMI1
    .setCharacteristic(Characteristic.Identifier, 1)
    .setCharacteristic(Characteristic.ConfiguredName, "HDMI 1")
    .setCharacteristic(Characteristic.IsConfigured, Characteristic.IsConfigured.CONFIGURED)
    .setCharacteristic(Characteristic.InputSourceType, Characteristic.InputSourceType.HDMI)
    .setCharacteristic(Characteristic.CurrentVisibilityState, Characteristic.CurrentVisibilityState.SHOWN);

this.enabledServices.push(inputHDMI1);
this.tvService.addLinkedService(inputHDMI1);

This does creates a separate tile on in the Home app instead of an input source for the tv tile. BTW, what is the purpose of the ActiveIdentifier characteristic?

KhaosT commented 5 years ago

Overall it looks right... let me try using this on my side and see if I can reproduce it. The ActiveIdentifier characteristic in TV Service indicates what's the current active input source the TV is using. Each InputSource service has an Identifier characteristic which the value should be unique. When HomeKit want to change input source, it will write to ActiveIdentifier with the identifier matching the InputSource's Identifier

merdok commented 5 years ago

Please let me know your finding. I already got everything to work except the input sources...

Ok, got it! So this is related to the input sources. So i assume the setter for ActiveIdentifier will be called as soon as an input source is selected?

KhaosT commented 5 years ago

@merdok I tried the same code and it's working for me... https://gist.github.com/KhaosT/b0c7b481d7106025f061a1c621cd2fa4

Yup, and if the input change from the TV side, you can also update ActiveIdentifier so Home app will show the one that's currently on TV.

merdok commented 5 years ago

Just copied/pasted your gist example from above and still HDMI is a separate tile on the Home app. There are no input sources for the TV... What is the issue here?

KhaosT commented 5 years ago

🤔 have you tried remove homebridge from HomeKit and add it back again? Maybe it’s cache?

Ben305 commented 5 years ago

@merdok You have to implement it like this

`var inputHDMI1 = new Service.InputSource("hdmi1", "HDMI 1");

inputHDMI1
    .setCharacteristic(Characteristic.Identifier, 1)
    .setCharacteristic(Characteristic.ConfiguredName, "HDMI 1")
    .setCharacteristic(Characteristic.IsConfigured, Characteristic.IsConfigured.CONFIGURED)
    .setCharacteristic(Characteristic.InputSourceType, Characteristic.InputSourceType.HDMI);

this.tvService.addLinkedService(inputHDMI1);
this.enabledServices.push(this.tvService);
this.enabledServices.push(inputHDMI1);`

It's important to add the input as linked service and add to the service array.

merdok commented 5 years ago

@KhaosT But if this would be a cache issue then i guess i would not be able to use any of the TV services since they all were added at the sam time right?

@Ben305 tried also that. Still does not work as expected.

Strange issue...

Ben305 commented 5 years ago

@merdok Pushed my branch which is working here...

KhaosT commented 5 years ago

Another question, what’s your node version?

merdok commented 5 years ago

@Ben305 that does not work for me @KhaosT v8.15.0

KhaosT commented 5 years ago

I’m running v10.15.0 here… not sure if that matters. By cache issue, I mean maybe HomeKit will only try to setup TV input for an accessory if it never seen it before…so if you are progressively tinkering the services, maybe that confuses HomeKit…

merdok commented 5 years ago

Oh, yes that was the issue here. Some kind of home cache probably. I did change the tv service identifier and the input source identifier and it work now... Afterwards i could change them back to the original ones and it still now works đź‘Ť

Hiddecollee commented 5 years ago

So everything works now?

merdok commented 5 years ago

Everything looks good. I will work on the input sources now and then it should be ready.

Hiddecollee commented 5 years ago

When you are done, you publish it and then we will be able to add this to our homebridge?

merdok commented 5 years ago

Yes, as long as you are on iOS12.2 beta then you will be able to enable and use the new services.

m11rphy commented 5 years ago

Hey merdok great work as always much appreciated. I ha e 3 LG TVs will it be possible to add all 3?

merdok commented 5 years ago

I cannot test it by myself since i have only 1 TV, but I do not see any reason why it should not work. After it is released you can test it and let me know :)

Hiddecollee commented 5 years ago

When do you think you will release it?

merdok commented 5 years ago

Hopefully in the next days...

Hiddecollee commented 5 years ago

Okay, so impatient ahhahaha

HunterJKirby commented 5 years ago

Copied over your index.js and everything is working great with my TV. How could I go about added multiple inputs other than HDMI 1? (Sorry I’m new to this). Thanks!

Hiddecollee commented 5 years ago

What tv do you have?

merdok commented 5 years ago

HomeKit TV integration can now be enabled in the latest release. Please test ist and let me know how it works :)

merdok commented 5 years ago

Are you on iOS 12.2 Beta? channelButtons, notificationButtons, remoteControlButtons and volumeControl will still appear as switches if enabled since there is no way in the current iOS beta to control them from the remote control.