Skip to content
Permalink
Browse files

use pre shared key instead of the more complicated cookie method

Thanks StefanPuntNL and wennes. Fixes #5.
  • Loading branch information...
breunigs committed Mar 26, 2016
1 parent 1a2b537 commit bc6e63b2475f51545ad503e47461dcf037c95a4d
Showing with 52 additions and 18 deletions.
  1. +25 −1 README
  2. +5 −0 { → auth_cookie_examples}/auth.sh
  3. +20 −0 auth_cookie_examples/example_curl.sh
  4. +1 −7 print_ircc_codes.sh
  5. +1 −10 send_command.sh
26 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
@@ -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=''
@@ -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"
@@ -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
@@ -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>"


0 comments on commit bc6e63b

Please sign in to comment.
You can’t perform that action at this time.