"tadakk" wrote:
Hey guys,
I really like that script. I decided to make a Powershell 3.0 equivalent.
$roku=$args[0]
if ($roku -ne $null) {
$Error.Clear()
Invoke-RestMethod -Method Post -Uri "http://$($roku):8060/keypress/Home"
if ($Error.count) {Write-Host "ERROR"; exit}
sleep -Milliseconds 350
Invoke-RestMethod -Method Post -Uri "http://$($roku):8060/keypress/Up"
sleep -Milliseconds 350
Invoke-RestMethod -Method Post -Uri "http://$($roku):8060/keypress/Right"
sleep -Milliseconds 350
Invoke-RestMethod -Method Post -Uri "http://$($roku):8060/keypress/Up"
sleep -Milliseconds 350
Invoke-RestMethod -Method Post -Uri "http://$($roku):8060/keypress/Right"
sleep -Milliseconds 350
Invoke-RestMethod -Method Post -Uri "http://$($roku):8060/keypress/Up"
sleep -Milliseconds 350
Invoke-RestMethod -Method Post -Uri "http://$($roku):8060/keypress/Up"
sleep -Milliseconds 350
Invoke-RestMethod -Method Post -Uri "http://$($roku):8060/keypress/Up"
sleep -Milliseconds 350
Invoke-RestMethod -Method Post -Uri "http://$($roku):8060/keypress/Right"
sleep -Milliseconds 350
Invoke-RestMethod -Method Post -Uri "http://$($roku):8060/keypress/Select"
sleep -Milliseconds 350
}
else {
Write-Host "You must specify the IP address"
}
Tommy
I had to add an additional home command to the beginning, and an additional up... and I've reduced the delays after the initial home press... and since I only have 1 roku - I moved the IP into the file... but this works for me: (obviously tweak the IP to suit 🙂 )
it just does nothing if its in that annoying "pairing with roku remote" message...
#!/bin/bash
# reboot the specified roku device
ROKU="192.168.1.111"
if [ "$ROKU" != "" ]; then
curl -X POST -d "" http://$ROKU:8060/keypress/Home
if [ "$?" != "0" ]; then echo "ERROR"; unset ROKU; exit $?; fi
sleep 0.35
curl -X POST -d "" http://$ROKU:8060/keypress/Home
sleep 0.35
curl -X POST -d "" http://$ROKU:8060/keypress/Up
sleep 0.35
curl -X POST -d "" http://$ROKU:8060/keypress/Right
sleep 0.35
curl -X POST -d "" http://$ROKU:8060/keypress/Up
sleep 0.35
curl -X POST -d "" http://$ROKU:8060/keypress/Right
sleep 0.35
curl -X POST -d "" http://$ROKU:8060/keypress/Up
sleep 0.35
curl -X POST -d "" http://$ROKU:8060/keypress/Up
sleep 0.35
curl -X POST -d "" http://$ROKU:8060/keypress/Up
sleep 0.35
curl -X POST -d "" http://$ROKU:8060/keypress/Up
sleep 0.35
curl -X POST -d "" http://$ROKU:8060/keypress/Right
sleep 0.35
curl -X POST -d "" http://$ROKU:8060/keypress/Select
sleep 0.35
fi
unset ROKU
These posts helped immensely. Here's a script that makes use of loops to shorten the code. Tested on Roku Ultra and Streaming Stick:
#!/bin/bash
# Date = 04.26.20
# Leveraged some code from https://github.com/chall32/ROKU_restart.sh
# Tested on Roku Ultra & Roku Streaming Stick
ShowUsage() {
echo "usage: $0 <ROKU IP>"
}
EXPECTED_ARGS=1
TARGET=$1
ROKUREBOOT=("home" "up" "right" "up" "right" "up" "up" "up" "up" "right" "select")
if [ $# -lt $EXPECTED_ARGS ]
then
ShowUsage
exit 1
fi
for i in $*
do
case $i in
--help)
ShowUsage
exit 1
;;
esac
done
if [[ -n "$TARGET" ]]
then
curl -d '' http://$TARGET:8060/keypress/home
sleep 3.5
for CMD in ${ROKUREBOOT[@]}
do
curl -d '' http://$TARGET:8060/keypress/$CMD
sleep 0.35
done
fi