Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

using tcl to control a roku

67 views
Skip to first unread message

two...@gmail.com

unread,
Jan 16, 2018, 5:49:51 PM1/16/18
to
Below is some code to send commands to a roku using tcl. Note, I only have 1
roku device, and it's kinda old. So, you might want to try out the curl command
first, in case they've changed things on newer devices.

This works on windows, androwish, and should on linux (though I
have not tested a tcl version on linux)

On my lan, I use my router's dhcp address reservation to provide a fixed
ip address for my roku, 192.168.1.76 and the port number is 8060.

On linux, one can test out roku commands using the command line program curl.

curl -d '' http://192.168.1.76:8060/keypress/select

That should send the select key.

The android app store provides a nice roku remote. However,
the real need for me was to create "macro" commands for the mlb.tv
app. For example, I bring up a screen with all the innings 1 to 9
home and away, so I can jump to a specific 1/2 inning in one button press.
On my older roku, this could take as many as 20 key presses to
get to say the 7th inning. And you have select the home/away audio
every time as well. Quite tedious.

Also, a 2 minute skip is perfect when watching baseball, both for
skipping over ads and relief pitchers. To skip, one uses the
right or left (12 times for 2 minutes) followed by select.

so, for example, to skip 2 minutes ahead, with 200 ms delay, between each:

toroku right 12 200
toroku select 1 ;# must send this also to restart playing



Here are a selection of commands I use, pretty much
the intuitive name of the key you want to send. The 2
defaulted args are the number of times to send and an optional
delay after each send.



toroku back
toroku down
toroku down $num 200
toroku InstantReplay
toroku left $n
toroku play ;# this one is the play/pause toggle
toroku right $n
toroku select
toroku up 1 250

I build a small keypad using the following list of triples:

{"<-" back x}
{"^ " up rep}
{"Ho" home x}
{"< " left rep}
{"ok" select x}
{"> " right rep}
{"rp" instantreplay x}
{"v " down rep}
{"* " info x}


where rep means this key will be repeated upon long press (which only works on
android however)


========================================================

package require http

proc toroku {key {rep 1} {wt 0}} {
for {set m 1} {$m <= $rep} {incr m} {
quickroku "http://192.168.1.76:8060/keypress/$key"
if { $wt != 0 } {
wait $wt
}
}
return
}

proc quickroku {args} {
set token [::http::geturl $args -method POST ]
::http::reset $token
}
proc uniqkey { } {
set key [ expr { pow(2,31) + [ clock clicks ] } ]
set key [ string range $key end-8 end-3 ]
set key [ clock seconds ]$key
return $key
}

proc wait { ms } {
set uniq [ uniqkey ]
set ::__sleep__tmp__$uniq 0
after $ms set ::__sleep__tmp__$uniq 1
vwait ::__sleep__tmp__$uniq
unset ::__sleep__tmp__$uniq
}

Arjen Markus

unread,
Jan 17, 2018, 2:58:43 AM1/17/18
to
Perhaps put this code on the Wiki? (I have no idea what a roku is, but my ignorance is probably more indicative of me than of rokus)

The Wiki is less volatile than the newgroup.

Regards,

Arjen

two...@gmail.com

unread,
Jan 17, 2018, 1:00:35 PM1/17/18
to


> The Wiki is less volatile than the newgroup.


Thanks for the suggestion; Done.

A roku is a popular internet tv box.

0 new messages