Roku control via network commands

I have a roku and was tinkering around with ideas for using my spark core for a universal remote. My tv and speakers can both be controlled with IR coding but I plan on controlling the roku via local network commands: http://sdkdocs.roku.com/display/sdkdoc/External+Control+Guide
Anyone have some experience sending commands to a device via network connection like this? I’ve been toying around with it, but haven’t been able to get a response from my roku.

1 Like

That’s awesome!

What I do is use nodeJS to do this sort of thing… So the restler module will speak to the Roku via http requests (GET/POST), and then you could just run a simple ws web socket to accept incoming connections.

That way you’ve got a super lightweight proxy server to send commands to the Roku from any mobile device.

But maybe all you need is just a simple webpage that handles AJAX stuff. Check out jQuery’s .ajax methods and you might just have an easy win doing that :smile:

Thanks a ton! I haven't worked with nodeJS before, but I will definitely look into it.

1 Like

Even better yet, there is already a Node wrapper for Roku!
https://github.com/TheThingSystem/node-roku

Looks like most of this, if not all of it could be directly done from the Spark Core :spark: But you still need to interface with the Core from some web app on your phone. For something like a remote control where you are just sending commands, you could use Spark.function() calls for all of your buttons, that in turn POST the correct requests from the Core.

Check out my super simple controller:
https://github.com/technobly/Simple-Spark-Core-Controller

Other examples in my repo as well…

1 Like

This is great! Thanks a ton. This is exactly what I was looking for.

2 Likes

I've been using a webb app like that one to do some basic stuff and have a pretty good handle on all that is going on there. But I don't have any experience with the node wrapper or how to use it. Do you have any suggestions for getting familiar with it and how to run it?
The help is much appreciated, and thanks again!

1. Install http://nodejs.org/

2. Go to a command prompt and type node --version and see if it’s working

3a. Find a directory to play around in and type npm install roku

3b. Type npm install node-ssdp (you shouldn’t have to do this, but I did… ignore the errors if they pop up for the moment)

4. Create a new file in that directory called test.js and put the following code into it:

test.js

var ssdp = new(require('node-ssdp'))()
var Roku = require('roku'); // I edited this line from their example, take note!

ssdp.once('response', function inResponse(msg, rinfo) {
  var location = msg.toString().match(/Location: (.*)/i)[1].trim();

  var device = new Roku(location);

  device.press(Roku.HOME);
  device.delay(1000);

  device.launch('pandora', function () {
    process.exit(0);
  });
});

ssdp.search('roku:ecp');

5. Go back to your play directory, and type node test.js and see if your Roku reponds by launching Pandora :smile:

6. Play with more examples https://github.com/TheThingSystem/node-roku/tree/master/test and have fun trying to escape the wicked grip Node.js will have on you now!

1 Like

Edited my install notes and code, after testing and it failing miserably… so much for the repo’s install instructions! And my time is taxed enough so sorry Roku repo… no pull request on this one. I don’t have a roku to test this on, but it seems like it’s working…

Now I WANT a roku -_- darnit…

1 Like

Ooohhh! I have a Roku and this would rock to do some stuff with it! Will play around soon!!

1 Like

None coder here with a ? Have a Roku2 with no remote. I have been using Android app to control it.

Wondering if I can use command prompt to set the wireless up on the Roku? Tell it what network and password to use.

Thanks for any efforts on my behalf.