Page 2 of 11
Re: Python plugin: Sony Bravia [ready for test]
Posted: Wednesday 12 April 2017 23:02
by maomanna
It seems the plugin here isnt working.
im on V3.5877.
updating to beta fails
How can i fix this?
Re: Python plugin: Sony Bravia [ready for test]
Posted: Wednesday 12 April 2017 23:20
by G3rard
You indeed need a beta to use this. Your version is the latest stable which does not support the Python plugins.
You can go to your Domoticz folder and execute
to install the latest beta.
Re: Python plugin: Sony Bravia [ready for test]
Posted: Thursday 13 April 2017 7:01
by maomanna
Een i user ./Updatebeta, domoticz wint start anymore. Seems that there is another problem
Re: Python plugin: Sony Bravia [ready for test]
Posted: Thursday 13 April 2017 12:02
by DaWauZ
I have a sony kdl40525exbaep from 2012, dont know if it works with, but if you think so, I can test for you.
Re: Python plugin: Sony Bravia [ready for test]
Posted: Thursday 13 April 2017 13:07
by NotsniwFrancisco
Hello G3rard, I'm new here and I don't have any idea about Python. But want to learn it. I will follow you, please update your post as much as you can. Thanks.
Re: Python plugin: Sony Bravia [ready for test]
Posted: Thursday 13 April 2017 14:21
by markcame
Hello,
I've tried the plugin with my Sony TV but I've find some problems,
- The first regarding the authorization mode, I'm not able to use the PSK. My TV normally does not have the menu to configure this settings, so i've put th TV in hotel mode and then enabled the PSK ad described, unfortunately I'm not able to control the tv with the plugin using this method.
using the old authorization mode with the cookie, the plugin is able to interact with the TV.
- The second problem is the volume bar, the volume is retrived correctly the mute function is ok but if i want to increase or decrease the volume the settings does not sended to the tv.
Someone have any ideas ?
Re: Python plugin: Sony Bravia [ready for test]
Posted: Thursday 13 April 2017 14:54
by G3rard
@markcame, yeah there is still an issue with the volume slider. Updates from the TV are correctly received, but updates from Domoticz are not working yet. I have to check this in bravia.py.
Will make a Github issue for this (feel free to make an issue on Github yourself btw
).
The cookie method is working then? That is good news.
What is your TV model? Then I can add that to the readme on Github.
Python plugin: Sony Bravia [ready for test]
Posted: Thursday 13 April 2017 14:56
by G3rard
NotsniwFrancisco wrote:Hello G3rard, I'm new here and I don't have any idea about Python. But want to learn it. I will follow you, please update your post as much as you can. Thanks.
Well you don't need to have any Python knowledge to use the plugin.
Just install the Domoticz beta and follow the readme on Github and you can start using the plugin.
Re: Python plugin: Sony Bravia [ready for test]
Posted: Thursday 13 April 2017 14:57
by G3rard
DaWauZ wrote:I have a sony kdl40525exbaep from 2012, dont know if it works with, but if you think so, I can test for you.
Not sure if it will work, as I read somewhere you need a Bravia >= 2013, but just give it a try.
Re: Python plugin: Sony Bravia [ready for test]
Posted: Thursday 13 April 2017 23:44
by markcame
@G3rard, the tv model is KDL- 42W805A at the moment the only way to control is using cookie, i will create the cookie using a script founded on github and then i put it in your script, i don't know if exist another way to do this.
at the moment i'm testing the plugin it works well in this way, i've noticed that probably needs to sync the input status with the retrived one from the tv , especially if the command is issued from a normal remote control.
the right imput isd displayed but on the input selector not...
thanks for the development of the plugin.
Re: Python plugin: Sony Bravia [ready for test]
Posted: Friday 14 April 2017 0:20
by Monki77
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)
Code: Select all
commandArray = {}
if(devicechanged['Sony TV']) then
url = 'http://MYIPADDRESS/sony/system'
headername = 'X-Auth-PSK'
headervalue = 'sony'
jsonbodypoweroff = '{\\"id\\":2,\\"method\\":\\"setPowerStatus\\",\\"version\\":\\"1.0\\",\\"params\\":[{ \\"status\\" : false}]}'
jsonbodypoweron = '{\\"id\\":2,\\"method\\":\\"setPowerStatus\\",\\"version\\":\\"1.0\\",\\"params\\":[{ \\"status\\" : true}]}'
if (devicechanged['Sony TV'] == 'On') then
if(uservariables['TVOnlyStatusUpdate'] == 1) then
print('TV status update received (ON), resetting user variable.')
commandArray['Variable:TVOnlyStatusUpdate'] = '0'
else
runcommand = 'curl -v -H \"Content-Type:application/json\" -H \"' .. headername .. ':' .. headervalue .. '\" -d \"' .. jsonbodypoweron .. '\" ' .. url .. ''
response = os.execute(runcommand)
if response then
print('TV wakes up')
end
end
end
if (devicechanged['Sony TV'] == 'Off') then
if(uservariables['TVOnlyStatusUpdate'] == 1) then
print('TV status update received (OFF), resetting user variable.')
commandArray['Variable:TVOnlyStatusUpdate'] = '0'
else
runcommand = 'curl -v -H \"Content-Type:application/json\" -H \"' .. headername .. ':' .. headervalue .. '\" -d \"' .. jsonbodypoweroff .. '\" ' .. url .. ''
response = os.execute(runcommand)
if response then
print('TV goes sleepy sleep')
else
print('TV not in the mood for sleepy sleep')
end
end
end
end
return commandArray
Re: Python plugin: Sony Bravia [ready for test]
Posted: Friday 14 April 2017 0:45
by G3rard
markcame wrote:@G3rard, the tv model is KDL- 42W805A at the moment the only way to control is using cookie, i will create the cookie using a script founded on github and then i put it in your script, i don't know if exist another way to do this.
at the moment i'm testing the plugin it works well in this way, i've noticed that probably needs to sync the input status with the retrived one from the tv , especially if the command is issued from a normal remote control.
the right imput isd displayed but on the input selector not...
thanks for the development of the plugin.
Can you share the script for the cookie? Because the bravia.py I am using was originally created with the use of a cookie. I changed it to a PSK because that works easier and I had some troubles with the cookie.
Maybe I can add a selector in the hardware page where you can choose between the cookie and the PSK.
The inputs are currently hardcoded (HDMI 1/MHL, HDMI 2, HDMI 3, HDMI 4). So if these are different on your TV, then the selector switch with the sources will indeed not show the correct state. The sources can be retrived from the TV with the use of bravia.py.
Can you add the following code to localtest.py (somewhere around line 70) and share the print result (preferably as a comment on
https://github.com/gerard33/sony-bravia/issues/5)?
Code: Select all
test2 = x.get_source('extInput:hdmi')
print('Source list:', test2)
Then I can check if I can change to code to use this data.
Re: Python plugin: Sony Bravia [ready for test]
Posted: Friday 14 April 2017 0:55
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)
Nice to see it's working on Sony Bravia with Android as well
I used the script of StefanPuntNL as well
* Volume slider is indeed not working yet. Made a Github issue for that (
https://github.com/gerard33/sony-bravia/issues/1).
* The TV remote is indeed not working. Not sure if that is supported by the Python plugin (yet).
* The script indeed uses WOL to turn the TV on. But there is also another way in bravia.py to turn the tv on. I commented that part out because it gave errors for my TV. But can you add the following code as the bottom of localtest.py and see if that works?
Code: Select all
x.send_req_ircc(x.get_command_code('TvPower'))
If that doesn't work I will have a look at your code to see if that can be used as well.
Re: Python plugin: Sony Bravia [ready for test]
Posted: Friday 14 April 2017 1:40
by Monki77
I pasted "x.send_req_ircc(x.get_command_code('TvPower'))" at the end of localtest.py (just above the "else: Print" part) and restarted the domoticz.sh service just incase, but it didn't work
I hope i did it right haha.
Python plugin: Sony Bravia [ready for test]
Posted: Friday 14 April 2017 8:07
by G3rard
The code must be added as the last line and with the same indent as the print line.
Also enter the IP and PSK in the top of the file (replacing the current values).
No need to restart anything, just SSH to the bravia plugin directory and execute
That will print some results and after this change tries to start the TV (when it's not switched on).
Re: Python plugin: Sony Bravia [ready for test]
Posted: Friday 14 April 2017 14:42
by markcame
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.
Re: Python plugin: Sony Bravia [ready for test]
Posted: Sunday 16 April 2017 0:58
by G3rard
A new version of the plugin is available on
https://github.com/gerard33/sony-bravia.
- Fixed volume control from Domoticz
- Fixed source name issue (regarding /MHL and the HDMI source)
- Added start time and end time for program playing
- Show status 'TV starting' in device when TV is switched on using Domoticz (it takes some time for the TV to boot and in the meanwhile no TV information is being loaded)
- Direct response in the Domoticz switches when TV is switched off using Domoticz
- Some cleanup
Re: Python plugin: Sony Bravia [ready for test]
Posted: Sunday 16 April 2017 1:09
by G3rard
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.
Re: Python plugin: Sony Bravia [work in progress]
Posted: Tuesday 18 April 2017 23:36
by maomanna
G3rard wrote:Making some good progress with the plugin. Expect to release a first version soon which can be used for testing.
Let me know if you are interested to test the plugin.
It will work on Sony Bravia models 2013 and newer. Not tested on Sony Bravia with Android yet!
sony_tv_plugin.png
I fixed my version of domoticz and added your plugin.
I see all the 3 devices. How can i adjust volume? it can only be muted
Re: Python plugin: Sony Bravia [ready for test]
Posted: Tuesday 18 April 2017 23:39
by G3rard
Have you set the volume bar option to true in the hardware page?