Sony Devices Binding

Give everyone an update - I’m still testing out the changes and my DN1080 just arrived, so I’ll start testing on it as well. One of the biggest changes is that I’ve finally wrapped my head around USB sticks (and storage in general) and how to handle them.

Basically for content (think cd, bluray, bluetooth, dlna, usb, etc) - there will be four attributes: URI, index, child count, title. You will be able to set the URI and index and then the content information channels (about 50 of them!) will populate based on those two values and a switch that would allow you to play that content. So if you had a USB stick that had say 50 songs on it. The top level URI would be something like “storage:usb” and an index of 3 would give me the 3rd song information on the USB and allow me to play it. Because of how sony does URIs - it works over folders as well (because the URI has folder information in it). Sounds complicated - but it’s actually pretty easy to use and works with all content types (you can do the same with blurays as it’s children are the chapters).

I kinda hope to release the next version next week - but that the DN1080 may delay that for another week depending on how it tests out as well.

2 Likes

Another weekly update. I’m really close to being done now - this ended up to be alot bigger of a change than I originally thought and I had to gut the avcontent service to accomodate AVRs, soundbars and dynamic content (cds, usb, etc). Everything seems to work now with a few minor issues that still need to be corrected. However, the changes have created a huge list of build issues (which enforces code style) that I need to fix - so I can’t quite create an official build yet. Unfortunately I’ll be away for the next five days and will need to finish it up next week on it.

6 Likes

Sorry for late response here, missed this message.
The notification dose not always have the same values as the corresponding get message, and there for the difference in version number. For example have a look at notifyvolumeinformation and getvolumeinformation.

Another week and still have one really nagging issue with Bluray players that I’m still trying to solve. Still have hopes to get it out this week however…

1 Like

take your time, tim!
better a working binding than banana software :slight_smile:
looking forward to testing it!

Latest release: https://github.com/tmrobert8/openhab2-addons/releases/tag/2.5-0424-1

This is a HUGE change - rewrote alot of internals, rewrote the AVContent service completely. I’m sure i fixed some bugs but I’m also sure i’m introducing more.

PLEASE READ THE MULTIPLE POSTS THAT WILL FOLLOW THIS ONE (especially the first one that I"m going to write). I believe there will be THREE posts following this - if you don’t see them, I’m probably still creating them (wait 15 minutes or so).

BIGGEST change - support for websockets which enable soundbars and AVRs (and blurays to an extent) without pairing!

4 Likes

FIRST POST - TODOs and backward compatibility issues

I need ALL of you to do the following:

  1. Shut down openHAB
  2. Delete “userdata/sony” directory completely (will be recreated)
  3. Delete any ‘scalar’ things you have discovered (existing ones will be incompatible)
  4. Delete all scalar*.map files in the transform directory (there was a change to those)
  5. Download the release, rename to .jar and put in addons
  6. Restart openHAB

here’s the important part
Once you add your scalar things back (regardless if they come online or not) - I need you to send me the json files that appear in “userdata\sony\definitions\capability” (either in a PM or via https://send.firefox.com/). This will give me a description of the capabilities of your device (please note the only private information included in this file is the devices IP address - feel free to XXX that out if you want).

This will help me discover any API differences or changes that your specific device has over what I’ve tested.

For now - you can ignore the ‘userdata\sony\definitions\types’. Those files will be used when I start created specific definitions of devices (but that’s in the future).

backward compatibility issues

  1. The application control channels are now hidden by default (they are still there but they are marked as ‘advanced’ to free the UI up a bit)
  2. The app status channel has changed from a switch to a string. The channel will accept “start” or “stop” to start/stop the application.
  3. avContent has completely changed - see further post
  4. audio volume channel has changed for the raw values on the device (like 0-50 in the case of bravia) to a 0-100% dimmer and the underlying value will be scaled to the device. So if you sent 20 to a bravia tv in the past - it will only send 10 to the tv now (since it’s being scaled).
  5. scalar configuration has changed - I dropped the whole analog/digital setting (since av changed) and added an IRCC URL (to enable the IRCC command channel in scalar). Most devices implement IRCC and it will be discovered by the inbox normally. If it’s not - just copy the IRCC URL from the IRCC service that is discovered and it should work. Please note that not all devices support IRCC

AV Content
This service has radically changed and nothing you have before will be the same. Here’s a quick overview:

Sources
avContent@sources is a string (readonly) channel that will list (comma delimited) all sources on your device. Please note that these are the highlevel sources. A source will be “extInput:hdmi” to indicate you have hdmi ports. However a specific hdmi port would be something like ‘extInput:hdmi?port=1’.

Terminal source
avContent@tm_source-Main (or -something for multizone devices like AVRs) is a string channel that will accept the source URI to switch the source to. Example: sending “tv:analog” to the tm_source channel will switch to analog tv. Sending “extInput:hdmi?port=1” will switch to hdmi1, etc. If you are using the paperui (or something that supports state options), the binding will dynamically create the options for you (so you can simply select “hdmi1” and it will send the proper URI).

Please note that according to @freke, even though USB (storage:usb1) is shown and is valid - the source will not switch to USB. You need to select a file to play for it to properly switch (see below).

Content
The content channels (avContent#cn_*) will allow you to explore/select content on the device. The most important channels are:

  1. avContent#cn_parenturi - a string channel for the parent uri
  2. avContent#cn_idx - the zero based index within the parenturi to select
  3. avContent#cn_childcount - the number (readonly) of children in the parent uri
  4. avContent#cn_uri - the URI (readonly) in the parenturi at the index position
  5. avContent#cn_selected - the command channel to select the child

At this point your like ‘huh?’. Let’s do an example - let’s say you have a USB flash drive with music in a folder structure like "artist/album/tracks’. So the top level directory has all the artists, if you select one of those directories - you see the albums and if you select an album you see all the tracks.

Let’s say:

  1. my USB has 53 artists in them (53 top level directories)
  2. the first artist (directory) is “Billy Joel”.
  3. Under the “Billy Joel” directory - I have two albums “River of Dreams” and “Storm Front”
  4. Under “Storm Front” I have 10 tracks

How to do this with the avcontent channels:

  1. I first send ‘storage:usb1’ to the cn_parenturi
  2. openHAB will then populate cn_childcount with the number of children [53], cn_idx to 0 (selecting the first child), cn_uri with the uri of the item in index 0 position [storage:usb1?path=/Billy%20Joel].
  3. I send “storage:usb1?path=/Billy%20Joel” to cn_parenturi
  4. cn_childcount become “2”, cn_idx stays at 0 and cn_uri becomes “storage:usb1?path=/Billy%20Joel/River%20of%20Dreams”
  5. I change cn_idx to 1 (to select the second album)
  6. cn_childcount stays the same, cn_idx shows 1 and cn_uri becomes “storage:usb1?path=/Billy%20Joel/Storm%20Front”
  7. I send “storage:usb1?path=/Billy%20Joel/Storm%20Front” to cn_parenturi
  8. cn_childcount becomes “10”, cn_idx switchs to 0, and cn_uri becomes “audio:content?path=/Billy%20Joel/Storm%20Front/01%20That%27s%20Not%20Her%20Style.mp3&storage=usb1” (the first track)
  9. I send “select” to cn_selected and the first track begins to play.

Sound complicated but if you are using a UI - it’s fairly simple. You simply are copying cn_uri to cn_parenturi and setting the cn_idx to the value you want. Please note that depending on the track tagging - the other content fields (title, album, etc) will populate as well.

avContent can be used to view/select tv stations, radio stations (presets), usb, disc, ets. Please note that some sources have no content (like bluetooth and strangley DLNA).

Please note that if you set tm_source to something - it will automatically set cn_parenturi to that source and cn_idx to 0 (so if you set “USB” to the source - it automatically sets the first item on the USB for you).

Playing
Depending on the content that is playing - the avContent#pl_* fields will start to populate.

The most important one here is (again, Main may differ on a multizone device):

  1. avContent#pl_cmd-Main - the command to control what is playing
  2. avContent#pl_presetid-Main - the preset to get/set for what is playing

The pl_cmd will take the following commands:

  1. “play” start playing
  2. “pause” pause playing
  3. “stop” stop playing
  4. “next” go to the next item
  5. “prev” go to the previous item
  6. “fwd” go forward in the item
  7. “bwd” go backward in the item
  8. “fwdseek” seek forward (usually radio broadcast frequencies)
  9. “bwdseek” seek backward (usually radio broadcast frequencies)
  10. “setpreset” set current item as preset (using pl_presetid as the preset to set)
  11. “getpreset” gets the preset from “pl_presetid”

Presets generally are for radio stations only

All the other pl_* channels will get populated depending item being played.

LAST POST other stuff
There is alot of stuff in this version but if you are techy and want to play with the device yourself (@freke may be interested in this as well). Go to “http://localhost:8080/sony/index.html” - this will bring up a page that will allow you to play with your device directly. I’m showing this to you all because I may eventually need one of you to do something on this page for me…

The best way to use this page is to hit the “Load File” button and navigate to “userdata\sony\definitions\capability” directory and load the json for your device. The table below the button will then popuplate with all the APIs for that device (and show you the parameters/return for each). Clicking on one of the APIs will the populate the left side with everything you need. Modify the the “parms” and press execute - the result will then appear in the bottom.

Here’s a quick demo…

  1. Open the page - hit “Load File”, navigate to userdata\sony\definitions\capability and select your json file
  2. Scroll down to “avContent”, “getSchemeList” and click it
  3. The left side should populate - simply press execute (there are no parameters to scheme list)
  4. The bottom should show something like [[{"scheme":"extInput"},{"scheme":"storage"},{"scheme":"dlna"}]] (your’s will differ probably)
  5. Choose one of the schemes (extInput is a good one)
  6. Click on the “avContent”, “getSourceList” (if you see v1.1 and v1.2 - select the 1.1 version)
  7. The left side should populate - in the parms, replace the “string” with your source (extInput in this demo). The parms should look like: {"scheme":"extInput"}
  8. Press execute - the result should be all the inputs for your device. Mine look like:
[[{"iconUrl":"","isBrowsable":false,"isPlayable":true,"meta":"meta:tv","playAction":"changeSource","source":"extInput:tv","title":"TV"},{"iconUrl":"","isBrowsable":true,"isPlayable":false,"meta":"meta:hdmi","playAction":"","source":"extInput:hdmi?port=1","title":"HDMI1"},{"iconUrl":"","isBrowsable":true,"isPlayable":false,"meta":"meta:hdmi","playAction":"","source":"extInput:hdmi?port=2","title":"HDMI2"},{"iconUrl":"","isBrowsable":true,"isPlayable":false,"meta":"meta:hdmi","playAction":"","source":"extInput:hdmi?port=3","title":"HDMI3"},{"iconUrl":"","isBrowsable":false,"isPlayable":true,"meta":"meta:btaudio","playAction":"changeSource","source":"extInput:btAudio","title":"Bluetooth Audio"},{"iconUrl":"","isBrowsable":false,"isPlayable":true,"meta":"meta:linemini","playAction":"changeSource","source":"extInput:line","title":"Analog"}]]
  1. You ca then use the “source” (“extInput:btAudio”) for various other actions - like clicking on “setPlayContent” and changing the parm to {"uri":"extInput:btAudio"} (ignoring everything else) and the bluetooth audio should come up on the device.

You can play around with it alot if you want. Don’t try any of the ‘notify*’ methods - those are info only lines. Likewise the “Merge File” really isn’t useful to you. @freke may find it interesting because it allows you to merge in other APIs to see if there are any differences between devices (differences are highlighted).

Have fun and let me know if you have any issues…

Tim

EDIT: btw - there are all sorts of goodies in the hidden ‘advanced’ channels. You’ll find things like being able to set the sound settings (music/sports/etc) and various other settings - worth looking through those

1 Like

Okay - a forth post but this is more informational only. Do NOT copy the userdata/sony/definitions/types to the userdata/sony/db/types directory. I made some changes to that logic as well but really haven’t tested it well yet. That will be tested for the next version. The biggest change here is that I can now regroup channels as needed. Example: for DN1080 - I could create a Main Zone, Second Zone and HDMI Zone groups with the appropriate channels in the groups dynamically with the definition file. Basically I could imitate the grouping that sony audio addon does but in a dynamic file approach (no code changes). This allows me to bring up new devices with only definition file changes.

EDIT: there are also a couple of issues that I’m aware of in the code base. The biggest being that if you delete an scalar thing - there is a polling thread that doesn’t get shutdown properly (you’ll see “Pinging ipaddress” messages in the log continuing). Still need to track that one down (and there is some label issues as well)

Thanks a lot for the new, at least the issue that my scalar thing goes offline "
Storage doesn’t exist" seems fixed. The thing stays online and i can switch apps until now.

However with the rest i totally lost you, i don’t even know how to switch tv stations anymore. Maybe i find some time on the weekend to understand :smiley:

Yes - TV stations have definitely gotten harder with this version and you may want to create some rules to make it easier.

Here’s what you can do to get a hang of what needs to be done in a rule - but doing it manually with the paperui:

  1. Open paperui
  2. Find your TV in it
  3. Find the “Terminal Source Main” (that’s your TV screen)
  4. Click on the “tv:analog” or “tv:atscsomething” or “tv:dtscsomething” button - depending on what type of channel you are trying to tune (analog or digital)
  5. That copies the “tv:whatever” to the “Content Parent URI” channel and sets “Content Index” to 0 - the “Content Title” channel should show you whatever channel is in the 0 position
  6. You can browse through your channels by changing the “Content Index” channel (from 0 to “Content Child Count” [which is the total number of channels you have]).
  7. When your on the channel you want - simply hit the “Select” button on “Content Selected” channel to tune to that station.

You can then create some rules that would make it much easier - basically the rule would:

  1. Send “tv:whatever” to the content parent uri channel
  2. Send x (where x is the index of the channel) to the content index channel
  3. Send “select” to the content selected channel
1 Like

Note that if you use send.firefox.com - you need to post the URL it gives you to the forum (or PM the URL) - just noticed someone clicked on the link

Updated the Binding. My SimpleIP Thing and Items still working good. WoL is now working too.
Scalar Thing still isnt working. At first look it seems a little bit worse because registration at my TV makes now trouble again. I will write an own post on this.

Thanks, with your instruction i was able to change tv stations.
But should these items receive the status from the tv as well?
if i change the tv station or even the source at the tv the items wont notice…

Hi @tmrobert8.
Thanks for your ongoing work on this binding.
I want to update, but can’t find a userdata/Sony folder to delete.
Running OH 2.4.0 on synology…

Any ideas?

hi @tmrobert8, i can’t find this folder anywhere… i’m using openhabian version of the install

I can confirm WoL works now. I had to uninstall the old binding via karaf console. @tmrobert8 the scalar thing has a strange behavior my TV recognize many new RQST codes when I choose the scalar thing. I’m not able to bind my TV with the scalar thing.
@suntribe, @marklavercombe I didn’t find this via ssh but the userdata folder is shared via network folder by default within openhabian.

Running OH with docker on synology too. Had no such directory either. Just skipped deleting it. It was created after restart with the new binding.

Same behavior here. Scalar Thing gets discoverd but when it add it it flashes a code multiple times per second. I added my my debug log:
SCALAR.log (428.2 KB)