LinkPlay Integration

OK, check out the testing branch. It supports multiroom in both modes (wifi direct and router), it should autodetect if your firmware version is older than 4, it automatically falls back to wifi direct mode. Can be overridden with the option multiroom_wifidirect: True if one wants to use wifi direct with newer firmwares too (perhaps having a mix of devices with new and old fw). For firmware versions bigger than 4, multiroom is done in router mode by default.

Check out carefully the new linkplay.join and linkplay.unjoin services as they differ from the original ones. Had to re-arrange them to comply with the HA in-house standard coming from sonos integration, and make linkplay compatible with custom:mini-media-player. Check out the description there how to set it up for speaker grouping features, the platform name is linkplay. Old multiroom services removed, as this part of the integration had to be rewritten almost completely.

New service added linkplay.command, check out the description in the Dev tools in HA. Supported commands are Reboot, PromptEnable, PromptDisable, SetRandomWifiKey, WriteDeviceNameToUnit, TimeSync, RouterMultiroomEnable.
Most of them are self-explanatory;

  • SetRandomWifiKey is there as an extra security feature, one could make an automation in HA to change the keys on the linkplay APs to some random values periodically.
  • WriteDeviceNameToUnit would write the name configured in HA to the player’s firmware so that the names would match exactly in order to have multiroom in wifi direct mode fully operational (not needed for router mode).
  • RouterMultiroomEnable theoretically router mode is enabled by default in new firmwares, but there’s also a logic included to build it up, this command ensures to set the good priority.
  • TimeSync is for units on networks not connected to internet to compensate for an unreachable NTP server. Correct time is needed for the alarm clock functionality (not implemented yet here)

New services added linkplay.snapshot and linkplay.restore in order to make usage with TTS easier. Currently only the source input is being snapshotted and restored (which of course can be a webradio stream).

Running from services

linkplay.join
entity_id: media_player.baie
master: media_player.bucatarie

Does not join, slave speaker does not play.
Mini media player shows like joined the group, but no group in the app.

Not showing on services.

Re-download, i’ve changed a few things moments ago.

Also add this to HA’s main configuration.yaml:

logger:
  default: warn
  logs:
    custom_components.linkplay: debug

And look for any suspicious while you start joining in home-assistant.log. Check if versions are detected correctly. If not, add multiroom_wifidirect: True to your config to all your players.

Now it starts to become more difficult, as on my units with firmware 4.2.8020 and 4.2.8230 things work fine in both wifidirect and router multiroom mode…

Join and unjoin are working OK.

Logs:

Log Details (WARNING)
Logger: homeassistant.helpers.service
Source: helpers/service.py:258
First occurred: 12:43:39 AM (1 occurrences)
Last logged: 12:43:39 AM

Unable to find services.yaml for the linkplay integration
Log Details (WARNING)
Logger: custom_components.linkplay.media_player
Source: custom_components/linkplay/media_player.py:551
Integration: LinkPlay (documentation, issues)
First occurred: 12:52:26 AM (1 occurrences)
Last logged: 12:52:26 AM

presed pause for: media_player.baie

Unable to find services.yaml for the linkplay integration

You should download the contents of the entire directory in the testing branch. That file is right there.

Yes, it`s there. You are perfectly right! :slight_smile:

Here’s how it looks in my setup with mini-media-player:
kép
The buttons are just input selectors, each input as a webradio.
Metadata from icecast, cover from lastfm.

Lovelace card config:

entities:
  - artwork: cover
    entity: media_player.hang_szaletli
    group: true
    hide:
      controls: false
      next: true
      play_pause: true
      play_stop: false
      power: true
      prev: true
      progress: true
      source: true
      volume: true
    shortcuts:
      attribute: source
      buttons:
        - icon: 'mdi:spotify'
          id: Spotify
          type: source
        - id: Jazzy
          name: Jazzy
          type: source
        - id: Rádió 1
          name: Rádió1
          type: source
        - id: Retró
          name: Retró
          type: source
        - id: Sláger
          name: Sláger
          type: source
        - id: Best FM
          name: BestFM
          type: source
        - id: Forrás
          name: Forrás
          type: source
        - id: Manna
          name: Manna
          type: source
        - id: Info Rádió
          name: Info
          type: source
        - id: Jazzy Soul
          name: Jzy Soul
          type: source
        - id: Petőfi
          name: Petőfi
          type: source
        - id: Kossuth
          name: Kossuth
          type: source
      column_height: 10
      columns: 4
    type: 'custom:mini-media-player'
  - entity: media_player.hang_szaletli
    group: true
    hide:
      controls: true
      icon: true
      info: true
      name: true
      power: true
      power_state: false
      progress: true
      source: true
      volume: false
    name: Szaletli
    speaker_group:
      entities:
        - entity_id: media_player.hang_szaletli
          name: Szaletli
        - entity_id: media_player.hang_konyha
          name: Konyha
        - entity_id: media_player.hang_nappali
          name: Nappali
      expanded: false
      platform: linkplay
    toggle_power: false
    type: 'custom:mini-media-player'
show_header_toggle: false
title: Kültér
type: entities
2 Likes

Nice!
I`m also working on my mini media player.

Bucatarie = master
Baie = slave
When playing everything is ok.
Whem Bucatarie is stopped, below is the logbook for Baie. Is this normal?

12:31:30 AM
Baie changed to playing
12:31:30 AM
Baie changed to idle
12:31:19 AM
Baie changed to playing
12:31:19 AM
Baie changed to idle
12:31:08 AM
Baie changed to playing
12:31:08 AM
Baie changed to idle
12:30:57 AM
Baie changed to playing
12:30:57 AM
Baie changed to idle
12:30:46 AM
Baie changed to playing
12:30:46 AM
Baie changed to idle
12:30:36 AM
Baie changed to playing
12:30:36 AM
Baie changed to idle
12:30:24 AM
Baie changed to playing
12:30:24 AM
Baie changed to idle
12:30:13 AM
Baie changed to playing
12:30:13 AM
Baie changed to idle
12:30:02 AM
Baie changed to playing
12:30:02 AM
Baie changed to idle
12:29:51 AM
Baie changed to playing
12:29:51 AM
Baie changed to idle
12:29:40 AM
Baie changed to playing
12:29:40 AM
Baie changed to idle
12:29:29 AM
Baie changed to playing
12:29:29 AM
Baie changed to idle
12:29:26 AM
Baie changed to playing
12:29:26 AM
============>>>>>Bucatarie changed to idle

I’ll take a look, thanks.

I see no issues at me. Please post your config.
Edit: nevermind, found the issue. Grab the file again.

Have we switched to master branch?

Edit: grabbed all the files from master. The logbook is ok.

Edit2: after disconnecting the slave, the playback on slave is stopped, but the icon shows like it is playing.

Snaphot & restore seems to work ok, but the volume is not snapshoted/restored.

How about tts? No sound on speakers. No file created in tts folder.

As stated in the readme, snapshot currently only stores input source.

Volume is problematic, because Linkplay module stores volume levels separately for different input types, so if you change volume before playing TTS, you’re actually changing the volume of the current source not the volume of the source where TTS will play. That’s why snapshotting with the volume needs a different approach.

I have TTS sound on speakers. I don’t know about tts files, all I have is activated google TTS, restarted HA and TTS text input appeared automatically in lovelace properties of the media player. And it plays.
It has issues that while Linkplay module finishes changing input source to TTS stream, half of the message is gone, but this is problematic with other platforms aswell, so I will think of a different approach here too. Perhaps combined with the volume speciality as above.

There was something wrong in my configuration.
TTS is working.

OK check out the master branch again. Major change is that you have to remove from config the unavailable_message: option as I switched to using Home Assistant’s built-in availability state flag, which makes availability display equal to the other components. You’ll have to first remove entire config and replace the component, restart HA, add back the corrected config and restart again.
Make sure you update all the files!

Snaphot & restore includes volume, source input and player state attribute. Snapshot actually prepares the unit for TTS so stops playback in advance - this also to handle the gap biting the first words of TTS (present at many other similar speaker integrations). Check the readme and the service descriptions.
(currently only tested with web streams and physical inputs).

Removed player name change when playing web streams, started to get confusing and it’s not needed with mini-media-player card since implementing streams as sources.

Ok, will test tonight.

Fixed files playback status and handling from USB stick.

Something not good…
No speaker on lovelace after restart.

Log Details (ERROR)
Logger: homeassistant.components.media_player
Source: custom_components/linkplay/media_player.py:164
Integration: Media player (documentation, issues)
First occurred: 11:26:05 PM (2 occurrences)
Last logged: 11:26:05 PM

Error while setting up linkplay platform for media_player
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 178, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/linkplay/media_player.py", line 164, in setup_platform
    mac_address = resp_json['STA_MAC']
KeyError: 'STA_MAC'

OK hold on. Again issue caused by old firmware. No problem.
This was an experiment to assign unique IDs based on devices mac address within HA. Not really needed actually, so removing this approach for now. Looks like your device doesn’t report a mac address at the key I was expecting, disregard. Not important.