Skip to content

Commit

Permalink
use pre shared key instead of the more complicated cookie method
Browse files Browse the repository at this point in the history
Thanks StefanPuntNL and wennes. Fixes #5.
  • Loading branch information
breunigs committed Mar 26, 2016
1 parent 1a2b537 commit bc6e63b
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 18 deletions.
26 changes: 25 additions & 1 deletion README
@@ -1 +1,25 @@
The usage of these scripts should be relatively straight forward. If you want more details, please refer to the corresponding blog post: https://blog.yrden.de/2014/11/14/remote-control-bravia-tvs-with-authentication.html
## Setup

You need to set your TV to use a pre-shared key.

1. Navigate to: [Settings] → [Network] → [Home Network Setup] → [IP Control]
2. Set [Authentication] to [Normal and Pre-Shared Key]
3. There should be a new menu entry [Pre-Shared Key]. Set it to **0000**. If you choose anything else, you need to change the PSK in the `send_command.sh` script.

## Usage

1. Run `print_ircc_codes.sh TV_IP_HERE` to get an overview of the commands possible.
2. Run `send_command.sh TV_IP_HERE ONE_COMMAND_HERE`. A command looks like `AAAAAQAAAAEAAABgAw==`.
3. The TV will execute the command and immediately return. If you want to navigate through menus, you'll have to manually `sleep` until the TV has finished the command/animation.

See `example_goto_media_player.sh` on how to build your automations.

Have fun!

### More detailed explanation

The original blog post describes how to figure this out in general:
https://blog.yrden.de/2014/11/14/remote-control-bravia-tvs-with-authentication.html

StefanPuntNL figured out how to use it with a Pre-Shared-Key, which is much simpler:
https://www.domoticz.com/forum/viewtopic.php?t=8301
5 changes: 5 additions & 0 deletions auth.sh → auth_cookie_examples/auth.sh
@@ -1,5 +1,10 @@
#!/bin/sh

# Note: this is only useful when you want to build an APP that also supports
# authentication via cookie. The cookie method loses validity after a
# couple of weeks, so so there is probably some refresh method required
# which is not detailed here.

set -e

tv_ip=''
Expand Down
20 changes: 20 additions & 0 deletions auth_cookie_examples/example_curl.sh
@@ -0,0 +1,20 @@
#!/bin/sh

# Note: this is only useful when you want to build an APP that also supports
# authentication via cookie. The cookie method loses validity after a
# couple of weeks, so so there is probably some refresh method required
# which is not detailed here.

if [ "$1" = "" ] || [ "$2" = "" ]; then
echo "Usage: $0 <TV_IP> <IRCC_COMMAND>"
exit 1
fi

if ! [ -e 'auth_cookie' ]; then
echo 'auth_cookie not found. Run ./auth.sh first.'
exit 1
fi

cmd="<?xml version=\"1.0\"?><s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:X_SendIRCC xmlns:u=\"urn:schemas-sony-com:service:IRCC:1\"><IRCCCode>$2</IRCCCode></u:X_SendIRCC></s:Body></s:Envelope>"

curl --silent -XPOST http://$ipaddress/sony/IRCC -d "$cmd" -H 'Content-Type: text/xml; charset=UTF-8' -H 'SOAPACTION: "urn:schemas-sony-com:service:IRCC:1#X_SendIRCC"' -H"Cookie: $cookie"
8 changes: 1 addition & 7 deletions print_ircc_codes.sh
Expand Up @@ -9,10 +9,4 @@ if [ "$1" = "" ]; then
exit 1
fi

if [ -e 'auth_cookie' ]; then
read cookie < auth_cookie

curl --silent --cookie \"$cookie\" -XPOST http://$1/sony/system -d '{"method":"getRemoteControllerInfo","params":[],"id":10,"version":"1.0"}' | python -m json.tool
else
echo 'auth_cookie not found. Run ./auth.sh first.'
fi
curl --silent -XPOST http://$1/sony/system -d '{"method":"getRemoteControllerInfo","params":[],"id":10,"version":"1.0"}' | python -m json.tool
11 changes: 1 addition & 10 deletions send_command.sh
Expand Up @@ -2,20 +2,11 @@

set -e

cd $(dirname $0)

if [ "$1" = "" ]; then
if [ "$1" = "" ] || [ "$2" = "" ]; then
echo "Usage: $0 <TV_IP> <IRCC_COMMAND>"
exit 1
fi

if ! [ -e 'auth_cookie' ]; then
echo 'auth_cookie not found. Run ./auth.sh first.'
exit 1
fi

read cookie < auth_cookie

cmd="<?xml version=\"1.0\"?><s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:X_SendIRCC xmlns:u=\"urn:schemas-sony-com:service:IRCC:1\"><IRCCCode>$2</IRCCCode></u:X_SendIRCC></s:Body></s:Envelope>"


Expand Down

0 comments on commit bc6e63b

Please sign in to comment.