LinkPlay Integration

Yes!
Reviewed my configuration and had some typos. It shows files in HA. Sorry for this.

Both for SD card and USB?

This is strange…
For USB is working ok on app and HA.
For SD is not working ok. No files on app and no files on HA.
BUT!
On the app it was selected the playlist from USB, when changing the source from USB to SD from HA AND the playlist was not closed, it shows the files from SD, but after reopening the playlist, it shows nothing on app.

Sounds like a bug in the UPNP part of the firmware. I guess it could be worked around but unless I could get my hands on such a unit, I don’t see real chances. None of my players have an SD slot, and additionally they are all above v4 firmware.

Working

Seems it is a 4stream problem. Using AudioPro shows files from both sources.

Edit: Yes, it is from 4stream. If playlist remains open when file playback changes, it shows files on SD.

If playlist remains open when file playback changes, it shows files on SD.

Can you please describe more exactly how it behaves?

The speaker is playing a track from SD.
Open 4stream, go to playlist. It is empty.
Playing track reaches the end and the next track starts playing (playlist still opened). This is the moment when the playlist populates and shows files on SD.

OK I see. I think the speaker is using a different UPNP queuename to publish the initial state of the ‘playlist’ (=list of all files) from the SD. During playback it seems updating the CurrentQueue which looks like it’s common for both USB and SD, the problem is that it’s not available until the user starts playing.
4Stream app seems not prepared to handle SD queues…

This could be resolved with a bit of sniffing. If you’re in the mood of hacking, try to monitor the traffic between the other app and your speaker. You could use HttpCanary app on Android for this. The idea is to start watching for packets when you click on the list to see the contents of the SD. You should look for upnp control messages and find the one which in response gives a huge XML with all the files (select response on top and text on bottom). Near the beginning of that message there should be something like <ListName>USBDiskQueue</ListName> - we need to know what’s the Queue name in the case of SD, instead of USBDiskQueue.

This one?
There are only 2 tracks on SD.

HTTP/1.1 200 OK
CONTENT-LENGTH: 4330
CONTENT-TYPE: text/xml; charset="utf-8"
SERVER: Linux/2.6.36

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body>
<u:BrowseQueueResponse xmlns:u="urn:schemas-wiimu-com:service:PlayQueue:1">
<QueueContext>&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;PlayList&gt;
&lt;ListName&gt;USBDiskQueue&lt;/ListName&gt;
&lt;ListInfo&gt;
&lt;SourceName&gt;USBDiskQueue&lt;/SourceName&gt;
&lt;MarkSearch&gt;0&lt;/MarkSearch&gt;
&lt;TrackNumber&gt;2&lt;/TrackNumber&gt;
&lt;Quality&gt;0&lt;/Quality&gt;
&lt;UpdateTime&gt;1625&lt;/UpdateTime&gt;
&lt;LastPlayIndex&gt;2&lt;/LastPlayIndex&gt;
&lt;RealIndex&gt;0&lt;/RealIndex&gt;
&lt;SwitchPageMode&gt;0&lt;/SwitchPageMode&gt;
&lt;CurrentPage&gt;0&lt;/CurrentPage&gt;
&lt;TotalPages&gt;0&lt;/TotalPages&gt;
&lt;searching&gt;0&lt;/searching&gt;
&lt;/ListInfo&gt;
&lt;Tracks&gt;
&lt;Track1&gt;
&lt;URL&gt;/media/sda1/Basshunter - Calcutta.mp3&lt;/URL&gt;
&lt;Metadata&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;
&amp;lt;DIDL-Lite xmlns:dc=&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot; xmlns:upnp=&amp;quot;urn:schemas-upnp-org:metadata-1-0/upnp/&amp;quot; xmlns:song=&amp;quot;www.wiimu.com/song/&amp;quot; xmlns=&amp;quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&amp;quot;&amp;gt;
&amp;lt;upnp:class&amp;gt;object.item.audioItem.musicTrack&amp;lt;/upnp:class&amp;gt;
&amp;lt;item id=&amp;quot;0&amp;quot;&amp;gt;
&amp;lt;song:subid&amp;gt;&amp;lt;/song:subid&amp;gt;
&amp;lt;song:description&amp;gt;unknown&amp;lt;/song:description&amp;gt;
&amp;lt;song:skiplimit&amp;gt;0&amp;lt;/song:skiplimit&amp;gt;
&amp;lt;song:id&amp;gt;0&amp;lt;/song:id&amp;gt;
&amp;lt;song:like&amp;gt;0&amp;lt;/song:like&amp;gt;
&amp;lt;song:singerid&amp;gt;0&amp;lt;/song:singerid&amp;gt;
&amp;lt;song:albumid&amp;gt;0&amp;lt;/song:albumid&amp;gt;
&amp;lt;res protocolInfo=&amp;quot;http-get:*:audio/mpeg:DLNA.ORG_PN=MP3;DLNA.ORG_OP=01;&amp;quot; duration=&amp;quot;00:00:00.000&amp;quot;&amp;gt;/media/sda1/Basshunter - Calcutta.mp3&amp;lt;/res&amp;gt;
&amp;lt;dc:title&amp;gt;Basshunter - Calcutta.mp3&amp;lt;/dc:title&amp;gt;
&amp;lt;dc:creator&amp;gt;unknown&amp;lt;/dc:creator&amp;gt;
&amp;lt;upnp:artist&amp;gt;unknown&amp;lt;/upnp:artist&amp;gt;
&amp;lt;upnp:album&amp;gt;unknown&amp;lt;/upnp:album&amp;gt;
&amp;lt;upnp:albumArtURI&amp;gt;unknown&amp;lt;/upnp:albumArtURI&amp;gt;
&amp;lt;/item&amp;gt;
&amp;lt;/DIDL-Lite&amp;gt;
&lt;/Metadata&gt;
&lt;Source&gt;USBDiskQueue&lt;/Source&gt;
&lt;/Track1&gt;
&lt;Track2&gt;
&lt;URL&gt;/media/sda1/Big Brovaz - Nu Flow.mp3&lt;/URL&gt;
&lt;Metadata&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;
&amp;lt;DIDL-Lite xmlns:dc=&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot; xmlns:upnp=&amp;quot;urn:schemas-upnp-org:metadata-1-0/upnp/&amp;quot; xmlns:song=&amp;quot;www.wiimu.com/song/&amp;quot; xmlns=&amp;quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&amp;quot;&amp;gt;
&amp;lt;upnp:class&amp;gt;object.item.audioItem.musicTrack&amp;lt;/upnp:class&amp;gt;
&amp;lt;item id=&amp;quot;0&amp;quot;&amp;gt;
&amp;lt;song:subid&amp;gt;&amp;lt;/song:subid&amp;gt;
&amp;lt;song:description&amp;gt;unknown&amp;lt;/song:description&amp;gt;
&amp;lt;song:skiplimit&amp;gt;0&amp;lt;/song:skiplimit&amp;gt;
&amp;lt;song:id&amp;gt;0&amp;lt;/song:id&amp;gt;
&amp;lt;song:like&amp;gt;0&amp;lt;/song:like&amp;gt;
&amp;lt;song:singerid&amp;gt;0&amp;lt;/song:singerid&amp;gt;
&amp;lt;song:albumid&amp;gt;0&amp;lt;/song:albumid&amp;gt;
&amp;lt;res protocolInfo=&amp;quot;http-get:*:audio/mpeg:DLNA.ORG_PN=MP3;DLNA.ORG_OP=01;&amp;quot; duration=&amp;quot;00:00:00.000&amp;quot;&amp;gt;/media/sda1/Big Brovaz - Nu Flow.mp3&amp;lt;/res&amp;gt;
&amp;lt;dc:title&amp;gt;Big Brovaz - Nu Flow.mp3&amp;lt;/dc:title&amp;gt;
&amp;lt;dc:creator&amp;gt;unknown&amp;lt;/dc:creator&amp;gt;
&amp;lt;upnp:artist&amp;gt;unknown&amp;lt;/upnp:artist&amp;gt;
&amp;lt;upnp:album&amp;gt;unknown&amp;lt;/upnp:album&amp;gt;
&amp;lt;upnp:albumArtURI&amp;gt;unknown&amp;lt;/upnp:albumArtURI&amp;gt;
&amp;lt;/item&amp;gt;
&amp;lt;/DIDL-Lite&amp;gt;
&lt;/Metadata&gt;
&lt;Source&gt;USBDiskQueue&lt;/Source&gt;
&lt;/Track2&gt;
&lt;/Tracks&gt;
&lt;/PlayList&gt;
</QueueContext>
</u:BrowseQueueResponse>
</s:Body> </s:Envelope>

Yes, this is it, thanks. Strangely it has the same name USBDiskQueue.

Edit: what happens if you replace at line 1198:
queuename = 'CurrentQueue' instead of 'USBDiskQueue'.

Try loading separately for both USB and SD.

USB is working.
When selecting SD, it takes the files from USB source.

Should I change lines 1197, 1198 and 1199 to match SD? Currentyl is USB.

That won’t affect it, those are just names…
Unfortunately I won’t be able to fix it unless I get my hands on such a device.

No problem!
Personally, I am using the speakers for internet radio.
I would like to thank you again for your time & work. Using HA to play music is more flexible.

When can we switch to master branch?

Is there a way to play youtube on theese speakers?

1 Like

Master branch is alive and included in HACS. You can re-install from there (if you’re on previous version of Linkplay integration, uninstall that first, and install from HACS v2, which is this one).
If you use HACS, you will be notified when there are updates, and you can also check for updates manually if yo want.

Added ability to snapshot and restore Spotify state (released in HACS, v2.0.2a)

What happens during snapshot is that the current Spotify playlist will be saved (overwritten) on the device’s highest preset number. It can be seen in the Android app: Snapshot set by Home Assistant (playlist name). During restore HA will simply recall that preset, the playback will continue with the same Spotify playlist as before.

Caveats are that since this means, from Spotify’s point of view, a new start of the same playlist playback, it may either start from the beginning or not, or the same track or not. I couldn’t figure it out. And tracks which were played before the snapshot may be played again later after restore.
Since most people listen to randomly generated music playlists, I guess this is acceptable.
Currently there’s no other way to do this as there’s not much documentation available and Spotify communication with the unit is closed.

That’s awesome!!! Still much better functionality then having music stop completely after a TTS notification. Thank you for your great work!

Added support for metadata during Tidal playback (artitst, title, album, coverart).
Added support for metadata during TuneIn playback (title, coverart).
(released in HACS, v2.0.4)

TuneIn support is limited, in the aspect of data refresh, due to the fact that it’s hard to be differentiated clearly from other stream playback types, without intensive polling of the device. The value it brings doesn’t worth it - as the TuneIn info rarely has correct metadata present (it most cases only has a subtitle or slogan instead of normal artist and title information, and just a station logo instead of real cover art).
The experience is better with stations configured as sources (and thus buttons with mini-media-player card), as there metadata is grabbed from Icecast.
I’m seriously thinking to remove it…

v2.0.5:

  • added possibilty to specify multiple entity ids separated by comma or use all to run the services against
  • fixed Spotify snapshot for devices which had an empty last preset
  • removed TuneIn coverart support, as it caused more bad than good. Better get info from stream’s icecast headers + coverarts based on that from Last.Fm

v2.0.6:

  • add support for Deezer metadata based on CDN subdomain detection (similar to Tidal)

Hey @robi - I just wanted to say thanks a lot for bringing this custom integration back to life with your new version.
I did test the original version a while back and it didn’t work as expected for me.
However now I found your new version randomly in HACS and so far it seems to work great. And you’re really on fire with the updates / further development.
Thanks again! :slight_smile:

1 Like