Send http commands to Roku

I am running a scene at 8pm that tells my toddler it is time to take a bath via imperihome and dims the lighting around the house automatically. I would also like the scene to launch the pandora app on my Roku stick that is connected to my home theater system (to play calming lullabies). I think it can be done by sending an http post command but I don’t know how to do that in Vera and couldn’t find anything in the forums.

Any ideas how I should go about doing that?

[quote=“homeuser, post:1, topic:191595”]I am running a scene at 8pm that tells my toddler it is time to take a bath via imperihome and dims the lighting around the house automatically. I would also like the scene to launch the pandora app on my Roku stick that is connected to my home theater system (to play calming lullabies). I think it can be done by sending an http post command but I don’t know how to do that in Vera and couldn’t find anything in the forums.

Any ideas how I should go about doing that?

Sending Http in vera is easy, but what the Http to send to roku to have it do what you want I don’t know without reading.

To send http in Vera use a scene and advanced and send lua.

In the lua box use the following.
luup.inet.wget(“XXXXXXXX”)

Replace only the X’s with your ip address of the roku and rest of the http command. Leave the “” and the rest.

Thanks for the tip. I created a manually triggered scene to test the code. Vera dashboard says success but nothing happens on the Roku.

This is from the Roku sdk site:

The following command simulates a user hitting the "Home" button

$ curl -d ‘’ http://192.168.1.134:8060/keypress/home

This is what I have in my luup code

luup.inet.wget(“http://xxx.xxx.x.xx:8060/launch/28”)

This is an example on the sdk of how to get the icon for the app and when I run it in my browser with my ip and app it returns the Pandora channel icon so I know I have the correct ip and app I’d number.

7. This following command will return the icon for the channel with id 12 (Netflix). The response will be raw binary picture data after http headers including one with the MIME type of the picture data.

$ curl ‘http://192.168.1.134:8060/query/icon/12’ > img.png

Edit: The following code works from terminal - $ curl -d ‘’ http://xxx.xxx.x.xx:8060/launch/28
When I use luup.inet.wget(" curl -d '' http://xxx.xxx.x.xx:8060/launch/28") in Vera, I get a success message but nothing happens on the Roku

here try this, it works for me

[code]local http = require “socket.http”
local ltn12 = require “ltn12”
local util = require “util”
http.timeout = 5
local body, code, headers, status = http.request {
method = “POST”,
url = “http://192.168.1.64:8060/launch/12”,
source = ltn12.source.string(reqbody),
headers =
{
[“Connection”] = “Close”,
[“Content-Type”] = “application/x-www-form-urlencoded”,
a },
sink = ltn12.sink.table(respbody)

}[/code]

Thank you for the code.

I was searching around before I saw your reply and found the os.execute command on a thread about sending commands to Foscams and thought I’d give it a shot and it seems to be working.

os.execute(" curl -d '' http://xxx.xxx.x.xx:8060/launch/28?contentID=3071195633120312883")

the contentID=x allows you to launch specific stations. I just copied the number on the end of the pandora url in a desktop browser. For my dinner scene it can automatically launch a dinner music station and my bath time scene can launch a sleepy music station. I could see this also being beneficial for launching different Pandora stations with one button with the imperihome app.

Thanks SteveZ for taking the time to share your code. If I run into trouble with the above code I will try yours.

The latest update to the Pandora app on Roku seems to have broken the ability to launnch specific stations. Vera still launches Pandora on Roku but only plays the last station played.

I’ve made a plugin to simplify control of Roku players. Deep-linking to Pandora stations is still a limitation, though.

Roku App Plugin