Author Topic: LG TVs  (Read 8925 times)

0 Members and 1 Guest are viewing this topic.

vulcanjedi

  • $upporter
  • Sr. Member
  • *****
  • Posts: 213
  • Karma: 8
    • View Profile
LG TVs
« on: April 23, 2014, 11:31:39 PM »
Anyone ever manage to get LG TV control?
Mostly I would like to switch inputs and for certain reasons we're using HDMI passthru from TV to amp for sound vs going through amp first.
Seems like they have a pairing requirement with at least some protocol
http://forum.loxone.com/enen/software/4876-lg-tv-http-control.html
http://developer.lge.com/resource/tv/RetrieveDocDevLibrary.dev

vulcanjedi

  • $upporter
  • Sr. Member
  • *****
  • Posts: 213
  • Karma: 8
    • View Profile
Re: LG TVs
« Reply #1 on: May 13, 2015, 01:06:42 AM »
http://harizanov.com/2013/12/control-lg-smart-tv-over-the-internet-using-a-raspberry-pi/
Found this new link which was more helpful.
I think VC is using python2 and this script seems dev'd for python3. I downloaded Python3 for windows and managed to get my TV to prompt for the pairing key but I can't get any command like shutoff or menu or anything to work? no errors but no results from the shell when I run python LGTV.py 21

Anyone else?
I think would need to see about porting the script back to python2 unless VC has plans to update to Python3 soon.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: LG TVs
« Reply #2 on: May 13, 2015, 08:33:07 AM »
VC uses IronPython, which is an implementation of Python that's been integrated to work with the .Net framework, so that James can integrate it with VC (a C#-coded .Net program).

http://voxcommando.com/mediawiki/index.php?title=Python

The IronPython developers are in charge of what version of Python their project implements.

http://ironpython.net/documentation/
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: LG TVs
« Reply #3 on: May 13, 2015, 08:43:29 AM »
Based on the first link you posted (which also links to LG's documentation here: http://developer.lge.com/resource/tv/RetrieveDocDevLibrary.dev), it sounds like it may be possible to use VC's post and get request (scrape) actions.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: LG TVs
« Reply #4 on: May 13, 2015, 11:08:06 AM »
Just a note: while it depends what they're trying to do, often when people use more recent python libraries like the http.client library, they're not actually doing anything that special, in which case the earlier, roughly equivalent libraries such as httplib (in this case) will do just fine.

You can compare the methods in the Python documentation as a starting point, and go from there.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

vulcanjedi

  • $upporter
  • Sr. Member
  • *****
  • Posts: 213
  • Karma: 8
    • View Profile
Re: LG TVs
« Reply #5 on: May 13, 2015, 01:44:38 PM »
Thanks!
Yea I think mostly just change TV inputs. The remote for this tv is a bit unweildly as its an airmouse which is not my style. I have a harmony but thought cooler if I could macro in VC to change inputs sometimes.
Maybe poweroff at night. Nothing too complicated from a workflow standpoint.
Yeah I think the libraries and porting not too bad. I tried to go through each compile error I got and port the libraries to the v2 counterpart but it wasn't quite as simple as I hoped during one error and then I just about confirming I could get to work at all first and was promisingly optimistic when I got the TV to prompt for the pairing code. but after that I got stuck last night.

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2319
  • Karma: 47
    • View Profile
Re: LG TVs
« Reply #6 on: May 13, 2015, 05:19:50 PM »
There is also a LG remote app for android and iOS available which you can try.
***********  get excited and make things  **********

vulcanjedi

  • $upporter
  • Sr. Member
  • *****
  • Posts: 213
  • Karma: 8
    • View Profile
Re: LG TVs
« Reply #7 on: May 13, 2015, 05:30:42 PM »
Yea the smartphone remotes work ok but again it recreates the air mouse aspect with touch screen so its cumbersome in my opinion to just change an input. Plus my goal is to unify all my stuff, so as much as I can use VC the better ;)

vulcanjedi

  • $upporter
  • Sr. Member
  • *****
  • Posts: 213
  • Karma: 8
    • View Profile
Re: LG TVs
« Reply #8 on: May 13, 2015, 09:05:49 PM »
https://github.com/ubaransel/lgcommander

Ok so the original script is much more successful at instantiation a session. Got it to induce the menu. Need to find how to directly change inputs vs the convoluted way the real / phone remotes require.
Lot easier if roommate woudl let me let the AMP do it.
Just need to get the gui stripped out, try to port to ironptyhon compatible python2 and fix passing the key code as argument since it was failing in the compiler.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: LG TVs
« Reply #9 on: May 13, 2015, 09:34:06 PM »
If you enter your TV's IP address where indicated in the VC command below, and then execute the command, does your LGTV show you the pairing key on-screen?

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.6-->
<command id="766" name="get key" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape.Post</cmdType>
    <params>
      <param>http://LTV_IPaddress:8080/roap/api/auth</param>
      <param>&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;auth&gt;&lt;type&gt;AuthKeyReq&lt;/type&gt;&lt;/auth&gt;</param>
      <param />
      <param />
      <param>application/atom+xml</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>RegExTool.Open</cmdType>
    <params>
      <param>True</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>get key</phrase>
</command>

Just wondering if we can get this to work without python. I think I could figure it out if I had the TV here, but I admit it will be a long shot for me to assist from here. Still, worth a try!
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

vulcanjedi

  • $upporter
  • Sr. Member
  • *****
  • Posts: 213
  • Karma: 8
    • View Profile
Re: LG TVs
« Reply #10 on: May 13, 2015, 09:38:13 PM »
As a matter of fact I do !
the regex tool returns
Quote
<?xml version="1.0" encoding="utf-8"?><envelope><ROAPError>200</ROAPError><ROAPErrorDetail>OK</ROAPErrorDetail></envelope>


If you enter your TV's IP address where indicated in the VC command below, and then execute the command, does your LGTV show you the pairing key on-screen?

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.6-->
<command id="766" name="get key" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape.Post</cmdType>
    <params>
      <param>http://LTV_IPaddress:8080/roap/api/auth</param>
      <param>&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;auth&gt;&lt;type&gt;AuthKeyReq&lt;/type&gt;&lt;/auth&gt;</param>
      <param />
      <param />
      <param>application/atom+xml</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>RegExTool.Open</cmdType>
    <params>
      <param>True</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>get key</phrase>
</command>

Just wondering if we can get this to work without python. I think I could figure it out if I had the TV here, but I admit it will be a long shot for me to assist from here. Still, worth a try!

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: LG TVs
« Reply #11 on: May 13, 2015, 09:57:43 PM »
As a matter of fact I do !

Are you saying that you *are* seeing the pairing key on the screen, though?

If so, what is it?
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

vulcanjedi

  • $upporter
  • Sr. Member
  • *****
  • Posts: 213
  • Karma: 8
    • View Profile
Re: LG TVs
« Reply #12 on: May 13, 2015, 10:05:00 PM »
The pairing key is s 6 digit number, that the tv has, and unless you reset your tv should stay there and not change no matter what / how many devices you pair to it. My phone used the same one.
Its 043855

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: LG TVs
« Reply #13 on: May 13, 2015, 10:08:42 PM »
Thanks. I'm still not understanding from your initial response whether the VC command I posted successfully caused that key to appear on your screen though.

If it did, that means our VC post requests are working and I can give you some other commands to try.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

vulcanjedi

  • $upporter
  • Sr. Member
  • *****
  • Posts: 213
  • Karma: 8
    • View Profile
Re: LG TVs
« Reply #14 on: May 13, 2015, 10:19:55 PM »
oh sorry Nime5ter if I was unclear, yes yes it did.  The pairing key displays on the TV when i ran your command so promising indeed