Author Topic: LG TVs  (Read 8918 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

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: LG TVs
« Reply #15 on: May 13, 2015, 10:28:55 PM »
Ha. OK. So, I don't know if we'll be as lucky with the following, but give it a whirl.

Again, you'll need to replace the IP address in both commands in this group. Run the session ID command first. If that works, then you can try the other command, using any of the command codes in the payload xml file that I've attached to this post.

As you should be able to tell from the command itself, the payload xml file should be placed in your payloads folder.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.6-->
<commandGroup open="True" name="LGTV" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="787" name="2 - Session ID" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="I don't know that you'll need a map, but it may not hurt. You could put your pair key and IP address in there too. Eventually there may be other values worth storing there.">
    <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;AuthReq&lt;/type&gt;&lt;/auth&gt;&lt;value&gt;043855&lt;/value&gt;&lt;/auth&gt;</param>
        <param />
        <param />
        <param>application/atom+xml</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <params>
        <param>&lt;session.*?&gt;(.*?)&lt;/session</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Map.CreateTable</cmdType>
      <params>
        <param>LGTV</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Map.Set</cmdType>
      <params>
        <param>LGTV</param>
        <param>sessionID</param>
        <param>{Match.1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>get Session ID</phrase>
  </command>
  <command id="784" name="LGTV commands" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>{PF.1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Scrape.Post</cmdType>
      <params>
        <param>http://LTV_IPaddress:8080/roap/api/command</param>
        <param>&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;command&gt;&lt;name&gt;HandleKeyInput&lt;/name&gt;&lt;value&gt;{1}&lt;/value&gt;&lt;/command&gt;</param>
        <param />
        <param />
        <param>application/atom+xml</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Select command code</phrase>
    <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\LGTV_commandcodes.xml</payloadFromXML>
  </command>
</commandGroup>

Here's hoping.
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 #16 on: May 13, 2015, 10:35:06 PM »
Code: [Select]
5/13/2015 5:48:30 PM VoxLog created / UAC test passed.
5/13/2015 8:33:01 PM 473 doCommand:LGTV commands
5/13/2015 8:33:01 PM 473 action repeat set to: 1
5/13/2015 8:33:01 PM 473 no match for replacing variables: {PF.1}
5/13/2015 8:33:01 PM 473 Action:  TTS.Speak - {PF.1}
5/13/2015 8:33:01 PM 473 [action] TTS.Speak:{PF.1}

5/13/2015 8:33:01 PM 473 Action INFO: speaking (asynchronous): {PF.1}
5/13/2015 8:33:01 PM 473 action repeat set to: 1
5/13/2015 8:33:01 PM 473 no match for replacing variables: {1}
5/13/2015 8:33:01 PM 473 Action:  Scrape.Post - http://192.168.9.999:8080/roap/api/command&&<?xml version="1.0" encoding="utf-8"?><command><name>HandleKeyInput</name><value>{1}</value></command>&&&&&&application/atom+xml
5/13/2015 8:33:01 PM 473 [action] Scrape.Post:http://192.168.9.999:8080/roap/api/command&&<?xml version="1.0" encoding="utf-8"?><command><name>HandleKeyInput</name><value>{1}</value></command>&&&&&&application/atom+xml

5/13/2015 8:33:01 PM 473 Doing scrape put/post with headers:
Content-Type: application/atom+xml


5/13/2015 8:33:01 PM 506 Error while calling scrape.post:<?xml version="1.0" encoding="utf-8"?><command><name>HandleKeyInput</name><value>{1}</value></command>
System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.HttpWebRequest.GetResponse()
   at eval_᜖.eval_ᜁ(String[] A_0, String A_1)
5/13/2015 8:33:01 PM 506 Action ERROR: System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.HttpWebRequest.GetResponse()
   at eval_᜖.eval_ᜁ(String[] A_0, String A_1)
5/13/2015 8:33:01 PM 530 [vcevent] tts.start

5/13/2015 8:33:03 PM 563 doCommand:2 - Session ID
5/13/2015 8:33:03 PM 563 action repeat set to: 1
5/13/2015 8:33:03 PM 563 Action:  Scrape.Post - http://192.168.9.999:8080/roap/api/auth&&<?xml version="1.0" encoding="utf-8"?><auth><type>AuthReq</type></auth><value>043855</value></auth>&&&&&&application/atom+xml
5/13/2015 8:33:03 PM 563 [action] Scrape.Post:http://192.168.9.999:8080/roap/api/auth&&<?xml version="1.0" encoding="utf-8"?><auth><type>AuthReq</type></auth><value>043855</value></auth>&&&&&&application/atom+xml

5/13/2015 8:33:03 PM 563 Doing scrape put/post with headers:
Content-Type: application/atom+xml


5/13/2015 8:33:03 PM 588 Error while calling scrape.post:<?xml version="1.0" encoding="utf-8"?><auth><type>AuthReq</type></auth><value>043855</value></auth>
System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.HttpWebRequest.GetResponse()
   at eval_᜖.eval_ᜁ(String[] A_0, String A_1)
5/13/2015 8:33:03 PM 588 Action ERROR: System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.HttpWebRequest.GetResponse()
   at eval_᜖.eval_ᜁ(String[] A_0, String A_1)
5/13/2015 8:33:03 PM 588 action repeat set to: 1
5/13/2015 8:33:03 PM 588 Action:  Results.RegEx - <session.*?>(.*?)</session
5/13/2015 8:33:03 PM 588 [action] Results.RegEx:<session.*?>(.*?)</session

5/13/2015 8:33:03 PM 589 Action ERROR: No matches found
5/13/2015 8:33:03 PM 589 action repeat set to: 1
5/13/2015 8:33:03 PM 589 Action:  Map.CreateTable - LGTV
5/13/2015 8:33:03 PM 589 [action] Map.CreateTable:LGTV

5/13/2015 8:33:03 PM 590 map disposing of dataadapter and dataset
5/13/2015 8:33:03 PM 591 Action ERROR: failed to create table: SQL logic error or missing database
table LGTV already exists
5/13/2015 8:33:03 PM 591 action repeat set to: 1
5/13/2015 8:33:03 PM 591 error replacing variables: {Match.1}
5/13/2015 8:33:03 PM 592 Action:  Map.Set - LGTV&&sessionID&&{Match.1}
5/13/2015 8:33:03 PM 592 [action] Map.Set:LGTV&&sessionID&&{Match.1}

5/13/2015 8:33:03 PM 592 map disposing of dataadapter and dataset
5/13/2015 8:33:03 PM 597 map set complete
5/13/2015 8:33:03 PM 597 Action INFO: value set
5/13/2015 8:33:03 PM 597 [vcevent] tts.end

5/13/2015 8:33:07 PM 738 doCommand:LGTV commands
5/13/2015 8:33:07 PM 738 action repeat set to: 1
5/13/2015 8:33:07 PM 738 no match for replacing variables: {PF.1}
5/13/2015 8:33:07 PM 738 Action:  TTS.Speak - {PF.1}
5/13/2015 8:33:07 PM 738 [action] TTS.Speak:{PF.1}

5/13/2015 8:33:07 PM 738 Action INFO: speaking (asynchronous): {PF.1}
5/13/2015 8:33:07 PM 738 action repeat set to: 1
5/13/2015 8:33:07 PM 738 no match for replacing variables: {1}
5/13/2015 8:33:07 PM 738 Action:  Scrape.Post - http://192.168.9.999:8080/roap/api/command&&<?xml version="1.0" encoding="utf-8"?><command><name>HandleKeyInput</name><value>{1}</value></command>&&&&&&application/atom+xml
5/13/2015 8:33:07 PM 738 [action] Scrape.Post:http://192.168.9.999:8080/roap/api/command&&<?xml version="1.0" encoding="utf-8"?><command><name>HandleKeyInput</name><value>{1}</value></command>&&&&&&application/atom+xml

5/13/2015 8:33:07 PM 738 Doing scrape put/post with headers:
Content-Type: application/atom+xml


5/13/2015 8:33:07 PM 754 Error while calling scrape.post:<?xml version="1.0" encoding="utf-8"?><command><name>HandleKeyInput</name><value>{1}</value></command>
System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.HttpWebRequest.GetResponse()
   at eval_᜖.eval_ᜁ(String[] A_0, String A_1)
5/13/2015 8:33:07 PM 754 Action ERROR: System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.HttpWebRequest.GetResponse()
   at eval_᜖.eval_ᜁ(String[] A_0, String A_1)
« Last Edit: May 13, 2015, 10:39:30 PM by nime5ter »

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: LG TVs
« Reply #17 on: May 13, 2015, 10:47:07 PM »
Oh well. :)

Looks like there's more research to be done but a few notes: You can't try the "LGTV commands" until you've successfully run the session ID command, which is why I said to try that one first.

2. To run the LGTV command, you'll have to do it properly, respecting its need for a payload value. Based on the log, that didn't happen. Maybe because you didn't close the tree etc. after adding the new commands.

Anyhow, since we're getting a bad request back from the session ID command, the 2nd point doesn't yet come into play.

Here's a replacement you can try for the session ID command. I'm going to sleep now, though, so that's all I can offer for now. I don't have high hopes that this will work if the first version didn't but who knows.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.6-->
<command id="787" name="2 - Session ID" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="I don't know that you'll need a map, but it may not hurt. You could put your pair key and IP address in there too. Eventually there may be other values worth storing there.">
  <action>
    <cmdType>Scrape.Post</cmdType>
    <params>
      <param>http://192.168.9.999:8080/hdcp/api/auth</param>
      <param>&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;auth&gt;&lt;type&gt;AuthReq&lt;/type&gt;&lt;/auth&gt;&lt;value&gt;043855&lt;/value&gt;&lt;/auth&gt;</param>
      <param />
      <param />
      <param>application/atom+xml</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <params>
      <param>&lt;session.*?&gt;(.*?)&lt;/session</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>LastActionSuccess</ifType>
    <ifParams>&amp;&amp;</ifParams>
    <then>
      <action>
        <cmdType>Map.CreateTable</cmdType>
        <params>
          <param>LGTV</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>Map.Set</cmdType>
        <params>
          <param>LGTV</param>
          <param>sessionID</param>
          <param>{Match.1}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <phrase>get Session ID</phrase>
</command>
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 #18 on: May 13, 2015, 10:59:28 PM »
Hmm I thought I did, then wasn't sure if the 2 meant do second so I tried the other way as well, but I may have not closed the command tree like you suggested.  So I saved, closed the tree, full refreshed and tried the new commands as well. But my spare android phone's battery is dead so I ran the commands from the command tree if that is ok?
Sleep well, thanks nime5ter

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: LG TVs
« Reply #19 on: May 14, 2015, 08:26:13 AM »
I meant that:

1. The session ID command (which I *think* is the equivalent of the "request pairing" command in the LG documentation) needs to execute successfully before we bother with the other command that sends specific command codes.

2. The command the sends specific command codes has those codes in the payload XML file. As is always the case in VC, you can't "save and execute" commands that take payloads unless you manually enter the necessary payload values in the LCB test fields. Otherwise, how can the command know what payload value to use?

Quote
  So I saved, closed the tree, full refreshed and tried the new commands as well.

I only posted one command in my last post, so I'm not sure if that's the one you tried or not. It would have been fine to run that using "save & execute", as it required no payloads and was not triggering any follow-up event-based commands.

Sounds like the script I borrowed from yesterday is not using the syntax you need.

Here is one last attempt we can try to get VC paired/talking to your TV. If this works then I can try to provide you with a new command for sending specific command codes to the TV.

DELETE THE COMMANDS I GAVE YOU YESTERDAY, THEN:

Run this command first:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.6-->
<command id="766" name="1 - 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>


THEN, run this command:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.6-->
<command id="778" name="2 - Request pairing" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape.Post</cmdType>
    <params>
      <param>http://192.168.9.999:8080/udap/api/pairing</param>
      <param>&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;envelope&gt;&lt;api type="pairing"&gt;&lt;name&gt;hello&lt;/name&gt;&lt;value&gt;043855&lt;/value&gt;&lt;/api&gt;&lt;/envelope&gt;</param>
      <param />
      <param />
      <param>text/xml; charset=utf-8</param>
      <param>User-Agent: UDAP/2.0</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>RegExTool.Open</cmdType>
    <params>
      <param>True</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Request pairing</phrase>
</command>
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 #20 on: May 14, 2015, 08:32:54 AM »
The above commands will be successful if the following occurs:

1. After you run the 1st command, the pop-window displaying the pairing key will show up on your TV screen and you'll get the "200" code message in the regex tool as you did at first yesterday.

2. If the second command is successful, the pop-window on your TV will disappear, and you will get another "200" code message in the regex tool.

Or, as LG words it:

Quote
If the pairing requested by a Controller is successful, the pop-up window displayed on a Host screen disappears. Otherwise, the pop-up window showing the pairing key displays on the Host screen for another 60 seconds.
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 #21 on: May 14, 2015, 08:08:36 PM »
I found the author of the original script pointed me to the pull request of someone else that already did the porting.
I cleaned up the port and stripped the gui bits which were still failing for me, since the Tkinter stuff was all gui based and ironpython doesnt support it.
I can get connected.
I can power off
I can't seem to find the codes or perhaps different method to directly change the inputs however, such as HDMI1, HDMI3...etc.
Sharing for those interested
I created a map table for the remote codes i was interested in. then need to create matching payload list
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.2-->
<command id="579" name="LGTV" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Results.SetLastResult</cmdType>
    <params>
      <param>{M:LGTV.{1}}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>{LastResult}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>PY.ExecFile</cmdType>
    <params>
      <param>{Path.VC}\PY\LGTV.py</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
</command>