Sending HTTP command as Action

If you have a question or need help, this is the place to be.

Sending HTTP command as Action

Postby kkl » Wed May 04, 2011 9:40 pm

Without writing scripts or programming, does there already exist in EventGhost the capability to send an HTTP command? An example is "http://10.10.1.52:8080/remote/processKey?key=pause&hold=keyPress", a DirecTV SHEF command. Is there a simple way to send this without using a browser window? There will be a short text response sent back (JSON) which I don't need to do anything with. Thanks very much for your expertise.
kkl
Experienced User
 
Posts: 67
Joined: Wed May 04, 2011 9:32 pm

Re: Sending HTTP command as Action

Postby mzaz » Thu May 05, 2011 11:04 pm

Not that I know of but you could easily add a python script

import urllib
urllib.urlopen('http://10.10.1.52:8080/remote/processKey?key=pause&hold=keyPress')


but if you don't want to do scripting then I guess you're out of luck.
mzaz
 
Posts: 1
Joined: Sat Jul 25, 2009 6:11 pm

Re: Sending HTTP command as Action

Postby kkl » Thu May 05, 2011 11:36 pm

Thanks very much for the pointer. It's not that I don't want to do scripting, it's just that I'm clueless about Python. I'm willing to put in the time to try to figure it out, I just don't know if I'll get there. Would your example work as a Python command rather than a Python script?
kkl
Experienced User
 
Posts: 67
Joined: Wed May 04, 2011 9:32 pm

Re: Sending HTTP command as Action

Postby kkl » Fri May 06, 2011 4:28 pm

kkl wrote:Would your example work as a Python command rather than a Python script?
It appears that the answer is yes! The syntax to get it on one line is:
import urllib; urllib.urlopen('http://10.10.1.52:8080/remote/processKey?key=pause&hold=keyPress')
Now I'll have to see if I can figure out how to do a plugin.
kkl
Experienced User
 
Posts: 67
Joined: Wed May 04, 2011 9:32 pm

Re: Sending HTTP command as Action

Postby neo117 » Sat May 14, 2011 1:50 pm

I am looking for a solution for this too. let me know if you find a compatible plugin, or if you make one!
I am going to start looking into it too
neo117
 
Posts: 7
Joined: Wed Dec 02, 2009 11:02 pm

Re: Sending HTTP command as Action

Postby kkl » Sun May 15, 2011 8:28 pm

I tried for awhile but just couldn't figure out how to make a plug-in. However, I was able to use Python commands to do everything I needed. The syntax above does work. I put the following single Python commands in the Autostart section:

import urllib
dtv2 = "http://10.10.1.52:8080/remote/processKey?key="

dtv2 is a variable that has my HR24's IP address and the syntax for DirecTV's SHEF command that emulates the remote control. I then created macros for each keypress that contains another Python command. Example:

urllib.urlopen(dtv2 + 'pause')

This will send the pause command to my receiver. It can be triggered by any EG event that you specify. It took awhile to type in all of the commands, so I will post the EG XML code to save typing for others. You can copy and paste this to the appropriate section of your EG XML file.

Code: Select all
    <Folder Name="DirecTV SHEF - DTV2 - Family Room" Expanded="True">
        <Macro Name="power" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'power')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'power')")
            </Action>
        </Macro>
        <Macro Name="poweron">
            <Action Name="urllib.urlopen(dtv2 + 'poweron')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'poweron')")
            </Action>
        </Macro>
        <Macro Name="poweroff" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'poweroff')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'poweroff')")
            </Action>
        </Macro>
        <Macro Name="format" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'format')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'format')")
            </Action>
        </Macro>
        <Macro Name="pause" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'pause')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'pause')")
            </Action>
        </Macro>
        <Macro Name="rew" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'rew')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'rew')")
            </Action>
        </Macro>
        <Macro Name="replay" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'replay')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'replay')")
            </Action>
        </Macro>
        <Macro Name="stop" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'stop')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'stop')")
            </Action>
        </Macro>
        <Macro Name="advance" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'advance')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'advance')")
            </Action>
        </Macro>
        <Macro Name="ffwd" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'ffwd')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'ffwd')")
            </Action>
        </Macro>
        <Macro Name="record" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'record')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'record')")
            </Action>
        </Macro>
        <Macro Name="play" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'play')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'play')")
            </Action>
        </Macro>
        <Macro Name="guide" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'guide')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'guide')")
            </Action>
        </Macro>
        <Macro Name="active" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'active')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'active')")
            </Action>
        </Macro>
        <Macro Name="list" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'list')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'list')")
            </Action>
        </Macro>
        <Macro Name="exit" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'exit')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'exit')")
            </Action>
        </Macro>
        <Macro Name="back" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'back')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'back')")
            </Action>
        </Macro>
        <Macro Name="menu" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'menu')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'menu')")
            </Action>
        </Macro>
        <Macro Name="info" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'info')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'info')")
            </Action>
        </Macro>
        <Macro Name="up" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'up')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'up')")
            </Action>
        </Macro>
        <Macro Name="down" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'down')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'down')")
            </Action>
        </Macro>
        <Macro Name="left" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'left')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'left')")
            </Action>
        </Macro>
        <Macro Name="right" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'right')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'right')")
            </Action>
        </Macro>
        <Macro Name="select" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'select')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'select')")
            </Action>
        </Macro>
        <Macro Name="red" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'red')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'red')")
            </Action>
        </Macro>
        <Macro Name="green" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'green')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'green')")
            </Action>
        </Macro>
        <Macro Name="yellow" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'yellow')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'yellow')")
            </Action>
        </Macro>
        <Macro Name="blue" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'blue')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'blue')")
            </Action>
        </Macro>
        <Macro Name="chanup" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'chanup')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'chanup')")
            </Action>
        </Macro>
        <Macro Name="chandown" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'chandown')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'chandown')")
            </Action>
        </Macro>
        <Macro Name="prev" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'prev')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'prev')")
            </Action>
        </Macro>
        <Macro Name="0" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + '0')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + '0')")
            </Action>
        </Macro>
        <Macro Name="1" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + '1')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + '1')")
            </Action>
        </Macro>
        <Macro Name="2" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + '2')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + '2')")
            </Action>
        </Macro>
        <Macro Name="3" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + '3')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + '3')")
            </Action>
        </Macro>
        <Macro Name="4" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + '4')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + '4')")
            </Action>
        </Macro>
        <Macro Name="5" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + '5')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + '5')")
            </Action>
        </Macro>
        <Macro Name="6" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + '6')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + '6')")
            </Action>
        </Macro>
        <Macro Name="7" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + '7')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + '7')")
            </Action>
        </Macro>
        <Macro Name="8" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + '8')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + '8')")
            </Action>
        </Macro>
        <Macro Name="9" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + '9')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + '9')")
            </Action>
        </Macro>
        <Macro Name="dash" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'dash')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'dash')")
            </Action>
        </Macro>
        <Macro Name="enter" Expanded="True">
            <Action Name="urllib.urlopen(dtv2 + 'enter')">
                EventGhost.PythonCommand(u"urllib.urlopen(dtv2 + 'enter')")
            </Action>
        </Macro>
    </Folder>
kkl
Experienced User
 
Posts: 67
Joined: Wed May 04, 2011 9:32 pm

Re: Sending HTTP command as Action

Postby jitterjames » Mon Nov 14, 2011 1:14 pm

AFAIK a python script is exactly the same as a python command but you can put multiple lines to get multiple commands.

It is easier to use and doesn't clog up your tree so much so I suggest you try it. The only advantage that I can see to using a command over a script, is that you can see the command text in the tree, so if that is important to you then stick with commands.
User avatar
jitterjames
Experienced User
 
Posts: 649
Joined: Thu Aug 13, 2009 4:36 pm
Location: Quebec, Canada


Return to General Support

Who is online

Users browsing this forum: No registered users and 1 guest