Directv - HTTP GET commands via LUUP

I’m trying to add basic commands for my directv DVR to a scene. I know what the exact commands should be and I’ve tested them from a basic web browser and they work fine. I’ve tried the examples from the wiki and there must be a syntax error somewhere as I can’t even get the scene to save with these code examples. I’ve tried many many variations on the 2 examples below, but I’ve yet to succeed. Any ideas?

Invoke HTTP URL with GET request (Method 1)
– 5 Second timeout
local status, result = luup.inet.wget(“http://192.168.1.20:8080/remote/processKey?key=poweron&hold=keyPress”, 5)

Invoke HTTP URL with GET request (Method 2)
Based on code by Jim/jgc94131
require(‘ltn12’)
local http = require(‘socket.http’)

– 5 Second timeout
socket.http.TIMEOUT = 5

local response_body = {}
local request_body = ‘’

local r, c, h = socket.http.request{
url = ‘http://192.168.1.20:8080/remote/processKey?key=poweron&hold=keyPress’,
method = “GET”,
port = 80,
headers = {
[“Content-Length”] = string.len(request_body),
[“Content-Type”] = “application/x-www-form-urlencoded”
},
source = ltn12.source.string(request_body),
sink = ltn12.sink.table(response_body)

Your first example looks OK to me.

Your second one is a complete mish-mash with unnecessary bits of code and undefined variables. If you want to try the http module then this should suffice.

local http = require "socket.http"
local result, status = http.request "whatever_url_you_want"

Thank you. I agree with your assessment of the code. I reverted to those two code examples from here: [url=https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=0ahUKEwiLk4SKpNrPAhXFSSYKHVmmBScQygQILzAB&url=http%3A%2F%2Fwiki.micasaverde.com%2Findex.php%2FLuup_Scenes_Events%23Invoke_HTTP_URL_with_GET_request_.28Method_1.29&usg=AFQjCNFR25gsREzmB2n6T7DbugnYIJJd0A&sig2=r7BwqYiktmEDx1K9Lk4RBA]Redirect Notice
after I couldn’t make anything else work. Your suggestion was actually the very first thing I tried. I can power cycle my vera lite (UI7), create a new scene, select no devices, and tell it to run this luup code:

local http = require “socket.http”
local result, status = http.request “http://192.168.1.20:8080/remote/processKey?key=poweron&hold=keyPress

When I hit finish, vera spins around, the scene never shows up in the list, Luup eventually restarts, and I get an error message that says “Failed to save system configuration”. I can create other basic scenes without issue and all my existing scenes run just fine. The luup code tester runs the code snippet above without issue, but the command produces no results. I can create scenes with other luup code without issue and they work properly, but I have not been successful at all in getting a scene to even save properly with any sort of http get command via luup, so I’ve been assuming there’s been a syntax error the whole time creating a compile issue. There’s something I’m missing.

Try those examples from the Lua Test page and see if they work interactively.

If you’re having problems with scene code, this sounds like a known Vera bug in Lua code handling for some firmware versions. I’m not up to date on the details of this, because I never update my firmware, having got it to a stable state, but looking around on the forum should tell you more.

I upgraded to the latest firmware (1.7.855) and immediately resolved the issue. A couple of others are now present unfortunately, but there was definitely a luup code problem with my previous firmware.

Ive searched ALL over, and i cannot find a stickied FAQ, or any FAQ for that matter on how to get this to work. Can someone make a FAQ and sticky it up please?

thanx,
anthony

Here’s what I use to control my DirecTV from a vera scene

Add this in the luup code of a scene if you want to Press Play (Play a paused show)and your DirecTV box is on the IP of 192.168.1.200

local status, result = luup.inet.wget(“http://192.168.1.200:8080/remote/processKey?key=play&hold=keyPress”, 2)

Add this in the luup code of a scene if you want to Skip (commercial skip 1X) and your DirecTV box is on the IP of 192.168.1.200

local status, result = luup.inet.wget(“http://192.168.1.200:8080/remote/processKey?key=advance&hold=keyPress”, 2)

For more detail see my blog post at Controlling your DirecTV using Z-Wave and other Home Automation platforms | MyZWave.net

I type this command and get nothing: local status, result = luup.inet.wget(“http://192.168.1.74:8080/remote/processKey?key=poweron&hold=keyPress”, 2)
What am I doing wrong? I have attached a screenshot.

I used these two lines in my scene and it works fine: (as noted previously by akbooer)

local http = require “socket.http”
local result, status = http.request “http://<change_ip_address>:8080/remote/processKey?key=poweron”

Now if I can just control my Sony STR-DN1080 AV receiver and my LG TV I can return the harmony hub that I just got. The harmony hub is not working so well for me, first and foremost, because it will not control the DirecTv with HTTP, it requires IR and that requires disabling the RF remote capability.