Python plugin: Sony Bravia TV

Python and python framework

Moderator: leecollings

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 »

Wow, it works now ... for all who have problems, the Problem was the opera browser, at the Computer it don't works with a old Version of Firefox, too - now i have used Firefox on Android and it works - nice plugin - thanks ;)
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 wrote:Wow, it works now ... for all who have problems, the Problem was the opera browser, at the Computer it don't works with a old Version of Firefox, too - now i have used Firefox on Android and it works - nice plugin - thanks ;)
That's good to hear :D
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: 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.
Can you also share localtest.py? Maybe I can help with the response part.
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?
Have done some testing with my KDL-32EX720 and only IRCC commands are supported. So it's not possible to turn the TV on.
Also it's not possible to show what is being played.
So the only thing possible is to make a very simple version, where you can use a selector switch or the remote control to do some basic controls (volume, channel, HDMI input etc).
That would mean I have to make a new plugin for this kind of TV's. I can try to find some time to do that, but it has a low priority.
What IRCC functions do you want to control from Domoticz with this plugin?
And maybe we can use some info from this site.
Last edited by G3rard on Tuesday 02 May 2017 0:11, 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 »

EBOOZ wrote:This is awesome! I'll test the script this weekend :roll:
Already did some testing?
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:
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?
Have done some testing with my KDL-32EX720 and only IRCC commands are supported. So it's not possible to turn the TV on.
Also it's not possible to show what is being played.
So the only thing possible is to make a very simple version, where you can use a selector switch or the remote control to do some basic controls (volume, channel, HDMI input etc).
That would mean I have to make a new plugin for this kind of TV's. I can try to find some time to do that, but it has a low priority.
What IRCC functions do you want to control from Domoticz with this plugin?
Unless you really feel like it, I wouldn't bother. I can just as easily use my current script with virtual switches and on/off actions. :)
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:Unless you really feel like it, I wouldn't bother. I can just as easily use my current script with virtual switches and on/off actions. :)
Are you able to switch the TV on with your script (using the wakeonlan part)? Then things are getting more interesting ;)
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:
DarkFoxDK wrote:Unless you really feel like it, I wouldn't bother. I can just as easily use my current script with virtual switches and on/off actions. :)
Are you able to switch the TV on with your script (using the wakeonlan part)? Then things are getting more interesting ;)
Sadly not.
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: 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.
Can you also share localtest.py? Maybe I can help with the response part.
on localtest.py i sinply added :

Code: Select all

x.connect("0000" , "prova","prova1")
on the first run, then i pass the pin and run manually again and changing the code with

Code: Select all

x.connect("3074" , "prova","prova1")
then the tv says device registered but in bravia.py the json.dumps give me error and i'n not able lo read the real response

Code: Select all

pi@raspberrypi:~/domoticz/plugins/sony$ python3 localtest.py
Traceback (most recent call last):
  File "localtest.py", line 25, in <module>
    x.connect("3074" , "prova","prova1")
  File "/home/pi/domoticz/plugins/sony/bravia.py", line 104, in connect
    Domoticz.Debug(json.dumps(response.json()))
AttributeError: 'bytes' object has no attribute 'json'
for now i have set a workaround i call with subprocess a bash script to renew the cookie but would be nice to obtain internally form the plugin
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, yeah that is exactly the line I mentioned in an earlier post, which isn't changed and still depending on the requests module, where the other parts of the code are changed to use the urllib module (requests module is not working with the Python plugin).
Can you change

Code: Select all

Domoticz.Debug(json.dumps(response.json()))
to

Code: Select all

Domoticz.Debug(response)
and maybe comment out the next line starting with self._cookies because that is also still using the requests module part.
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, yeah that is exactly the line I mentioned in an earlier post, which isn't changed and still depending on the requests module, where the other parts of the code are changed to use the urllib module (requests module is not working with the Python plugin).
Can you change

Code: Select all

Domoticz.Debug(json.dumps(response.json()))
to

Code: Select all

Domoticz.Debug(response)
and maybe comment out the next line starting with self._cookies because that is also still using the requests module part.
changing gime me

Code: Select all

pi@raspberrypi:~/domoticz/plugins/sony$ python3 localtest.py
b'{"id":1,"result":[]}'
it seems still give null result
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 on https://github.com/gerard33/sony-bravia.
* Added remote control --> you can now use the remote control in Domoticz (next to the TV icon in the Status device), this can among others be used for volume up and down (will also work when you have an amplifier connected)
* Added channel number in playing information --> shows the channel number which is playing
* Some code cleanup
Not using Domoticz anymore
vgr2
Posts: 71
Joined: Monday 29 August 2016 12:02
Target OS: -
Domoticz version:
Contact:

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

Post by vgr2 »

I could see the remote control, but how should it be work? I could not see any response if i try it... do i have to do updates before
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 »

Update to the latest version of the plugin and then restart Domoticz.
Not using Domoticz anymore
vgr2
Posts: 71
Joined: Monday 29 August 2016 12:02
Target OS: -
Domoticz version:
Contact:

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

Post by vgr2 »

ok I will try it. Will it be also possible (for you) to have an connection to the integrated TV camaera?
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 »

Nope, the TV camera is not part of the interface I am using for the plugin.
Not using Domoticz anymore
vgr2
Posts: 71
Joined: Monday 29 August 2016 12:02
Target OS: -
Domoticz version:
Contact:

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

Post by vgr2 »

Remote control is working with latest version. Will it be possible to add the TV/Radio button to RC?
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 »

Yeah that's possible.
In plugin.py replace the following line

Code: Select all

elif Command == "Channels": _tv.send_req_ircc("AAAAAQAAAAEAAAA6Aw==")        # Display
with

Code: Select all

elif Command == "Channels": _tv.send_req_ircc("AAAAAgAAABoAAABXAw==")        # Tv_Radio
Then select the TV in the Hardware menu and press Update.
After that pressing the CH button can be used for TV/Radio.
You can of course change any of the other keys you would like to use for this.
Not using Domoticz anymore
vgr2
Posts: 71
Joined: Monday 29 August 2016 12:02
Target OS: -
Domoticz version:
Contact:

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

Post by vgr2 »

Could not find the line

elif Command == "Channels": _tv.send_req_ircc("AAAAAQAAAAEAAAA6Aw==")        # Display

in my plugin.py the line Looks like

elif Command == "Channels": _tv.send_req_ircc("AAAAAgAAABoAAABhAw==") # PopUpMenu
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 »

You're right, I already have an updated version where the CH button is representing the Info button of the TV remote.
But the line with Channels and ending with #PopUpMenu is the one you can replace.
Not using Domoticz anymore
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 0 guests