Author Topic: LG TVs  (Read 9734 times)

0 Members and 1 Guest are viewing this topic.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • 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: 1999
  • 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: 1999
  • 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: 1999
  • 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>