merdok / homebridge-webos-tv

Homebridge plugin for LG webOS TVs
MIT License
650 stars 88 forks source link

More than one app? #30

Closed Stephan811D closed 6 years ago

Stephan811D commented 6 years ago

Is it possible to add more than one application to the accessory? For example "spotify" and "netflix"?

When not... what would happen when i add a second accessories called webos3 to the config.json with another app?

thanks in advance

merdok commented 6 years ago

Currently it is not possible, but i plan to somehow add that feature in a future update.

I didn't test what will happen if you another accessory called webos3 to the config.json. You can try this and let me know what will happen.

Stephan811D commented 6 years ago

that would be really nice! so i wouldn't need my harmony hub anymore ..

however, i tried to add 3 more accessories .. spotify, youtube and netflix and set the polling and volumeControl to false.. and it worked!!

bildschirmfoto 2018-03-21 um 23 57 25

but for each accessorie the plugin adds 3 TV Power Homekits too.. completely understandably .. it would be really nice if there would be only an array in the config.json for more than one app.

bildschirmfoto 2018-03-22 um 00 02 51

j-burton commented 6 years ago

Hi, Ive been trying for days to get Netflix to launch when I switch the tv on with Siri, but no matter what I try I get the same result...

[2018-3-22 11:47:33] [TV] webOS - connecting to TV
[2018-3-22 11:47:33] [TV] webOS - connected to TV
[2018-3-22 11:47:33] [TV] webOS - error Error: ENOENT: no such file or directory, open '/docker/homebridge/lgtvKey File'
[2018-3-22 11:47:33] [TV] webOS - current appId: com.webos.app.livetv
[2018-3-22 11:47:33] [TV] webOS - TV current appId: com.webos.app.livetv
[2018-3-22 11:47:33] [TV] webOS - TV current appId: com.webos.app.livetv
[2018-3-22 11:47:33] [TV] webOS - TV muted: No

Also polling always says the tv is on, no matter if its on or not, but im not so worried about that. Here is my config.json

"accessories": [
    {
  "accessory": "webos3",
  "name": "TV",
  "ip": "192.168.10.10",
  "mac": "14:C9:13:20:99:E7",
  "keyFile": "/docker/homebridge/lgtvKeyFile",
  "pollingEnabled": false,
  "externalSourceSwitch": "HDMI_1",
  "appSwitch": "netflix"
    }

Please, please help me

merdok commented 6 years ago

@Stephan811D cool. Thanks for the info. I think this is a good solution to add multiply app switches. I will try to think of something how to improve that.

@j-burton most probably the directory where you specified the file "/docker/homebridge/lgtvKey" has no write permissions. You would need to fix that.

j-burton commented 6 years ago

I got the keyhole working now with no issues, but still the main wish is that I want the tv to go straight to Netflix when I turn it on isn't happening

Stephan811D commented 6 years ago

@j-burton yes i know your problem really well ... i think you can't start the netflix app without starting the tv first... i think it's a timing problem.. because when i start the tv first i can trigger the application every time without any problem..

i set up a scene called Netflix in my home app.. and i have 2 devices ... one is the TV Power switch and the second is the netflix app

when you use it like this maybe a javascript timeout in the index.js could fix that ...

in that function:

webos3Accessory.prototype.setAppSwitchState = function (state, callback) {
    if (this.connected) {
        if (state) {

            //timeout for this line should fix that maybe?? request starts after 5 seconds for example
            //when tv is already running
            lgtv.request('ssap://system.launcher/launch', {id: this.appSwitch});
            this.setExternalSourceSwitchManuallyCallback(null, false);
        } else {
            lgtv.request('ssap://system.launcher/launch', {id: "com.webos.app.livetv"});
        }
        callback(null, state);
    } else {
        callback(new Error('webOS - is not connected'))
    }
};

i mean it's not a nice fix but maybe it works ... i didn't test it yet ... @merdok what do you think about that idea? you know your code better than me..

greetings

merdok commented 6 years ago

@j-burton this is not possible as far as i know. You could use the workaround from @Stephan811D to get the desired effect.

@Stephan811D That workaround would work but seems more like a forced hack for me. I think it is better to use two voice commands: first to power on the tv and then start the netflix app...

j-burton commented 6 years ago

Do I just add that code at the end of the index.js file? Im just copying the code, I have no clue what it is, but where in there does it specify how many seconds?

merdok commented 6 years ago

@Stephan811D multiply apps are now supported since version 0.9.3. Please try it and let me know if it works as desired.

@j-burton since version 0.9.3 the TV will now attempt to power on when you start an app. Please try it and let me know if it works as desired.

Stephan811D commented 6 years ago

@merdok i tested the new version.. everything works really well now!!

thank you for that awesome Plug-In !!!

greetings from Austria