Open alexmohr opened 4 years ago
Could you post your device type? It's strange that you have issues like that because the device gets the command as a string and not via an ID which could be missmatched.
Have you tried the TV & Sideview App from Sony and if yes is it working?
My device is a Home Cinema BDV-N7200W
Let me check if that application works for me El 8 oct 2019 10:11 +0200, Alex , escribió:
Could you post your device type? It's strange that you have issues like that because the device gets the command as a string and not via an ID which could be missmatched. Have you tried the TV & Sideview App from Sony and if yes is it working? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
The application works in the same way.
I can control remotely but when I connect, it goes to HOME and not to the last input select, so I need to select the proper source/input (TV in my case to use Digital input/Toslink). It is not a problem, one additional step in the sequence. What I am not sure if it is currently implemented on sony media player. El 8 oct 2019 12:22 +0200, Richard Peña patrul@gmail.com, escribió:
My device is a Home Cinema BDV-N7200W
Let me check if that application works for me El 8 oct 2019 10:11 +0200, Alex , escribió:
Could you post your device type? It's strange that you have issues like that because the device gets the command as a string and not via an ID which could be missmatched. Have you tried the TV & Sideview App from Sony and if yes is it working? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
If the TV & SideView app shows the same wrong behavior than the issue is in the firmware of your device. Make sure you've installed the latest firmware. You could solve this easily via a home assistant script which will be triggered when the state of the devices changes.
I have just used the mobile app to select “Software Update” on TV screen but it reports the last version it is installed.
I could try to program this sequence, but how could I change the source from Home Assistant? It is implemented on sony media player? I cannot see corresponding buttons El 8 oct 2019 13:39 +0200, Alex notifications@github.com, escribió:
If the TV & SideView app shows the same wrong behavior than the issue is in the firmware of your device. Make sure you've installed the latest firmware. You could solve this easily via a home assistant script which will be triggered when the state of the devices changes. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
No you are right this functionality is currently not implemented. I do not have a device which supports selecting sources. I can implement this feature but I would need some XML files from your device to make sure the implementation is working and to write tests against that.
To provide the file take a look at https://gist.github.com/kalleth/e10e8f3b8b7cb1bac21463b0073a65fb
I'd need the complete response for the method getCurrentExternalInputsStatus
because this feature is neither implemented in the home assistant component nor in the api lib.
It would be great.
Please, let me know how can I help. I have very basic knowledge of development, I do not remember any language but I studied it and started with Basic, and teached about HTML so many years ago. El 8 oct 2019 13:57 +0200, Alex notifications@github.com, escribió:
No you are right this functionality is currently not implemented. I do not have a device which supports selecting sources. I can implement this feature but I would need some XML files from your device to make sure the implementation is working and to write tests against that. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
Please let me know if the linked gist above does not provide you enough information to acquire the files.
Sure, I will do all my best
There is a problem:
curl: (7) Failed to connect to 192.168.1.31 port 80: Conexión rehusada
I guess it is the same cause giving these error in my logs, showed before
2019-10-08 13:13:19 ERROR (SyncWorker_11) [sonyapilib.device] HTTPError: 403 Client Error: Forbidden for url: http://192.168.1.31:50002/getRemoteCommandList
2019-10-08 13:13:19 ERROR (SyncWorker_11) [custom_components.sony.media_player] 9830
2019-10-08 13:13:19 ERROR (SyncWorker_11) [custom_components.sony.media_player] Amplificador
Is there any way to reset my connection? The Home Cinema is not giving me any new PIN, and I cannot see as authorized remote device on the configuration list. Very strange, because I can use it (power on/off, volume up/down, mute)
curl: (7) Failed to connect to 192.168.1.31 port 80: Conexión rehusada
is due to using the wrong port. There is no service listening on port 80.
Try a curl on http://192.168.1.31:52323/dmr.xml
and post the output here. I'll guide you through the rest of the process.
The sony api is a bit wacky from time to time, espescially when trying random services. A restart of the device often helps.
To access things via curl it is necessary to attach the correct headers to the device or a 403 is raised. Look for \"headers\": {\"Authorization\": \"Basic XXXXX=\", \
in sony.conf
file to get the authorization for curl.
Some services do not require authentication these depend on the model of the device. As you are not seeing the device as paired something went wrong there. Altough it is strange that most services seem to work. You can reset the home assistant configuration by deleting sony.conf
in the home assistant configuration folder, after that the device can be paired again.
curl http://192.168.1.31:52323/dmr.xml
<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0" xmlns:pnpx="http://schemas.microsoft.com/windows/pnpx/2005/11" xmlns:df="http://schemas.microsoft.com/windows/2008/09/devicefoundation">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<device>
<deviceType>urn:schemas-upnp-org:device:MediaRenderer:1</deviceType>
<friendlyName>BDV-N7200W</friendlyName>
<manufacturer>Sony Corporation</manufacturer>
<manufacturerURL>http://www.sony.net/</manufacturerURL>
<modelName>BDV-N7200W</modelName>
<modelNumber>BDV-2014</modelNumber>
<UDN>uuid:00000000-0000-1010-8000-104fa844bd2e</UDN>
<dlna:X_DLNADOC xmlns:dlna="urn:schemas-dlna-org:device-1-0">DMR-1.50</dlna:X_DLNADOC>
<dlna:X_DLNACAP xmlns:dlna="urn:schemas-dlna-org:device-1-0">playcontainer-1-0</dlna:X_DLNACAP>
<iconList>
<icon>
<mimetype>image/jpeg</mimetype>
<width>120</width>
<height>120</height>
<depth>24</depth>
<url>/bdv_nv_device_icon_large.jpg</url>
</icon>
<icon>
<mimetype>image/png</mimetype>
<width>120</width>
<height>120</height>
<depth>24</depth>
<url>/bdv_nv_device_icon_large.png</url>
</icon>
<icon>
<mimetype>image/jpeg</mimetype>
<width>48</width>
<height>48</height>
<depth>24</depth>
<url>/bdv_nv_device_icon_small.jpg</url>
</icon>
<icon>
<mimetype>image/png</mimetype>
<width>48</width>
<height>48</height>
<depth>24</depth>
<url>/bdv_nv_device_icon_small.png</url>
</icon>
</iconList>
<serviceList>
<service>
<serviceType>urn:schemas-upnp-org:service:RenderingControl:1</serviceType>
<serviceId>urn:upnp-org:serviceId:RenderingControl</serviceId>
<SCPDURL>/RenderingControlBdvSCPD.xml</SCPDURL>
<controlURL>/upnp/control/RenderingControl</controlURL>
<eventSubURL>/upnp/event/RenderingControl</eventSubURL>
</service>
<service>
<serviceType>urn:schemas-upnp-org:service:ConnectionManager:1</serviceType>
<serviceId>urn:upnp-org:serviceId:ConnectionManager</serviceId>
<SCPDURL>/ConnectionManagerSCPD.xml</SCPDURL>
<controlURL>/upnp/control/ConnectionManager</controlURL>
<eventSubURL>/upnp/event/ConnectionManager</eventSubURL>
</service>
<service>
<serviceType>urn:schemas-upnp-org:service:AVTransport:1</serviceType>
<serviceId>urn:upnp-org:serviceId:AVTransport</serviceId>
<SCPDURL>/AVTransportSCPD.xml</SCPDURL>
<controlURL>/upnp/control/AVTransport</controlURL>
<eventSubURL>/upnp/event/AVTransport</eventSubURL>
</service>
</serviceList>
<av:X_StandardDMR xmlns:av="urn:schemas-sony-com:av">1.1</av:X_StandardDMR>
<microsoft:magicPacketWakeSupported xmlns:microsoft="urn:schemas-microsoft-com:WMPNSS-1-0">
1
</microsoft:magicPacketWakeSupported>
<pnpx:X_compatibleId>MS_DigitalMediaDeviceClass_DMR_V001</pnpx:X_compatibleId>
<pnpx:X_deviceCategory>MediaDevices</pnpx:X_deviceCategory>
<pnpx:X_hardwareId>VEN_0106&DEV_0400&REV_01</pnpx:X_hardwareId>
<df:X_deviceCategory>Multimedia.DMR</df:X_deviceCategory>
</device>
</root>
Correctly registered
some services do not require authentication these depend on the model of the device. As you are not seeing the device as paired something went wrong there. Altough it is strange that most services seem to work. You can reset the home assistant configuration by deleting
sony.conf
in the home assistant configuration folder, after that the device can be paired again.
Thanks for posting the file.
I need http://192.168.1.31:50001/Iirc.xml
and http://192.168.1.31/sony/getCurrentExternalInputsStatus
curl does not get anything from both URL
If I get in this way, the result shows error 415 Unsupported Media Type
curl -v -XPOST http://192.168.1.31:50001/Iirc.xml -d '{"method":"","params":[""],"id":1,"version":"1.0"}'
Note: Unnecessary use of -X or --request, POST is already inferred.
* Expire in 0 ms for 6 (transfer 0x11d3880)
* Trying 192.168.1.31...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x11d3880)
* Connected to 192.168.1.31 (192.168.1.31) port 50001 (#0)
> POST /Iirc.xml HTTP/1.1
> Host: 192.168.1.31:50001
> User-Agent: curl/7.64.0
> Accept: */*
> Content-Length: 50
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 50 out of 50 bytes
< HTTP/1.1 415 Unsupported Media Type
< Connection: close
< Date: Wed, 09 Oct 2019 06:59:13 GMT
< Server: Linux/2.6 UPnP/1.0 Sony-BDV/2.0
<
* Closing connection 0
And if I try to connect ofher port it opens connection but says 404 Not found
curl -v -XPOST http://192.168.1.31:50002/Iirc.xml -d '{"method":"","params":[""],"id":1,"version":"1.0"}'
Note: Unnecessary use of -X or --request, POST is already inferred.
* Expire in 0 ms for 6 (transfer 0x201a880)
* Trying 192.168.1.31...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x201a880)
* Connected to 192.168.1.31 (192.168.1.31) port 50002 (#0)
> POST /Iirc.xml HTTP/1.1
> Host: 192.168.1.31:50002
> User-Agent: curl/7.64.0
> Accept: */*
> Content-Length: 50
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 50 out of 50 bytes
< HTTP/1.1 404 Not Found
< Connection: close
< Date: Wed, 09 Oct 2019 07:00:18 GMT
< Server: Linux/2.6 Sony-BDV/2.0
<
* Closing connection 0
This should be the correct URL http://192.168.1.31:50001/Iircc.xml
(I forgot the 2nd 'c') The port 50001 is correct but you should use GET
for IRCC requests not POST
It might be necessary to authenticate against the device when access this URLs. You must send either a pre shared key which you have to configure on your device or authenticate via basic auth. The data for this can be taken from your home assistant config in the sony.conf file
When I try to connect with browser or curl to http://192.168.1.31:50001/Iircc.xml It says HTTP ERROR 404
Third time's the charm... http://192.168.1.31:50001/Ircc.xml
But please post the other XML I've requested as well the second one is actually more important.
In the sony TV & SideView app do you have a list of available sources or is it just an input button which cycles the inputs through?
curl -X GET http://192.168.1.31:50001/Ircc.xml
<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<device>
<deviceType>urn:schemas-upnp-org:device:Basic:1</deviceType>
<friendlyName>BDV-N7200W</friendlyName>
<manufacturer>Sony Corporation</manufacturer>
<manufacturerURL>http://www.sony.net/</manufacturerURL>
<modelDescription></modelDescription>
<modelName>BDV</modelName>
<modelURL></modelURL>
<UDN>uuid:00000003-0000-1010-8000-104fa844bd2e</UDN>
<iconList>
<icon>
<mimetype>image/jpeg</mimetype>
<width>120</width>
<height>120</height>
<depth>24</depth>
<url>/bdv_nv_device_icon_large.jpg</url>
</icon>
<icon>
<mimetype>image/png</mimetype>
<width>120</width>
<height>120</height>
<depth>24</depth>
<url>/bdv_nv_device_icon_large.png</url>
</icon>
<icon>
<mimetype>image/jpeg</mimetype>
<width>48</width>
<height>48</height>
<depth>24</depth>
<url>/bdv_nv_device_icon_small.jpg</url>
</icon>
<icon>
<mimetype>image/png</mimetype>
<width>48</width>
<height>48</height>
<depth>24</depth>
<url>/bdv_nv_device_icon_small.png</url>
</icon>
</iconList>
<serviceList>
<service>
<serviceType>urn:schemas-sony-com:service:IRCC:1</serviceType>
<serviceId>urn:schemas-sony-com:serviceId:IRCC</serviceId>
<SCPDURL>/IRCCSCPD.xml</SCPDURL>
<controlURL>/upnp/control/IRCC</controlURL>
<eventSubURL></eventSubURL>
</service>
</serviceList>
<presentationURL></presentationURL>
<av:X_IRCC_DeviceInfo xmlns:av="urn:schemas-sony-com:av">
<av:X_IRCC_Version>1.0</av:X_IRCC_Version>
<av:X_IRCC_CategoryList>
<av:X_IRCC_Category>
<av:X_CategoryInfo>AAIAAAAF</av:X_CategoryInfo>
</av:X_IRCC_Category>
<av:X_IRCC_Category>
<av:X_CategoryInfo>AAIAAADQ</av:X_CategoryInfo>
</av:X_IRCC_Category>
<av:X_IRCC_Category>
<av:X_CategoryInfo>AAMAAAIQ</av:X_CategoryInfo>
</av:X_IRCC_Category>
<av:X_IRCC_Category>
<av:X_CategoryInfo>AAMAAAYQ</av:X_CategoryInfo>
</av:X_IRCC_Category>
<av:X_IRCC_Category>
<av:X_CategoryInfo>AAMAAA4Q</av:X_CategoryInfo>
</av:X_IRCC_Category>
</av:X_IRCC_CategoryList>
</av:X_IRCC_DeviceInfo>
<av:X_UNR_DeviceInfo xmlns:av="urn:schemas-sony-com:av">
<av:X_UNR_Version>1.3</av:X_UNR_Version>
<av:X_CERS_ActionList_URL>http://192.168.1.31:50002/actionList</av:X_CERS_ActionList_URL>
</av:X_UNR_DeviceInfo>
<av:X_RDIS_DeviceInfo xmlns:av="urn:schemas-sony-com:av">
<av:X_RDIS_Version>1.0</av:X_RDIS_Version>
<av:X_RDIS_SESSION_CONTROL>false</av:X_RDIS_SESSION_CONTROL>
<av:X_RDIS_ENTRY_PORT>50004</av:X_RDIS_ENTRY_PORT>
</av:X_RDIS_DeviceInfo>
</device>
</root>
curl -X GET http://192.168.1.31/sony/getCurrentExternalInputsStatus
curl: (7) Failed to connect to 192.168.1.31 port 80: Conexión rehusada
No answer with 50001 or 50002 port
More info
curl -X GET http://192.168.1.31:50002/actionList
<?xml version="1.0" encoding="UTF-8"?>
<actionList>
<action name="register" mode="3" url="http://192.168.1.31:50002/register"/>
<action name="getText" url="http://192.168.1.31:50002/getText"/>
<action name="sendText" url="http://192.168.1.31:50002/sendText"/>
<action name="getContentInformation" url="http://192.168.1.31:50002/getContentInformation"/>
<action name="getSystemInformation" url="http://192.168.1.31:50002/getSystemInformation"/>
<action name="getRemoteCommandList" url="http://192.168.1.31:50002/getRemoteCommandList"/>
<action name="getStatus" url="http://192.168.1.31:50002/getStatus"/>
<action name="getHistoryList" url="http://192.168.1.31:50002/getHistoryList"/>
<action name="getContentUrl" url="http://192.168.1.31:50002/getContentUrl"/>
<action name="sendContentUrl" url="http://192.168.1.31:50002/sendContentUrl"/>
</actionList>
Thanks. In the sony TV & SideView app do you have a list of available sources or is it just an input button which cycles the inputs through?
I'd like to see the output of http://192.168.1.31:50002/getRemoteCommandList
For this URL you need to provide authentication data.
I just checked again and the other command I've requested before is only available on newer devices. I have to do some digging to find out where the inputs are listed. I'm not quite sure if home assistant supports cycling through inputs without a list.
That's now nearly all data I should need :)
In the sony app, I can see a list of available inputs: HDMI 1, HDMI2, TV, Bluetooth and AUDIO
For the command, no output.
My device has no option to setup PSK. Anyway, I tried different options according to sony.conf (\"pin\": \"5125\", \"psk\": null,) and the no output. I am sending all curl request from authorized device (terminal from RPI4 where Home Assistant is running)
The device itself is not authorized. The sony.conf contains the authorization. This header has to be send via curl along with the request. I'll send you a detailed how to later today because I have to try it out with my device.
Look for \"headers\": {\"Authorization\": \"Basic XXXXX=\", \ in sony.conf file to get the authorization for curl.
I will keep trying ...
curl -i -H 'Accept:application/json' -H 'Authorization:Basic OjUxMjU=' -X GET http://192.168.1.31:50002/getRemoteCommandList
HTTP/1.1 403 Forbidden
Connection: close
Date: Wed, 09 Oct 2019 08:59:49 GMT
Server: Linux/2.6 Sony-BDV/2.0
Don't worry I'll attach a detailed explanation later today :)
curl -i -H 'Authorization:Basic OjUxMjU=' -H 'X-CERS-DEVICE-ID:Bluray' http://192.168.1.31:50002/getSystemInformation
curl -i -H 'Authorization:Basic OjUxMjU=' -H 'X-CERS-DEVICE-ID:Bluray' http://192.168.1.31:50002/getRemoteCommandList
curl -i -H 'Authorization:Basic OjUxMjU=' -H 'X-CERS-DEVICE-ID:Bluray' http://192.168.1.31:50002/getContentInformation
curl -i -H 'Authorization:Basic OjUxMjU=' -H 'X-CERS-DEVICE-ID:Bluray' http://192.168.1.31:50001/IRCCSCPD.xml
I hope all commands are spelled correctly. I must guess a little because I'm not sure which XML will contain the relevant information.
X-CERS-DEVICE-ID:Bluray
Must be replaced with the id you can find in your sony.conf
Many thanks!!! I hope this output makes sense
$ curl -i -H 'Authorization:Basic OjUxMjU=' -H 'X-CERS-DEVICE-ID:Amplificador' http://192.168.1.31:50002/g
etSystemInformation
HTTP/1.1 200 OK
Connection: close
Cache-Control: no-cache
Pragma: no-cache
Transfer-Encoding: chunked
Content-Type: text/xml
Date: Wed, 09 Oct 2019 20:57:47 GMT
Server: Linux/2.6 Sony-BDV/2.0
<?xml version="1.0" encoding="UTF-8"?>
<systemInformation>
<name>BDTheatreSystem</name>
<generation>2014</generation>
<remoteType>RM-ADP089</remoteType>
<remoteType>RM-ADP090</remoteType>
<remoteType>RM-ADP091</remoteType>
<remoteType>RM-ADP092</remoteType>
<remoteType>RM-ADP093</remoteType>
<remoteType bundled="true">RM-ADP093W</remoteType>
<remoteType>RM-ADP095</remoteType>
<remoteType>RM-ADP095W</remoteType>
<remoteType>RM-ADP096</remoteType>
<remoteType>RM-ADP097W</remoteType>
<remoteType>RM-ADP099W</remoteType>
<remoteType>RM-ADP101</remoteType>
<remoteType>RM-ADP072</remoteType>
<remoteType>RM-ADP073</remoteType>
<remoteType>RM-ADP074</remoteType>
<remoteType>RM-ADP075</remoteType>
<remoteType>RM-ADP076</remoteType>
<remoteType>RM-ADP077</remoteType>
<actionHeader name="CERS-DEVICE-ID"/>
<supportContentsClass>
<class>video</class>
<class>music</class>
</supportContentsClass>
<supportSource>
<source>BD</source>
<source>DVD</source>
<source>CD</source>
<source>Net</source>
</supportSource>
<supportFunction>
<function name="Notification"/>
<function name="WOL">
<functionItem field="MAC" value="10-4f-a8-44-bd-2e"/>
</function>
</supportFunction>
</systemInformation>
$ curl -i -H 'Authorization:Basic OjUxMjU=' -H 'X-CERS-DEVICE-ID:Amplificador' http://192.168.1.31:50002/g
etRemoteCommandList
HTTP/1.1 200 OK
Connection: close
Cache-Control: no-cache
Pragma: no-cache
Transfer-Encoding: chunked
Content-Type: text/xml
Date: Wed, 09 Oct 2019 20:58:46 GMT
Server: Linux/2.6 Sony-BDV/2.0
<?xml version="1.0" encoding="UTF-8"?>
<remoteCommandList>
<command name="Confirm" type="ircc" value="AAAAAwAAAhAAAAB8Aw==" />
<command name="Up" type="ircc" value="AAAAAwAAAhAAAAB4Aw==" />
<command name="Down" type="ircc" value="AAAAAwAAAhAAAAB5Aw==" />
<command name="Right" type="ircc" value="AAAAAwAAAhAAAAB7Aw==" />
<command name="Left" type="ircc" value="AAAAAwAAAhAAAAB6Aw==" />
<command name="Home" type="ircc" value="AAAAAgAAANAAAAAHAw==" />
<command name="Options" type="ircc" value="AAAAAwAAAhAAAABzAw==" />
<command name="Return" type="ircc" value="AAAAAwAAAhAAAAB9Aw==" />
<command name="Num1" type="ircc" value="AAAAAwAAAhAAAAAAAw==" />
<command name="Num2" type="ircc" value="AAAAAwAAAhAAAAABAw==" />
<command name="Num3" type="ircc" value="AAAAAwAAAhAAAAACAw==" />
<command name="Num4" type="ircc" value="AAAAAwAAAhAAAAADAw==" />
<command name="Num5" type="ircc" value="AAAAAwAAAhAAAAAEAw==" />
<command name="Num6" type="ircc" value="AAAAAwAAAhAAAAAFAw==" />
<command name="Num7" type="ircc" value="AAAAAwAAAhAAAAAGAw==" />
<command name="Num8" type="ircc" value="AAAAAwAAAhAAAAAHAw==" />
<command name="Num9" type="ircc" value="AAAAAwAAAhAAAAAIAw==" />
<command name="Num0" type="ircc" value="AAAAAwAAAhAAAAAJAw==" />
<command name="Power" type="ircc" value="AAAAAgAAAFAAAAAVAw==" />
<command name="Display" type="ircc" value="AAAAAwAAAhAAAAAYAw==" />
<command name="VolumeUp" type="ircc" value="AAAAAgAAAFAAAAASAw==" />
<command name="VolumeDown" type="ircc" value="AAAAAgAAAFAAAAATAw==" />
<command name="Mute" type="ircc" value="AAAAAgAAAFAAAAAUAw==" />
<command name="Audio" type="ircc" value="AAAAAwAAAhAAAAASAw==" />
<command name="SubTitle" type="ircc" value="AAAAAwAAAhAAAAARAw==" />
<command name="Angle" type="ircc" value="AAAAAwAAAhAAAAATAw==" />
<command name="Favorites" type="ircc" value="AAAAAwAABhAAAABLAw==" />
<command name="Yellow" type="ircc" value="AAAAAwAABhAAAAAHAw==" />
<command name="Blue" type="ircc" value="AAAAAwAABhAAAAAEAw==" />
<command name="Red" type="ircc" value="AAAAAwAABhAAAAAFAw==" />
<command name="Green" type="ircc" value="AAAAAwAABhAAAAAGAw==" />
<command name="Play" type="ircc" value="AAAAAgAAANAAAAACAw==" />
<command name="Stop" type="ircc" value="AAAAAgAAANAAAAAAAw==" />
<command name="Pause" type="ircc" value="AAAAAgAAANAAAAABAw==" />
<command name="Rewind" type="ircc" value="AAAAAwAAAhAAAAAzAw==" />
<command name="Forward" type="ircc" value="AAAAAwAAAhAAAAA0Aw==" />
<command name="Prev" type="ircc" value="AAAAAwAAAhAAAAAwAw==" />
<command name="Next" type="ircc" value="AAAAAwAAAhAAAAAxAw==" />
<command name="Replay" type="ircc" value="AAAAAwAAAhAAAAAhAw==" />
<command name="Advance" type="ircc" value="AAAAAwAAAhAAAAAgAw==" />
<command name="TopMenu" type="ircc" value="AAAAAwAAAhAAAAAZAw==" />
<command name="PopUpMenu" type="ircc" value="AAAAAwAAAhAAAAAaAw==" />
<command name="Eject" type="ircc" value="AAAAAwAAAhAAAAA8Aw==" />
<command name="BDV:SoundOutput" type="ircc" value="AAAAAwAABhAAAABFAw==" />
<command name="Dimmer" type="ircc" value="AAAAAgAAAFAAAABNAw==" />
<command name="BDV:Sleep" type="ircc" value="AAAAAgAAAFAAAABgAw==" />
<command name="BDV:Function" type="ircc" value="AAAAAgAAANAAAABpAw==" />
<command name="BDV:SoundMode" type="ircc" value="AAAAAgAAANAAAABuAw==" />
<command name="BDV:SoundModeDown" type="ircc" value="AAAAAgAAANAAAABeAw==" />
<command name="BDV:SoundModeUp" type="ircc" value="AAAAAgAAANAAAABLAw==" />
<command name="Enter" type="ircc" value="AAAAAwAAAhAAAAAMAw==" />
<command name="SEN" type="ircc" value="AAAAAwAADhAAAABQAw==" />
<command name="Netflix" type="ircc" value="AAAAAwAADhAAAABRAw==" />
<command name="Mode3D" type="ircc" value="AAAAAwAABhAAAABMAw==" />
<command name="BDV:KeyControl-" type="ircc" value="AAAAAgAAANAAAAAXAw==" />
<command name="BDV:KeyControl+" type="ircc" value="AAAAAgAAANAAAAAWAw==" />
<command name="BDV:Echo" type="ircc" value="AAAAAgAAANAAAAAUAw==" />
<command name="BDV:MicVol+" type="ircc" value="AAAAAgAAANAAAAASAw==" />
<command name="BDV:MicVol-" type="ircc" value="AAAAAgAAANAAAAATAw==" />
<command name="BDV:Bluetooth" type="ircc" value="AAAAAwAABhAAAABxAw==" />
<command name="BDV:MusicEQ" type="ircc" value="AAAAAgAAANAAAABJAw==" />
<command name="BDV:SpeakerIllumination" type="ircc" value="AAAAAwAABhAAAABgAw==" />
<command name="BDV:FootBall" type="ircc" value="AAAAAwAADhAAAAAXAw==" />
<command name="ZoomIn" type="url" value="http://192.168.1.31:50002/setBrowse?action=zoomIn" />
<command name="ZoomOut" type="url" value="http://192.168.1.31:50002/setBrowse?action=zoomOut" />
<command name="BrowserBack" type="url" value="http://192.168.1.31:50002/setBrowse?action=back" />
<command name="BrowserForward" type="url" value="http://192.168.1.31:50002/setBrowse?action=forward" />
<command name="BrowserBookmarkList" type="url" value="http://192.168.1.31:50002/getBrowse?action=bookmarkList" />
</remoteCommandList>
$ curl -i -H 'Authorization:Basic OjUxMjU=' -H 'X-CERS-DEVICE-ID:Amplificador' http://192.168.1.31:50002/getContentInformation
HTTP/1.1 500 Internal Server Error
Connection: close
X-CERS-STATUS-CODE: DI01 NoDisc
Date: Wed, 09 Oct 2019 20:59:48 GMT
Server: Linux/2.6 Sony-BDV/2.0
$ curl -i -H 'Authorization:Basic OjUxMjU=' -H 'X-CERS-DEVICE-ID:Amplificador' http://192.168.1.31:50001/I
RCCSCPD.xml
HTTP/1.1 200 OK
Accept-Ranges: none
Content-Length: 1760
Content-Type: text/xml; charset="utf-8"
Last-Modified: Tue, 11 Dec 2018 02:02:05 GMT
Connection: close
Date: Wed, 09 Oct 2019 21:00:21 GMT
Server: Linux/2.6 UPnP/1.0 Sony-BDV/2.0
<?xml version="1.0"?>
<scpd xmlns="urn:schemas-upnp-org:service-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<actionList>
<action>
<name>X_SendIRCC</name>
<argumentList>
<argument>
<name>IRCCCode</name>
<direction>in</direction>
<relatedStateVariable>X_A_ARG_TYPE_IRCCCode</relatedStateVariable>
</argument>
</argumentList>
</action>
<action>
<name>X_GetStatus</name>
<argumentList>
<argument>
<name>CategoryCode</name>
<direction>in</direction>
<relatedStateVariable>X_A_ARG_TYPE_Category</relatedStateVariable>
</argument>
<argument>
<name>CurrentStatus</name>
<direction>out</direction>
<relatedStateVariable>X_A_ARG_TYPE_CurrentStatus</relatedStateVariable>
</argument>
<argument>
<name>CurrentCommandInfo</name>
<direction>out</direction>
<relatedStateVariable>X_A_ARG_TYPE_CurrentCommandInfo</relatedStateVariable>
</argument>
</argumentList>
</action>
</actionList>
<serviceStateTable>
<stateVariable sendEvents="no">
<name>X_A_ARG_TYPE_IRCCCode</name>
<dataType>string</dataType>
</stateVariable>
<stateVariable sendEvents="no">
<name>X_A_ARG_TYPE_Category</name>
<dataType>string</dataType>
</stateVariable>
<stateVariable sendEvents="no">
<name>X_A_ARG_TYPE_CurrentStatus</name>
<dataType>string</dataType>
</stateVariable>
<stateVariable sendEvents="no">
<name>X_A_ARG_TYPE_CurrentCommandInfo</name>
<dataType>string</dataType>
</stateVariable>
</serviceStateTable>
</scpd>
Yes thank you for providing the files. I'm still not sure how to read the sources list. Probably it is hidden away in one of these soap services. It might take some time for me to come up with something.
Thanks in advance. Please let me know if there is anything I can do
I cannot find a way to list the sources with the api version your device has. I'd need a wireshark trace between the app and the device to find out which calls are. Other implementations for the API like this use the API located at http://192.168.1.31/sony which you've reported to be non working on your device. You could give the linked repository a try to communicate with your device and list the source. Maybe I am missing something.
I am trying to get that implementation working but I cannot, due to my lack knowledge on programming. I'm if I continue googling I may get it work, but there is a risk to broke something with so many tries and errors.
I downloaded the other API, installed with sudo python setup.py install
, but after that I´m unable to configure, so I´m just blocked out and I prefer to ask you.
from SonyAPI import SonyAPI
device = SonyAPI(ip_address='192.168.1.31', pin=XXXX)
for s in device.source_list():
print(s)
The script above should do it.
If I copy the text to a sh script and execute it shows the error:
from: can't read /var/mail/SonyAPI
./SonyAPI: línea 5: error sintáctico cerca del elemento inesperado `('
./SonyAPI: línea 5: `device = SonyAPI(ip_address='192.168.1.31', pin=5125)'
Run it with python 3 and not as shell scripts. Put it next to the SonyApi folder from the linked repository
Something went wrong. It seems related to connection and closed port
pi@Atico-HA:~/SonyAPI-master/SonyAPI $ python sonyapi.py
Traceback (most recent call last):
File "sonyapi.py", line 3, in <module>
device = SonyAPI(ip_address='192.168.1.31', pin=5125)
File "build/bdist.linux-armv7l/egg/SonyAPI/__init__.py", line 184, in __init__
self.pin = pin
File "build/bdist.linux-armv7l/egg/SonyAPI/__init__.py", line 378, in pin
'Unknown Request Error: ' + traceback.format_exc()
SonyAPI.RegisterError: Unknown Request Error: Traceback (most recent call last):
File "build/bdist.linux-armv7l/egg/SonyAPI/__init__.py", line 322, in pin
headers=headers
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 116, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 516, in send
raise ConnectionError(e, request=request)
ConnectionError: HTTPConnectionPool(host='192.168.1.31', port=80): Max retries exceeded with url: /sony/accessControl (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xb613e190>: Failed to establish a new connection: [Errno 111] Connection refused',))
That's what I expected.
The app somehow uses another channel to get the available inputs. Your device does not support the standard way all libraries out there implement.
Without a wireshark trace (or similar) of the communication between your device and the app I' unable help you. Sorry.
I am trying to get a wireshark trace but my network is switched and the router is not managed so I cannot mirror the port where Sony device is connected
I am still thinking on a shortcut
Finally I got it
After selection a source, this is the secuence trace of POST and Responses
I guess the key is in this URI:
<CurrentURI>
local://192.168.1.31:60151/I_14_02_0_-1_00_07_7_23_0_0
</CurrentURI>
No. Time Source Destination Protocol Length Info
486 18:59:04,901887552 192.168.1.166 192.168.1.31 HTTP/XML 316 POST /upnp/control/AVTransport HTTP/1.1
Frame 486: 316 bytes on wire (2528 bits), 316 bytes captured (2528 bits) on interface 0
Ethernet II, Src: Apple_ec:70:0d (40:9c:28:ec:70:0d), Dst: Sony_44:bd:2e (10:4f:a8:44:bd:2e)
Internet Protocol Version 4, Src: 192.168.1.166, Dst: 192.168.1.31
Transmission Control Protocol, Src Port: 55600, Dst Port: 52323, Seq: 240, Ack: 1, Len: 250
[2 Reassembled TCP Segments (489 bytes): #485(239), #486(250)]
Hypertext Transfer Protocol
POST /upnp/control/AVTransport HTTP/1.1\r\n
[Expert Info (Chat/Sequence): POST /upnp/control/AVTransport HTTP/1.1\r\n]
[POST /upnp/control/AVTransport HTTP/1.1\r\n]
[Severity level: Chat]
[Group: Sequence]
Request Method: POST
Request URI: /upnp/control/AVTransport
Request Version: HTTP/1.1
Host: 192.168.1.31:52323\r\n
User-Agent: DLNADOC/1.50\r\n
Content-Type: text/xml; charset="utf-8"\r\n
SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#Stop"\r\n
Content-Length: 250\r\n
Connection: close\r\n
\r\n
[Full request URI: http://192.168.1.31:52323/upnp/control/AVTransport]
[HTTP request 1/1]
[Response in frame: 488]
File Data: 250 bytes
eXtensible Markup Language
<s:Envelope
s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<u:Stop
xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
<InstanceID>
0
</InstanceID>
</u:Stop>
</s:Body>
</s:Envelope>
No. Time Source Destination Protocol Length Info
488 18:59:05,234115438 192.168.1.31 192.168.1.166 HTTP/XML 327 HTTP/1.1 200 OK
Frame 488: 327 bytes on wire (2616 bits), 327 bytes captured (2616 bits) on interface 0
Ethernet II, Src: Sony_44:bd:2e (10:4f:a8:44:bd:2e), Dst: Apple_ec:70:0d (40:9c:28:ec:70:0d)
Internet Protocol Version 4, Src: 192.168.1.31, Dst: 192.168.1.166
Transmission Control Protocol, Src Port: 52323, Dst Port: 55600, Seq: 324, Ack: 490, Len: 261
[2 Reassembled TCP Segments (584 bytes): #487(323), #488(261)]
Hypertext Transfer Protocol
HTTP/1.1 200 OK\r\n
[Expert Info (Chat/Sequence): HTTP/1.1 200 OK\r\n]
[HTTP/1.1 200 OK\r\n]
[Severity level: Chat]
[Group: Sequence]
Response Version: HTTP/1.1
Status Code: 200
[Status Code Description: OK]
Response Phrase: OK
Content-Length: 261\r\n
Content-Type: text/xml; charset="utf-8"\r\n
EXT: \r\n
Connection: close\r\n
Date: Sat, 19 Oct 2019 16:59:04 GMT\r\n
Server: Linux/2.6 UPnP/1.0 Sony-BDV/2.0\r\n
X-AV-Server-Info.sony.com: av=5.0; cn="Sony Corporation"; mn="BDV-N7200W"; mv="2.0";\r\n
X-AV-Physical-Unit-Info.sony.com: pa="BDV-N7200W";\r\n
\r\n
[HTTP response 1/1]
[Time since request: 0.332227886 seconds]
[Request in frame: 486]
[Request URI: http://192.168.1.31:52323/upnp/control/AVTransport]
File Data: 261 bytes
eXtensible Markup Language
<?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:StopResponse
xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
</u:StopResponse>
</s:Body>
</s:Envelope>
No. Time Source Destination Protocol Length Info
490 18:59:05,248202435 192.168.1.166 192.168.1.31 HTTP/XML 462 POST /upnp/control/AVTransport HTTP/1.1
Frame 490: 462 bytes on wire (3696 bits), 462 bytes captured (3696 bits) on interface 0
Ethernet II, Src: Apple_ec:70:0d (40:9c:28:ec:70:0d), Dst: Sony_44:bd:2e (10:4f:a8:44:bd:2e)
Internet Protocol Version 4, Src: 192.168.1.166, Dst: 192.168.1.31
Transmission Control Protocol, Src Port: 55601, Dst Port: 52323, Seq: 253, Ack: 1, Len: 396
[2 Reassembled TCP Segments (648 bytes): #489(252), #490(396)]
Hypertext Transfer Protocol
POST /upnp/control/AVTransport HTTP/1.1\r\n
[Expert Info (Chat/Sequence): POST /upnp/control/AVTransport HTTP/1.1\r\n]
[POST /upnp/control/AVTransport HTTP/1.1\r\n]
[Severity level: Chat]
[Group: Sequence]
Request Method: POST
Request URI: /upnp/control/AVTransport
Request Version: HTTP/1.1
Host: 192.168.1.31:52323\r\n
User-Agent: DLNADOC/1.50\r\n
Content-Type: text/xml; charset="utf-8"\r\n
SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI"\r\n
Content-Length: 396\r\n
Connection: close\r\n
\r\n
[Full request URI: http://192.168.1.31:52323/upnp/control/AVTransport]
[HTTP request 1/1]
[Response in frame: 495]
File Data: 396 bytes
eXtensible Markup Language
<s:Envelope
s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<u:SetAVTransportURI
xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
<InstanceID>
0
</InstanceID>
<CurrentURI>
local://192.168.1.31:60151/I_14_02_0_-1_00_07_7_23_0_0
</CurrentURI>
<CurrentURIMetaData>
</CurrentURIMetaData>
</u:SetAVTransportURI>
</s:Body>
</s:Envelope>
No. Time Source Destination Protocol Length Info
492 18:59:05,336434746 192.168.1.31 192.168.1.166 HTTP/XML 414 NOTIFY / HTTP/1.1
Frame 492: 414 bytes on wire (3312 bits), 414 bytes captured (3312 bits) on interface 0
Ethernet II, Src: Sony_44:bd:2e (10:4f:a8:44:bd:2e), Dst: Apple_ec:70:0d (40:9c:28:ec:70:0d)
Internet Protocol Version 4, Src: 192.168.1.31, Dst: 192.168.1.166
Transmission Control Protocol, Src Port: 39656, Dst Port: 55567, Seq: 385, Ack: 1, Len: 348
[2 Reassembled TCP Segments (732 bytes): #491(384), #492(348)]
Hypertext Transfer Protocol
NOTIFY / HTTP/1.1\r\n
[Expert Info (Chat/Sequence): NOTIFY / HTTP/1.1\r\n]
[NOTIFY / HTTP/1.1\r\n]
[Severity level: Chat]
[Group: Sequence]
Request Method: NOTIFY
Request URI: /
Request Version: HTTP/1.1
Host: 192.168.1.166:55567\r\n
Date: Sat, 19 Oct 2019 16:59:04 GMT\r\n
User-Agent: UPnP/1.0\r\n
X-AV-Physical-Unit-Info: pa="BDV-N7200W";\r\n
X-AV-Server-Info: av=5.0; cn="Sony Corporation"; mn="BDV-N7200W"; mv="2.0";\r\n
Content-Type: text/xml; charset="utf-8"\r\n
Content-Length: 348\r\n
NT: upnp:event\r\n
NTS: upnp:propchange\r\n
SID: uuid:5e2036e0-f291-11e9-8000-104fa844bd2e\r\n
SEQ: 43\r\n
\r\n
[Full request URI: http://192.168.1.166:55567/]
File Data: 348 bytes
eXtensible Markup Language
<?xml
version="1.0"
?>
<e:propertyset
xmlns:e="urn:schemas-upnp-org:event-1-0">
<e:property>
<LastChange>
<Event xmlns="urn:schemas-upnp-org:metadata-1-0/AVT/">\n <InstanceID val="0">\n <TransportState val="TRANSITIONING"/>\n </InstanceID>\n</Event>\n
</LastChange>
</e:property>
</e:propertyset>
No. Time Source Destination Protocol Length Info
493 18:59:05,341411260 192.168.1.166 192.168.1.31 HTTP 104 HTTP/1.1 200 OK
Frame 493: 104 bytes on wire (832 bits), 104 bytes captured (832 bits) on interface 0
Ethernet II, Src: Apple_ec:70:0d (40:9c:28:ec:70:0d), Dst: Sony_44:bd:2e (10:4f:a8:44:bd:2e)
Internet Protocol Version 4, Src: 192.168.1.166, Dst: 192.168.1.31
Transmission Control Protocol, Src Port: 55567, Dst Port: 39656, Seq: 1, Ack: 733, Len: 38
Hypertext Transfer Protocol
HTTP/1.1 200 OK\r\n
[Expert Info (Chat/Sequence): HTTP/1.1 200 OK\r\n]
[HTTP/1.1 200 OK\r\n]
[Severity level: Chat]
[Group: Sequence]
Response Version: HTTP/1.1
Status Code: 200
[Status Code Description: OK]
Response Phrase: OK
Content-Length: 0\r\n
\r\n
[HTTP response 1/1]
[Request URI: http://192.168.1.166:55567/]
No. Time Source Destination Protocol Length Info
495 18:59:06,397620373 192.168.1.31 192.168.1.166 HTTP/XML 353 HTTP/1.1 200 OK
Frame 495: 353 bytes on wire (2824 bits), 353 bytes captured (2824 bits) on interface 0
Ethernet II, Src: Sony_44:bd:2e (10:4f:a8:44:bd:2e), Dst: Apple_ec:70:0d (40:9c:28:ec:70:0d)
Internet Protocol Version 4, Src: 192.168.1.31, Dst: 192.168.1.166
Transmission Control Protocol, Src Port: 52323, Dst Port: 55601, Seq: 324, Ack: 649, Len: 287
[2 Reassembled TCP Segments (610 bytes): #494(323), #495(287)]
Hypertext Transfer Protocol
HTTP/1.1 200 OK\r\n
[Expert Info (Chat/Sequence): HTTP/1.1 200 OK\r\n]
[HTTP/1.1 200 OK\r\n]
[Severity level: Chat]
[Group: Sequence]
Response Version: HTTP/1.1
Status Code: 200
[Status Code Description: OK]
Response Phrase: OK
Content-Length: 287\r\n
Content-Type: text/xml; charset="utf-8"\r\n
EXT: \r\n
Connection: close\r\n
Date: Sat, 19 Oct 2019 16:59:05 GMT\r\n
Server: Linux/2.6 UPnP/1.0 Sony-BDV/2.0\r\n
X-AV-Server-Info.sony.com: av=5.0; cn="Sony Corporation"; mn="BDV-N7200W"; mv="2.0";\r\n
X-AV-Physical-Unit-Info.sony.com: pa="BDV-N7200W";\r\n
\r\n
[HTTP response 1/1]
[Time since request: 1.149417938 seconds]
[Request in frame: 490]
[Request URI: http://192.168.1.31:52323/upnp/control/AVTransport]
File Data: 287 bytes
eXtensible Markup Language
<?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:SetAVTransportURIResponse
xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
</u:SetAVTransportURIResponse>
</s:Body>
</s:Envelope>
No. Time Source Destination Protocol Length Info
497 18:59:07,435817788 192.168.1.31 192.168.1.166 HTTP/XML 456 NOTIFY / HTTP/1.1
Frame 497: 456 bytes on wire (3648 bits), 456 bytes captured (3648 bits) on interface 0
Ethernet II, Src: Sony_44:bd:2e (10:4f:a8:44:bd:2e), Dst: Apple_ec:70:0d (40:9c:28:ec:70:0d)
Internet Protocol Version 4, Src: 192.168.1.31, Dst: 192.168.1.166
Transmission Control Protocol, Src Port: 39657, Dst Port: 55567, Seq: 385, Ack: 1, Len: 390
[2 Reassembled TCP Segments (774 bytes): #496(384), #497(390)]
Hypertext Transfer Protocol
NOTIFY / HTTP/1.1\r\n
[Expert Info (Chat/Sequence): NOTIFY / HTTP/1.1\r\n]
[NOTIFY / HTTP/1.1\r\n]
[Severity level: Chat]
[Group: Sequence]
Request Method: NOTIFY
Request URI: /
Request Version: HTTP/1.1
Host: 192.168.1.166:55567\r\n
Date: Sat, 19 Oct 2019 16:59:04 GMT\r\n
User-Agent: UPnP/1.0\r\n
X-AV-Physical-Unit-Info: pa="BDV-N7200W";\r\n
X-AV-Server-Info: av=5.0; cn="Sony Corporation"; mn="BDV-N7200W"; mv="2.0";\r\n
Content-Type: text/xml; charset="utf-8"\r\n
Content-Length: 390\r\n
NT: upnp:event\r\n
NTS: upnp:propchange\r\n
SID: uuid:5e2036e0-f291-11e9-8000-104fa844bd2e\r\n
SEQ: 44\r\n
\r\n
[Full request URI: http://192.168.1.166:55567/]
File Data: 390 bytes
eXtensible Markup Language
<?xml
version="1.0"
?>
<e:propertyset
xmlns:e="urn:schemas-upnp-org:event-1-0">
<e:property>
<LastChange>
[truncated]<Event xmlns="urn:schemas-upnp-org:metadata-1-0/AVT/">\n <InstanceID val="0">\n <CurrentTrackURI val="local://192.168.1.31:60151/I_14_02_0_-1_00_07_7_23_0_0"/>\n </Instan
</LastChange>
</e:property>
</e:propertyset>
No. Time Source Destination Protocol Length Info
498 18:59:07,447868295 192.168.1.166 192.168.1.31 HTTP 104 HTTP/1.1 200 OK
Frame 498: 104 bytes on wire (832 bits), 104 bytes captured (832 bits) on interface 0
Ethernet II, Src: Apple_ec:70:0d (40:9c:28:ec:70:0d), Dst: Sony_44:bd:2e (10:4f:a8:44:bd:2e)
Internet Protocol Version 4, Src: 192.168.1.166, Dst: 192.168.1.31
Transmission Control Protocol, Src Port: 55567, Dst Port: 39657, Seq: 1, Ack: 775, Len: 38
Hypertext Transfer Protocol
HTTP/1.1 200 OK\r\n
[Expert Info (Chat/Sequence): HTTP/1.1 200 OK\r\n]
[HTTP/1.1 200 OK\r\n]
[Severity level: Chat]
[Group: Sequence]
Response Version: HTTP/1.1
Status Code: 200
[Status Code Description: OK]
Response Phrase: OK
Content-Length: 0\r\n
\r\n
[HTTP response 1/1]
[Request URI: http://192.168.1.166:55567/]
I think you are right about the local://192.168.1.31:60151/I_14_02_0_-1_00_07_7_23_0_0
everthing else does not really hint at sources or inputs.
Have you checked what a curl on this url prints?
Do you remember between which sources you switched?
Hey @alexmohr,
I was follwoing this topic for the last few days and making some research, so I just continued from where patrul stopped,
Then using the Wireshark I managed to find how the TV and Video app send the HDMI1/2 command to the device. I have sent them direct to the device using a Rest client and it worked.
So the thing is that I could not really find a way to find the list it self, so I believe that would be kind of possible to hardcode the input or something, since it may be a standard for some models (I have the same code local://192.168.10.117:60151/I_14_02_0_-1_00_07_7_23_0_0
as patrul which hefers to HDMI2).
Unfortunatly it is not so simple as the IRCC commands but you may know how to implement it on the API.
Just one thing, I am not an expert on any programming language :)
Hopefully we can try something together here.
First of all unfortunately I don't have a lot of time to work at this at the moment so progress will be slow if any. I'm not a huge fan of hard coding these things but we could solve it with a configuration option and use the values you've provided as default.
Please post the requests you've made in your REST client. With these it should be more or less easy to implement the source selection.
That is fine, thanks for the help.
So, from my understanding of this function, just made in steps below,
STEP 1
TVsideview apps sends a POST request http://192.168.10.117:64321/upnp/control/ContentDirectory
to get ContentDirectory:
POST /upnp/control/ContentDirectory HTTP/1.1
Host: 192.168.10.117:64321
Content-Type: text/xml; charset="utf-8"
SOAPAction: "urn:schemas-upnp-org:service:ContentDirectory:1#GetSystemUpdateID"
<?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:GetSystemUpdateID xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
</u:GetSystemUpdateID>
</s:Body>
</s:Envelope>
Then the device returns an ID "2459". Not really sure why but it may be some reference for the input addresses. MAybe this can be skiped for now...
STEP 2 This is something I did not find througt the app but it is necessary sending the device to the HOME page, since step 3 just works if you are on it. This can be done with already implemented IRCC command HOME
STEP 3
The APP sends kind of a input selection to /52323/upnp/control/AVTransport
POST /upnp/control/AVTransport HTTP/1.1
Host: 192.168.10.117:52323
Content-Type: text/xml; charset="utf-8"
SOAPAction: "urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI"
<?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:SetAVTransportURI
xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
<InstanceID>
0
</InstanceID>
<CurrentURI>
local://192.168.10.117:60151/I_14_02_0_-1_00_06_6_23_0_0
</CurrentURI>
<CurrentURIMetaData>
[truncated]<DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:dlna="urn:schemas-dln
</CurrentURIMetaData>
</u:SetAVTransportURI>
</s:Body>
</s:Envelope>
Where local://192.168.10.117:60151/I_14_02_0_-1_00_06_6_23_0_0
means select HDMI1 and local://192.168.10.117:60151/I_14_02_0_-1_00_07_7_23_0_0
means select HDMI2.
I have not tested the other sources yet.
STEP 4 The app sends a command to actually change to the selected source as you can see below.
POST /upnp/control/AVTransport HTTP/1.1
Host: 192.168.10.117:52323
Content-Type: text/xml; charset="utf-8"
SOAPAction: "urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI"
<?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:Play xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
<InstanceID>0</InstanceID>
<Speed>1</Speed>
</u:Play>
</s:Body>
</s:Envelope>
Then from here we get the source change.
I just found these things by trying and reading a bit around. So I cant give much technical details
I also made some changes on my local API device.py file in order to get this to work, but as I mentioned before, I'm not the programing guy and don't know how to add and reference these addresses into a config file so I hardcoded the addresses and for sure the code is not optimized. So far it is working for me, maybe it may save some time if you want to implement it properly.
def input_hdmi1(self):
"""Send HDMI input selection to the connected device"""
self.home()
time.sleep(1)
data = """<u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
<InstanceID>0</InstanceID>
<CurrentURI>local://{0}:60151/I_14_02_0_-1_00_06_6_23_0_0</CurrentURI>
<CurrentURIMetaData>[truncated]<DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:dlna="urn:schemas-dln</CurrentURIMetaData>
</u:SetAVTransportURI>""".format(self.host)
action = "urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI"
content = self._post_soap_request(
url=self.av_transport_url, params=data, action=action)
self.input_play()
return "HDMI 1"
def input_hdmi2(self):
"""Send HDMI input selection to the connected device"""
self.home()
time.sleep(1)
data = """<u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
<InstanceID>0</InstanceID>
<CurrentURI>local://{0}:60151/I_14_02_0_-1_00_07_7_23_0_0</CurrentURI>
<CurrentURIMetaData>[truncated]<DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:dlna="urn:schemas-dln</CurrentURIMetaData>
</u:SetAVTransportURI>""".format(self.host)
action = "urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI"
content = self._post_soap_request(
url=self.av_transport_url, params=data, action=action)
self.input_play()
return "HDMI 2"
def input_play(self):
"""Send input select to the connected device"""
data = """<u:Play xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
<InstanceID>0</InstanceID>
<Speed>1</Speed>
</u:Play>"""
action = "urn:schemas-upnp-org:service:AVTransport:1#Play"
content = self._post_soap_request(
url=self.av_transport_url, params=data, action=action)
Just need to find out how to implement it on home assistant component.
**Edit: changed hardcoded ip to look for the host instead.
Thanks that looks amazing. This should be enough to implement the source selection. Maybe we could find out how the urls for the source are generated if we can get them for other inputs too. I currently have access to a TV which supports this API aswell so maybe I can find out something about the url creation.
I registered my bluray again and tried to use the wireshark to follow the all communication. Unfortunately I could no find anything, maybe because of lack of knowledge. :)
Anyway, I made a hard coded list (as I know what my device supports) and managed to add the source function on home assistant component.
Once we find a way to find the url and input capabilities, then it should be ok to implement them.
So, so far I have my Bluray integrated with my HA and managed to make some automation to change the source. It is working fine.
Sorry for the late reply, I am very busy writing my thesis at the moment. Just wanted to let you know that you are not forgotten and I'll work on integrating your proposal in october. If you're up to making to a pull request I'd be happy to accept it.
No problem, We all have things to do. I will try to make a PR for both API and HA component along this week. Thanks.
@gohlas Did you make any progress yet you want to share? Even if it's not done yet you could open the PR and I'll take over from there.
Sorry, totally forgot about it with busy days. I will make the PR as soon as possible.
Available input sources can be acquired via DLNA (which is currently not implemented). https://github.com/KHerron/SonyAPILib/blob/444d315a8f869127646383c0a93ab22e59355797/SonyAPILib/SonyAPILib/sonyAPILib.cs#L2467
It works also for me. I do not why, but when I use the power button of the media player, it goes to HOME option, similar to config screen and not able to play directly from last input selected before switching off, for example TV input.
If I use the power button of remote, it works and TV input is selected by default. El 7 oct 2019 23:26 +0200, Matthieu DUVAL notifications@github.com, escribió:
_Originally posted by @patrul in https://github.com/alexmohr/media_player.sony/issues/2#issuecomment-539385214_