hobbyquaker / lgtv2

Control LG WebOS TV using node.js :tv:
MIT License
334 stars 44 forks source link

Turn on feature #13

Closed anonrig closed 6 years ago

anonrig commented 6 years ago

Is there a turn on feature?

hobbyquaker commented 6 years ago

Not possible via the API, simply because the network interfaces are down when the TV is off. Possible workarounds are WakeOnLan (not all LG TVs support that, the newer ones should) and Infrared (e.g. LIRC, Broadlink, Harmony, ...)

anonrig commented 6 years ago

Thank you for your fast response. You're right. I've managed to look into it, and for others to seek, this is my solution:

  async turnOn() {
    console.log('Turning on');
    return new Promise((resolve, reject) => {
      wol.wake('MAC ADDRESS', {
        address: '192.168.1.31',
        port: 3000
      }, (error) => {
        if (error) return reject(error);
        console.log('Turned on');
        resolve();
      });
    });
  }
twistedpixel commented 6 years ago

I just spoke to LG tech support and if you're in the UK (potentially anywhere in Europe, actually), for whatever ridiculous regulatory reason, TVs are not allowed to stay connected to a network while in standby. Perhaps the decision was made after the "Samsung TVs might be spying on you" issue.

LG have removed this feature from TVs - in the UK, at least - and this is why awesome software like this will never be able to power on your TV from standby. I've confirmed it affects Samsung TVs too.

I'm not sure who to speak to about this but I get the feeling it's too big and buried in too much bureaucracy for any consumers or third-party developers to get reversed.

anonrig commented 6 years ago

hello @twistedpixel , I've also encountered similar issues, using node-wol, (sometimes) it works and sometimes it doesn't.

My overall code is: https://github.com/anonrig/alexa-jarvis

twistedpixel commented 6 years ago

@anonrig Most likely the sporadic behavior you’re seeing is because the TV stays connected for a short while into standby. Seems to be about 5 minutes (maybe more, maybe less) but varies across manufacturers. Very frustrating!

I wonder if there’s a toggle for this behavior somewhere in the engineer menu. I don’t really like messing around in that menu though (specially since I only bought my OLED a few weeks ago!)

hobbyquaker commented 6 years ago

Afaik the reason why manufacturers can't keep network interfaces up in standby is EU DIRECTIVE 2005/32/EC and follow ups, stand-by power is limited to 0,5W and in future to 0,25W, I think this is simply not enough to operate a network interface and a cpu. Overall I think that makes sense, to high standy-by power consumption isn't anything I want ;-) The downsides of using WOL can be worked around with the usage of Infrared to switch on the TV, I'm using a simple self-made Pi based MQTT-Connected IR-Transceiver for that, but you can also build that for less than 10€ with e.g. a ESP8266.

twistedpixel commented 6 years ago

@hobbyquaker Interesting. But realistically 0.5W isn’t exactly a hairdryer!

I guess Infrared is the best option. I didn’t really want to go down that route as it feels like cheating but hey: use the tools you have!

Cheers for the info on the EU directive.

shyne99 commented 6 years ago

Adding my experience here. I face the same issue, as I wanted my google home to be able to wake my lg screen with my computer when I ask it to do. Since I was using my raspberry as a server to handle the request of the google home. My go solution was to connect my rapberry to my screen over HMDI (even if I never use this source) and use HDMI-CEC to turn on the screen. The pros is that it is operationnal in 5 minutes. Cons is that you have to hook up your screen and spare a useless HMDI slot that only works as a power On button. Hope it helps

twistedpixel commented 6 years ago

That’s a good idea. You must be one of the lucky people with a TV that has USB ports that stay powered in standby!

Out of interest, do you have a good recommendation for a HDMI-CEC library on the Pi?