Python plugin: Sony Bravia TV

Python and python framework

Moderator: leecollings

maomanna
Posts: 94
Joined: Monday 30 November 2015 16:21
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Sony Bravia [ready for test]

Post by maomanna »

yes, was fixed, see editted post
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: Python plugin: Sony Bravia [ready for test]

Post by G3rard »

The volume slider only works when the speakers of the TV are used (so not if you are using an amplifier).

Which TV model do you have? Then I can add your model to the list of working models on github.
Not using Domoticz anymore
maomanna
Posts: 94
Joined: Monday 30 November 2015 16:21
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Sony Bravia [ready for test]

Post by maomanna »

I dont use an amplifier. I use a soundbar which is connecties with ARC to my tv

My model is 50w829.
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Python plugin: Sony Bravia [ready for test]

Post by G3rard »

A soundbar will have the same behaviour as an amplifier.
When you set the TV to use the built-in speakers (via Options), you will see that you can control the volume with Domoticz (and hear the sound isn't really good ).
That's working for sure as I have the same model
Not using Domoticz anymore
maomanna
Posts: 94
Joined: Monday 30 November 2015 16:21
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Sony Bravia [ready for test]

Post by maomanna »

Thats a pity, because the volume of the soundbar is manager by the tv. Using the remote of the tv, see the volume at ofthe tv going up and down.
EBOOZ
Posts: 11
Joined: Wednesday 30 December 2015 9:50
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.8153
Contact:

Re: Python plugin: Sony Bravia [ready for test]

Post by EBOOZ »

This is awesome! I'll test the script this weekend :roll:
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: Python plugin: Sony Bravia [ready for test]

Post by G3rard »

Just released a new version. Available on https://github.com/gerard33/sony-bravia.
* Added Netflix to the Sources device
* When playing the Netflix app, this is also shown on the Status device (there is no app information available from the API, so it will always show Netflix)
* Added a device from which you can start/stop/pause
* Added a device with a channel list
--You can choose channels 1-9. Just rename CH1, CH2 etc. to your channel names in the selector switch (keep --Choose a channel-- in place)
sony_tv_control_channel.png
sony_tv_control_channel.png (63.56 KiB) Viewed 3400 times
Last edited by G3rard on Monday 24 April 2017 23:33, edited 3 times in total.
Not using Domoticz anymore
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: Python plugin: Sony Bravia [ready for test]

Post by G3rard »

Monki77 wrote:Nice plugin!

X8509C Android TV here.
My findings are -

Source seems to work fine.
EPG data works fine - Reports what is on TV
Volume doesn't work (as mentioned by others) but muting and reporting of volume does work.
The TV Remote button doesn't do anything (Not sure what it's supposed to do).
The TV does turn off, but will not turn on (I use WIFI, and a quick look at your script shows you use WOL, so i'm out of luck)

What i use to turn the TV on via wifi is an adapted version of another script made by StefanPuntNL (pasted it at the end of my post)
i just added this part -

jsonbodypoweron = '{\\"id\\":2,\\"method\\":\\"setPowerStatus\\",\\"version\\":\\"1.0\\",\\"params\\":[{ \\"status\\" : true}]}'

and then i edited the rest of the script accordingly.
I don't know if this only works for android TVs or not though...

Here's the full On/Off script (it does pull info from another script which pings my TV)
I have added the setPowerStatus command.
Please remove your TV from the Hardware tab, update to the latest version on Github and add the Hardware again (after a restart of Domoticz).
Then replace the MAC address with "Android" (case sensitive).
That should use the setPowerStatus = True command.
Let me know if it works.
Not using Domoticz anymore
markcame
Posts: 36
Joined: Wednesday 07 December 2016 19:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Sony Bravia [ready for test]

Post by markcame »

G3rard wrote:
markcame wrote:for the authorization with cookie i use the following script that can be found here https://github.com/breunigs/bravia-auth-and-remote

move on auth_cookie_examples folder then run auth.sh (you must previously fill with the required information in the script such as IP, nickname and a UUID)
then on the TV wil be displayed a code you can now enter on the console the code and a file will be created with the cookie.

it would be nice if this can be automatized in the plugin as a binding procedure, otherwise you can always run the the script and modify to update a domoticz variable that the plugin can catch, i think that for a full integration the harder part is to create a text box to enter the code displayed on the TV.
I think this can also work with the bravia.py file.
Are you able to try the connect function from bravia.py? You can add that to localtest.py to see if that works as well.
Sorry, but in the last past days i was a bit busy but i didn't stop to test the plugin.
I've tryed the connect function and passing 0000 the tv will prompt a pin, i've also experimented with the cookie and i will confirm that afther about 2 weeks the cookie must be renewd, to do this i pass a null pin (using the code previously found on github) and this tells the tv to send a new cookie, obiouvsly this happens only if the device was previously paired, do you think this can be integrated in the plugin ?
DarkFoxDK
Posts: 26
Joined: Saturday 02 January 2016 2:22
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: Python plugin: Sony Bravia [ready for test]

Post by DarkFoxDK »

I've got a Sony Bravia KDL-46EX724, which is a couple of generations older than the ones supported by the plugin, however, it still does support IRCC codes, so I wonder what would be needed for at least partial support?

Currently I'm using this script for somewhat limited control:

Code: Select all

#!/bin/bash

#Uncomment the following lines by removing the hash sign when your variables are not stored in profile.d
SonyBraviaAuthHeader="X-Auth-PSK"
SonyBraviaPreSharedKey="sony"
SonyBraviaIP="192.168.33.10"
SonyBraviaMAC="30:f9:ed:e2:3c:1b"


set -e

cd $(dirname $0)

if [ "$1" = "" ]; then
  echo "Usage: $0 <COMMAND> [COUNT]"
  exit 1
fi

if [ "$1" = "PowerOn" ]; then
  wakeonlan $SonyBraviaMAC >/dev/null
  echo "PowerOn: ✓"
  exit 0
fi

if [ "$2" = "" ]; then
  count="1"
else
  count="$2"
fi

declare -A commandmap
#commandmap[PowerOff]="AAAAAQAAAAEAAAAvAw=="
#commandmap[PowerOff]="AAAAAQAAAAEAAAAVAw=="
commandmap[PowerOff]="AAAAAQAAAAEAAAAuAw=="
commandmap[Input]="AAAAAQAAAAEAAAAlAw=="
commandmap[TV]="AAAAAQAAAAEAAAAkAw=="
commandmap[GGuide]="AAAAAQAAAAEAAAAOAw=="
commandmap[EPG]="AAAAAgAAAKQAAABbAw=="
commandmap[Favorites]="AAAAAgAAAHcAAAB2Aw=="
commandmap[Display]="AAAAAQAAAAEAAAA6Aw=="
commandmap[Home]="AAAAAQAAAAEAAABgAw=="
commandmap[Options]="AAAAAgAAAJcAAAA2Aw=="
commandmap[Return]="AAAAAgAAAJcAAAAjAw=="
commandmap[Up]="AAAAAQAAAAEAAAB0Aw=="
commandmap[Down]="AAAAAQAAAAEAAAB1Aw=="
commandmap[Right]="AAAAAQAAAAEAAAAzAw=="
commandmap[Left]="AAAAAQAAAAEAAAA0Aw=="
commandmap[Confirm]="AAAAAQAAAAEAAABlAw=="
commandmap[Red]="AAAAAgAAAJcAAAAlAw=="
commandmap[Green]="AAAAAgAAAJcAAAAmAw=="
commandmap[Yellow]="AAAAAgAAAJcAAAAnAw=="
commandmap[Blue]="AAAAAgAAAJcAAAAkAw=="
commandmap[Num1]="AAAAAQAAAAEAAAAAAw=="
commandmap[Num2]="AAAAAQAAAAEAAAABAw=="
commandmap[Num3]="AAAAAQAAAAEAAAACAw=="
commandmap[Num4]="AAAAAQAAAAEAAAADAw=="
commandmap[Num5]="AAAAAQAAAAEAAAAEAw=="
commandmap[Num6]="AAAAAQAAAAEAAAAFAw=="
commandmap[Num7]="AAAAAQAAAAEAAAAGAw=="
commandmap[Num8]="AAAAAQAAAAEAAAAHAw=="
commandmap[Num9]="AAAAAQAAAAEAAAAIAw=="
commandmap[Num0]="AAAAAQAAAAEAAAAJAw=="
commandmap[Num11]="AAAAAQAAAAEAAAAKAw=="
commandmap[Num12]="AAAAAQAAAAEAAAALAw=="
commandmap[VolumeUp]="AAAAAQAAAAEAAAASAw=="
commandmap[VolumeDown]="AAAAAQAAAAEAAAATAw=="
commandmap[Mute]="AAAAAQAAAAEAAAAUAw=="
commandmap[ChannelUp]="AAAAAQAAAAEAAAAQAw=="
commandmap[ChannelDown]="AAAAAQAAAAEAAAARAw=="
commandmap[SubTitle]="AAAAAgAAAJcAAAAoAw=="
commandmap[ClosedCaption]="AAAAAgAAAKQAAAAQAw=="
commandmap[Enter]="AAAAAQAAAAEAAAALAw=="
commandmap[DOT]="AAAAAgAAAJcAAAAdAw=="
commandmap[Analog]="AAAAAgAAAHcAAAANAw=="
commandmap[Teletext]="AAAAAQAAAAEAAAA/Aw=="
commandmap[Exit]="AAAAAQAAAAEAAABjAw=="
commandmap[Analog2]="AAAAAQAAAAEAAAA4Aw=="
commandmap[*AD]="AAAAAgAAABoAAAA7Aw=="
commandmap[Digital]="AAAAAgAAAJcAAAAyAw=="
commandmap[Analog?]="AAAAAgAAAJcAAAAuAw=="
commandmap[BS]="AAAAAgAAAJcAAAAsAw=="
commandmap[CS]="AAAAAgAAAJcAAAArAw=="
commandmap[BSCS]="AAAAAgAAAJcAAAAQAw=="
commandmap[Ddata]="AAAAAgAAAJcAAAAVAw=="
commandmap[PicOff]="AAAAAQAAAAEAAAA+Aw=="
commandmap[Tv_Radio]="AAAAAgAAABoAAABXAw=="
commandmap[Theater]="AAAAAgAAAHcAAABgAw=="
commandmap[SEN]="AAAAAgAAABoAAAB9Aw=="
commandmap[InternetWidgets]="AAAAAgAAABoAAAB6Aw=="
commandmap[InternetVideo]="AAAAAgAAABoAAAB5Aw=="
commandmap[Netflix]="AAAAAgAAABoAAAB8Aw=="
commandmap[SceneSelect]="AAAAAgAAABoAAAB4Aw=="
commandmap[Mode3D]="AAAAAgAAAHcAAABNAw=="
commandmap[iManual]="AAAAAgAAABoAAAB7Aw=="
commandmap[Audio]="AAAAAQAAAAEAAAAXAw=="
commandmap[Wide]="AAAAAgAAAKQAAAA9Aw=="
commandmap[Jump]="AAAAAQAAAAEAAAA7Aw=="
commandmap[PAP]="AAAAAgAAAKQAAAB3Aw=="
commandmap[MyEPG]="AAAAAgAAAHcAAABrAw=="
commandmap[ProgramDescription]="AAAAAgAAAJcAAAAWAw=="
commandmap[WriteChapter]="AAAAAgAAAHcAAABsAw=="
commandmap[TrackID]="AAAAAgAAABoAAAB+Aw=="
commandmap[TenKey]="AAAAAgAAAJcAAAAMAw=="
commandmap[AppliCast]="AAAAAgAAABoAAABvAw=="
commandmap[acTVila]="AAAAAgAAABoAAAByAw=="
commandmap[DeleteVideo]="AAAAAgAAAHcAAAAfAw=="
commandmap[PhotoFrame]="AAAAAgAAABoAAABVAw=="
commandmap[TvPause]="AAAAAgAAABoAAABnAw=="
commandmap[KeyPad]="AAAAAgAAABoAAAB1Aw=="
commandmap[Media]="AAAAAgAAAJcAAAA4Aw=="
commandmap[SyncMenu]="AAAAAgAAABoAAABYAw=="
commandmap[Forward]="AAAAAgAAAJcAAAAcAw=="
commandmap[Play]="AAAAAgAAAJcAAAAaAw=="
commandmap[Rewind]="AAAAAgAAAJcAAAAbAw=="
commandmap[Prev]="AAAAAgAAAJcAAAA8Aw=="
commandmap[Stop]="AAAAAgAAAJcAAAAYAw=="
commandmap[Next]="AAAAAgAAAJcAAAA9Aw=="
commandmap[Rec]="AAAAAgAAAJcAAAAgAw=="
commandmap[Pause]="AAAAAgAAAJcAAAAZAw=="
commandmap[Eject]="AAAAAgAAAJcAAABIAw=="
commandmap[FlashPlus]="AAAAAgAAAJcAAAB4Aw=="
commandmap[FlashMinus]="AAAAAgAAAJcAAAB5Aw=="
commandmap[TopMenu]="AAAAAgAAABoAAABgAw=="
commandmap[PopUpMenu]="AAAAAgAAABoAAABhAw=="
commandmap[RakurakuStart]="AAAAAgAAAHcAAABqAw=="
commandmap[OneTouchTimeRec]="AAAAAgAAABoAAABkAw=="
commandmap[OneTouchView]="AAAAAgAAABoAAABlAw=="
commandmap[OneTouchRec]="AAAAAgAAABoAAABiAw=="
commandmap[OneTouchStop]="AAAAAgAAABoAAABjAw=="
commandmap[DUX]="AAAAAgAAABoAAABzAw=="
commandmap[FootballMode]="AAAAAgAAABoAAAB2Aw=="
commandmap[Social]="AAAAAgAAABoAAAB0Aw=="
commandmap[Hdmi1]="AAAAAgAAABoAAABaAw=="
commandmap[Hdmi2]="AAAAAgAAABoAAABbAw=="
commandmap[Hdmi3]="AAAAAgAAABoAAABcAw=="
commandmap[Hdmi4]="AAAAAgAAABoAAABdAw=="

IRCC=${commandmap[$1]}

if [ "$IRCC" = "" ]; then
  echo "Unkown command $1"
  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>$IRCC</IRCCCode></u:X_SendIRCC></s:Body></s:Envelope>"
auth="$SonyBraviaAuthHeader: $SonyBraviaPreSharedKey"
url=http://$SonyBraviaIP/IRCC

for ((n=0;n<count;n++)); do
  code=$(curl -w "%{http_code}" --silent -d "$cmd" -H 'Content-Type: text/xml; charset=UTF-8' -H "$auth" $url -o /dev/null )

  if [ "$code" = "200" ]; then
    echo "$1: ✓"
  else
    echo "$1: Command failed (HTTP_CODE: $code, try running it in a console)"
    exit 1
  fi
done
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: Python plugin: Sony Bravia [ready for test]

Post by G3rard »

markcame wrote: Sorry, but in the last past days i was a bit busy but i didn't stop to test the plugin.
I've tryed the connect function and passing 0000 the tv will prompt a pin, i've also experimented with the cookie and i will confirm that afther about 2 weeks the cookie must be renewd, to do this i pass a null pin (using the code previously found on github) and this tells the tv to send a new cookie, obiouvsly this happens only if the device was previously paired, do you think this can be integrated in the plugin ?
Can you share me some more details on the steps your are taking and what you think can be achieved from within the plugin?

* First registration
I guess you need to enter the pincode that is shown on the TV in the terminal when using the code from https://github.com/breunigs/bravia-auth-and-remote?
That means that you always need to go to the terminal to pair the TV, because you can't enter the code (which will be different every time) in Domoticz.

* Cookie renewal
Is that done with reauth.sh and without a pin?
In that case maybe it is a solution to use a LUA script in Domoticz to run the sh script every 2 weeks.

The plugin is designed to use with a pre-shared key which works much easier than the cookie method.
I saw that breunings also changed his code to work with a pre-shared key.
Last edited by G3rard on Sunday 30 April 2017 0:47, edited 1 time in total.
Not using Domoticz anymore
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: Python plugin: Sony Bravia [ready for test]

Post by G3rard »

DarkFoxDK wrote:I've got a Sony Bravia KDL-46EX724, which is a couple of generations older than the ones supported by the plugin, however, it still does support IRCC codes, so I wonder what would be needed for at least partial support?

Currently I'm using this script for somewhat limited control:
What can you use from that script with your TV? Because the plugin uses the same method as in that script.
The plugin also uses IRCC codes, for example in the Sources switch. Can you use that?
Not using Domoticz anymore
DarkFoxDK
Posts: 26
Joined: Saturday 02 January 2016 2:22
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: Python plugin: Sony Bravia [ready for test]

Post by DarkFoxDK »

G3rard wrote: What can you use from that script with your TV? Because the plugin uses the same method as in that script.
The plugin also uses IRCC codes, for example in the Sources switch. Can you use that?
I think pretty much all but power on and off works in that script. None of the commands in the plugin work, it never even acknowledged that the TV was on.
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Python plugin: Sony Bravia [ready for test]

Post by G3rard »

@DarkFoxDK, the switches in Domoticz only work when the status switch of the TV in Domoticz is on (it's coded that way, because it has no use sending an IRCC command if the TV is not on). Apparently the code which is used to see if the TV is on, is not working with your TV model.

Are you able to change localtest.py in the sony-bravia folder?
Then you can try to send some IRCC commands when your TV is switched on. That script also checks if the TV is on, before you can send a command, but that can be easily changed.
Let me know if you need any help with that.

If that works, it is possible to send IRCC command from Domoticz, but it will only give you some basic functionalities, as switching on/off and the program information is not available.

I will also try some tests myself with a 32EX720 I have.
Not using Domoticz anymore
markcame
Posts: 36
Joined: Wednesday 07 December 2016 19:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Sony Bravia [ready for test]

Post by markcame »

G3rard wrote:
markcame wrote: Sorry, but in the last past days i was a bit busy but i didn't stop to test the plugin.
I've tryed the connect function and passing 0000 the tv will prompt a pin, i've also experimented with the cookie and i will confirm that afther about 2 weeks the cookie must be renewd, to do this i pass a null pin (using the code previously found on github) and this tells the tv to send a new cookie, obiouvsly this happens only if the device was previously paired, do you think this can be integrated in the plugin ?
Can you share me some more details on the steps your are taking and what you think can be achieved from within the plugin?

* First registration
I guess you need to enter the pincode that is shown on the TV in the terminal when using the code from https://github.com/breunigs/bravia-auth-and-remote?
That means that you always need to go to the terminal to pair the TV, because you can't enter the code (which will be different every time) in Domoticz.

* Cookie renewal
Is that done with reauth.sh and without a pin?
In that case maybe it is a solution to use a LUA script in Domoticz to run the sh script every 2 weeks.

The plugin is designed to use with a pre-shared key which works much easier than the cookie method.
I saw that breunings also changed his code to work with a pre-shared key.
Ok I've tryed on localtest.py the connect function passing "0000" as pin start the pairing, then i execute again with the pin provided by TV and the registration was succesfull. I was not able instead to retrive the cookie from the function, it seems something goes wrong with the response from json.

With the bash script instead i'm able tor pair and retrive the cookie, then every other launch of the script passing an empy pin with an already paired device force the TV to sendo a new cookie.

I think this can be implemented in the plugin in the following way.

On plugin configuration in domoticz you can provide a checkbox to enable or not the use of cookie, than you can create a variable on domoticz in and you can store the auth cookie, then the variable that store the cookie can be updated triggered by the exeption on error 403 forbidden that means that the access is not authorized by the tv.

For the first pairing i think is better execute them on command line because i think will be difficult to input the pin provided by tv in domoticz.
Schuko80
Posts: 8
Joined: Sunday 23 April 2017 10:07
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Sony Bravia [ready for test]

Post by Schuko80 »

Hey, i got some problems, to get the plugin working...

Python is installed and I'm on the last beta of Domoticz. In the log I see no Problem with Python, too.

Under Hardware I see the Sony Bravia, if i select it and click on add, it does nothing, if I don't use a name, i get the message, that i have to put a name in, so i think domoticz is not the problem. Every other device will work, too.

I try "localtest.py" on ssh - this will don't work - permission denied - but i think there is a problem with the PSK key, mac and ip is ok

Any idea?

EDIT:
Ok, "localtest.py" works now, but i get an error on line 61:

TV model: KDL-55W805C
Traceback (most recent call last):
File "localtest.py", line 61, in <module>
print('MAC address:', network['mac'])
KeyError: 'mac'

if i command out line 61, localtest works

don't know where to search the error :/
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: Python plugin: Sony Bravia [ready for test]

Post by G3rard »

@Schuko80
Is localtest.py showing information on the program that is playing on the TV (if you are using the built-in TV tuner)?
Strange that the MAC address gives an error. Can you uncomment line 62 and share the results?

Are other Python plugins working on your system?
And can you explain a bit more on what happens when you try to add the plugin under Hardware? Maybe some screenshots.
And what do you mean with: "Every other device will work, too."?
Not using Domoticz anymore
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: Python plugin: Sony Bravia [ready for test]

Post by G3rard »

markcame wrote: Ok I've tryed on localtest.py the connect function passing "0000" as pin start the pairing, then i execute again with the pin provided by TV and the registration was succesfull. I was not able instead to retrive the cookie from the function, it seems something goes wrong with the response from json.
I made some changes in bravia.py because the plugin was not working with requests module, so changed that to urllib module.
But I have not tested the connect function, so indeed there could be some isssues with the response. I think line 103 and 104 will not work as it is in the current code.
Are you able to change this, to see if you can get that working?
markcame wrote: I think this can be implemented in the plugin in the following way.
On plugin configuration in domoticz you can provide a checkbox to enable or not the use of cookie, than you can create a variable on domoticz in and you can store the auth cookie, then the variable that store the cookie can be updated triggered by the exeption on error 403 forbidden that means that the access is not authorized by the tv.
For the first pairing i think is better execute them on command line because i think will be difficult to input the pin provided by tv in domoticz.
Are you able do make some code changes for this yourself?
Not using Domoticz anymore
markcame
Posts: 36
Joined: Wednesday 07 December 2016 19:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Sony Bravia [ready for test]

Post by markcame »

markcame wrote: I think this can be implemented in the plugin in the following way.
On plugin configuration in domoticz you can provide a checkbox to enable or not the use of cookie, than you can create a variable on domoticz in and you can store the auth cookie, then the variable that store the cookie can be updated triggered by the exeption on error 403 forbidden that means that the access is not authorized by the tv.
For the first pairing i think is better execute them on command line because i think will be difficult to input the pin provided by tv in domoticz.
Are you able do make some code changes for this yourself?[/quote]

Ok i've coded something but is not complete yet, now on the plugin configuration panel you can select the use of cookie, in this case a text device will be created to store it.
Actually i have again the problem to renew the cookie from the plugin itself, i have to trigger a modified bash script for the only renew this update via json the value of the thext device
unfortunatly this is again manual and not automated i want to integrate it so when catch a forbidden access the script will be trigger automatically the script or the process renew.

i have try to use localtest.py but i get response "[]" and i'm not able to read the real response, i think that actually the renew happens because the old cookie loses it's validity.
Attachments
pluginforcookie.tar.gz
(9.2 KiB) Downloaded 74 times
Schuko80
Posts: 8
Joined: Sunday 23 April 2017 10:07
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Sony Bravia [ready for test]

Post by Schuko80 »

G3rard wrote:@Schuko80
Is localtest.py showing information on the program that is playing on the TV (if you are using the built-in TV tuner)?
Strange that the MAC address gives an error. Can you uncomment line 62 and share the results?

Are other Python plugins working on your system?
And can you explain a bit more on what happens when you try to add the plugin under Hardware? Maybe some screenshots.
And what do you mean with: "Every other device will work, too."?
Ok, bravia-auth-and-remote works perfect ...

localtest will show this:

RTL2 - Der Trödeltrupp - Das Geld liegt im Keller
Playing: 15:59 - 18:00 [35%]
TV model: KDL-55W805C
Traceback (most recent call last):
File "localtest.py", line 61, in <module>
print('MAC address:', network['mac'])
KeyError: 'mac'



when i uncommand line 61 it works:

RTL2 - Der Trödeltrupp - Das Geld liegt im Keller
Playing: 15:59 - 18:00 [37%]
TV model: KDL-55W805C
Volume: 8


in Domoticz i see no Fields for IP adress, PSK and so on - look the attachment
Attachments
sony.png
sony.png (129.03 KiB) Viewed 3283 times
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest