LinkPlay Integration

Added chadet as a dependency of this component so in theory it should install it in background as soon as you update and restart HA.

@robi I just installed your addon and it works well as individual media player. By the way, is there a way to play a song from Spotify (premium) or from local HA storage to multiroom as the same time?

Thank you.

Icecast all working perfectly again - thanks!

I recently ordered a few Arylic Up2Stream Amp v4 as I am planing on using them for my future multi room audio setup.
They work pretty great with the 4Stream app, but I have a few problems / questions regarding the integration inHome Assistant.
The first problem or question is related to spotify. Before starting to look into the spotify integration, I was thinking that spotify can smehow be used as a “source” for the linkplay devices and that I might be able to pick playlists from inside home assistant. Now it seems like this is not possible with spotify as they want you to use the official app / website. Am I correct?
I also have a free spotify account only and if I understand it correctly, I can’t use spotify together with my Arylic Amps right?

The second problem is related to some streams. In my current test setup I am using the following streams:

  'https://streams.ilovemusic.de/iloveradio21.mp3': 'I Love Hardstyle',
  'https://streams.ilovemusic.de/iloveradio2.mp3': 'I Love 2 Dance',
  'https://ffn-de-hz-fal-stream04-cluster01.radiohost.de/radiobollerwagen_mp3-192': 'Bollerwagen'

All the URLs are working in VLC but in Home Assistant, the first and the second one don’t work most of the times. They display the station name and current song title but don’t play any music. A few seconds later the media player changes the state from “playing” to “idle” again.
The third stream instead works always.

The third problem is with an automation to play TTS. Basically I would like to take a snapshot of two devices, group them together, set the volume and then play a TTS notification. After the notification I would like to restore the snapshot again.
When I run the automation, the music stops, the volumn is set and then it plays again with the new volume for a short time. After that, part of the TTS message is played, the beginning is skipped.
I tried to copy the code from the automation example but the result was the same.
Here is the code of my automation:

- id: '1642781963070'
  alias: Licht aus
  description: ''
  trigger:
  - platform: state
    entity_id: light.light_1
    from: 'off'
    to: 'on'
  action:
  - service: linkplay.snapshot
    data:
      entity_id: media_player.bedroom
  - service: linkplay.snapshot
    data:
      entity_id: media_player.bathroom
  - service: media_player.media_pause
    target:
      entity_id:
      - media_player.bathroom
      - media_player.bedroom
  - service: media_player.volume_set
    data:
      volume_level: 0.5
    target:
      entity_id:
      - media_player.bedroom
      - media_player.bathroom
  - service: media_player.join
    target:
      entity_id:
      - media_player.bedroom
    data:
      group_members: media_player.bathroom
  - service: tts.google_translate_say
    data:
      entity_id: media_player.bedroom
      message: Test 1 2 3 Test
      cache: true
  - delay: 00:00:05
  - service: media_player.unjoin
    target:
      entity_id: media_player.bathroom
  - service: linkplay.restore
    data:
      entity_id: media_player.bedroom
  - service: linkplay.restore
    data:
      entity_id: media_player.bathroom
  mode: single

Last but not least, I am wondering if it is possible to play media files from a NAS or Home Assistant.
I know that it is possible to play files from a USB that is connected to the linkplay device but I would like to have a central place for all my media files and “send” them to the players instead.

I hope you can answer my questions, thank you for your great work!

Yes, you have to use their app to start playing content. Even if you use HA’a native Spotify integration, you initiate media playback from there, not your Linkplay media device.
That’s how Spotify functionality was invented, no way to change this.

Yes you need a paid account to redirect music playback to a speaker device. With the free account you can only redirect playback from your mobile to a PC-desktop player.

Try using plain HTTP not HTTPS streams.

Try adding an extra delay before the tts.google_translate_say too.

Hi Robert,
thank you for the quick reply.

Yes you need a paid account to redirect music playback to a speaker device. With the free account you can only redirect playback from your mobile to a PC-desktop player.

My hope was that spotify offers an API similar to the webradios so you can basically just send the stream link to the devices…

Try using plain HTTP not HTTPS streams.

That seems to solve the issue, the streams now play everytime. Thank you!

Try adding an extra delay before the tts.google_translate_say too.

I also tried that, the result is more or less the same.
I also simplified the codee and I am now using PicoTTS as I hoped that a local tts might work better. Here is the current automation code:

trigger:
  - platform: state
    entity_id: light.light_1
    from: 'off'
    to: 'on'
action:
  - service: linkplay.snapshot
    data:
      entity_id: media_player.bedroom
  - service: media_player.media_pause
    target:
      entity_id: media_player.bedroom
  - delay: '00:00:02'
  - service: media_player.volume_set
    data:
      volume_level: 0.5
    target:
      entity_id:
        - media_player.bedroom
  - service: tts.picotts_say
    data:
      entity_id: media_player.bedroom
      message: Test 1 2 3 Test
      cache: true
  - delay: '00:00:02'
  - service: linkplay.restore
    data:
      entity_id: media_player.bedroom
mode: single

The problem is not only, that the TTS message does not (always) play fully, but that the old stream is played again when I set the volume. As I need a higher volume for the TTS message, the sound plays pretty loud for a short time, before it switches to the TTS message.
I also tried the following solutions:

  • Use media_player.media_stop instead of media_pause
  • Play a short “warmup” TTS message after the snapshot and before setting the volume, with another delay after the warmup
    The reuslt is always the same, the previous sound is played again for a short time with the higher volume.

I have to say that at the moment all my devices, including the Pi that runs Home Assistant, are connected over WiFi, not ethernet. That might cause some issues to altough I don’t think the TTS issue is related to that…

Edit:
Another question: I just tried to choose my player from within the HA media browser, but it only shows “Web Browser” as a player. Is that normal?

Try with a silence sound file.

Thank you, I will try that.
But that sounds more like a workaround then a real solution, so I am wondering whats the cause of this problem? Is this an issue with Home Assistant, with TTS, with LinkPlay or with this integration?
Is that something that can be fixed without hacky workarounds?

I think it’s an issue with the firwmare on the players. It takes a lot of time until they start to play the stream.

Thank you for the information.
I didn’t have the time to check if the silence file would solve the issue but I will let you know as soon as I tested it!
Another question:
Is it possible to play local music files from a NAS or similar?
I tried playing music from HA media browser but it does not show my LinkPlay players but only “web browser”.
I would like to have a NAS with all my music files and maybe playlists.

Did not have time to implement that, sorry. If you plug a USB stick in your LinkPlay device, that will play.

Ok, so it’s not a limitation of the platform.
Thank you very much for the quick answers and especially for your great work!

1 Like

v3.0.0 out

  • Refactored component to be async to improve responsiveness and less hog down the system
  • HA unique identifier based on hardware UUID, see breaking change note below
  • Changed to a different UPnP implementation, this should work also from other subnets
  • Removed the deprecated, unused services

Breaking change: the configured devices will be re-added to HA internal registry database with a new unique identifier tied to the hardware UUID of the Linkplay modules instead of IP address. This will result in having the original entity_id of the preiously configured devices unavailable and having added it as new with entity_id _2 or similar.

This can be easily fixed in Home Assistant, visit your entites list, click the old entity_id and delete it. Then click the newly generated entity_id _2 and name it back to what preiously was. Everything else remains unchanged.

This should be useful when the IP address of the device changes, so the entity id is kept in the future.

4 Likes

Thanks for the new version! It seems to respond much faster.

But I got an issue with double entities.
My linkplay devices are behind smart switches. So they are not available most of the time.

When HA starts it adds the entities according to the yaml configuration. But without the UUID because they are not reachable. When I then turn on the linkplay device HA adds antoher entity (media_player.x_2)

The only thing which currently sovles this is, when I turn on all linkplay devices when I restart HA.

Is there a possibility to set the UUID in the yaml config?

Yes it is, check out in the latest release. Turn on the devices, restart HA, look in device attributes for their UUID, and set it in the config manually (see readme), and then restart HA again.

1 Like

Added support for HA’s built-in media browser. TTS is back from the UI and the new Radio Browser (HA’s original integration) is also working. Can play now media files stored in HA.

Local USB browser disabled for now - have no clue how to combine the two. But I guess few people used it anyway. USB playback is of course still working, it’s just the browsing UI functionality that was removed.

2 Likes

If TTS audio is being cut off at the beginning, this is because the player needs some time to switch to playing out the stream. The only good solution for this is to add a configurable amount of silence at the beginning of the audio stream, I’ve modified Google Translate and VoiceRSS to do this, they can be installed manually as custom components.

Custom integrations that override core integrations are not accepted in HACS, but can can still be installed through it as custom repository.

Hi many thanks for this integration. Really appreciated.

I see indeed that the Media Browser is included. However I don’t see Spotify as a source in the Media Browser for the linkplay device.

This is an example of another chromecast device:

And this is the one from the Linkplay device:

Would it be possible to also add spotify to the Media browser?

Thanks for the headsup. I’ll see what can be done.

1 Like

Not easy to implement for me so don’t expect it any soon.