LinkPlay Integration

Pushed an update with a workaround.

Hi,

Where do i put this:

- service: linkplay.join
  data:
    entity_id: media_player.sound_room2
    master: media_player.sound_room1
- service: linkplay.unjoin
  data:
    entity_id: media_player.sound_room1

in configuration.yaml or ???

BR. Cristi

These are service calls. You put them into the configuration of the action section of your automations.

If you’re a beginner, you should try using kalkih/mini-media-player (installable from HACS). There you don’t need any service calls to define manually, you just have to show speaker management groups in Lovelace, and it does all the thing for you.

@robi

I try service call in automation and work great.

Thank you.

How do I use the updaye tool? My Audiocasts are at version 3.8.something. I’ve tried customer service but they seem pretty useless.

Which Audiocast model? The M5 is at v4.2.8230. You can trigger update with the Android app (4Stream), it will display a red “new” icon when a new update is found. Click on it and the player will download the appropriate file automatically.

Question - I’m not having any luck getting Spotify media information to show up in the Mini Media Player card. I’m using Spotify on my phone, casted to a speaker using linkplay. All other functionality works.

Linkplay configuration:

media_player:
    - platform: linkplay
      host: 192.168.80.21
      name: Linkplay Living Room
#      icecast_metadata: 'StationNameSongTitle'      
      sources: 
        {
          'wifi': 'WiFi', 
        }

Mini Media Player Card YAML:

    artwork: cover
    entity: media_player.linkplay_living_room
    name: Living Room
    speaker_group:
      entities:
        - entity_id: media_player.linkplay_living_room
          name: Living Room
        - entity_id: media_player.linkplay_den
          name: Den
        - entity_id: media_player.linkplay_patio
          name: Patio
        - entity_id: media_player.linkplay_bathroom
          name: Bathroom
      expanded: false
      platform: linkplay
    toggle_power: false
    type: 'custom:mini-media-player'

Screenshot_20200917_151450

Looking at filter attributes in developer tools, I don’t see any metadata:

sound_mode_list: Classic, Jazz, Normal, Pop, Vocal
volume_level: 0.9
is_volume_muted: false
media_content_type: music
sound_mode: Normal
shuffle: false
linkplay_group: 
master: false
slave: false
firmware: 4.2.7717
device_class: speaker
debug_info: _playing_liveinput
friendly_name: Living Room
icon: mdi:speaker
supported_features: 68108

Thanks for any help or insight you can provide.

They’re M5s. For some reason I’m not getting the icon showing up on the app though.

I assume your Linkplay device is so old, that it doesn’t even publish info about its firmware version???

Please post results of the following, while your speaker is playing from Spotify:

http://spe.ak.er.ip/httpapi.asp?command=getStatusEx
http://spe.ak.er.ip/httpapi.asp?command=getPlayerStatus

What app do you use?

Started working to add support for the new media source feature in Home Assistant.
With it, it will be possible to natively access music files on a USB stick in a Linkplay device from Home Assistant.
(it is already possible through an input select and 3 automations, but the new media source way looks way better)

Hi @robi,

So sorry! I copied filter attribute info from another linkplay device that is not always on (bathroom), my apologies. I have updated my original post that has the correct info.

FYI my linkplays in the Den and Living Room are exactly the same and their configuration is the same.

Please post results of the following, while your speaker is playing from Spotify: http://spe.ak.er.ip/httpapi.asp?command=getStatusEx

{ "language": "en_us", "ssid": "LinkPlayA31_5AD4", "hideSSID": "1", "SSIDStrategy": "1", "firmware": "4.2.7717", "build": "release", "project": "a31imuzobox", "priv_prj": "a31imuzobox", "Release": "20191217", "branch": "stable\/wiimu-4.2", "group": "0", "expired": "0", "internet": "1", "uuid": "XXXXXXXXXX", "MAC": "XXXXXXXXXX", "STA_MAC": "XXXXXXXXX", "CountryCode": "CN", "CountryRegion": "1", "date": "2020:09:18", "time": "11:53:30", "tz": "-5.000000", "dst_enable": "1", "netstat": "2", "essid": "626C61636B62657474795F756E74727573746564", "apcli0": "XXXXXXXX", "eth2": "XXXXXXXXXXXXX", "hardware": "A31", "VersionUpdate": "0", "NewVer": "0", "mcu_ver": "0", "mcu_ver_new": "0", "dsp_ver_new": "0", "ra0": "10.10.10.254", "temp_uuid": "10747CBD7214AF91", "cap1": "0x500", "capability": "0x600080", "languages": "0x6", "dsp_ver": "0", "streams_all": "0x7ffffffe", "streams": "0x7ffffffe", "region": "unknown", "external": "0x0", "preset_key": "6", "plm_support": "0x0", "spotify_active": "1", "lbc_support": "0", "WifiChannel": "1", "RSSI": "-44", "battery": "0", "battery_percent": "0", "securemode": "1", "auth": "WPAPSKWPA2PSK", "encry": "AES", "psk": "XXXXXXXXX", "iot_ver": "1.0.0", "upnp_version": "1005", "upnp_uuid": "uuid:XXXXXXXXXXXXXX", "uart_pass_port": "8899", "communication_port": "8819", "web_firmware_update_hide": "0", "web_login_result": "-1", "ignore_talkstart": "0", "silenceOTATime": "", "ignore_silenceOTATime": "1", "iheartradio_new": "1", "security": "https\/2.0", "security_version": "2.0", "privacy_mode": "0", "user1": "278:524", "user2": "5959:6291", "DeviceName": "Den", "GroupName": "Den" }

Please post results of the following, while your speaker is playing from Spotify: http://spe.ak.er.ip/httpapi.asp?command=getPlayerStatus

{"type":"0","ch":"0","mode":"31","loop":"4","eq":"0","status":"play","curpos":"913503","offset_pts":"0","totlen":"1156049","Title":"556E6B6E6F776E","Artist":"556E6B6E6F776E","Album":"556E6B6E6F776E","alarmflag":"0","plicount":"0","plicurr":"0","vol":"100","mute":"0","iuri":"","uri":""}

I see no problem. Could it be perhaps that your Home Assistant and the audio players are not on the same network?
Metadata from Spotify is gathered by HA via UPnP protocol, from the Linkplays, they have to be on the same network with HA.
More and more functionality will be migrated to UPnP as time goes on.

Also: how do you exactly cast your spotify to Linkplay?

That is possible. I have the linkplay devices on a separate VLAN, however I have multicast DNS set up for the devices to be discoverable across separate networks.

There are two ways I can cast from spotify to linkplay. What I have been doing recently is loading Spotify app on my phone, selecting a playlist on the phone, and then selecting the linkplay device as the output (sort of bypassing HA, and only using HA for linkplay groupings and pause/play/next song controls).

Yesterday I set up the spotify HA integration, so I can now control spotify 99% from HA, including selecting the linkplay output. A couple screenshots are below. My ultimate goal is to be able to use HA app exclusively for media control.

Screenshot_20200918_083734

Screenshot_20200918_083759

As far as I read through how Spotify works, you cannot exclude their official app when you want to cast playback to another device (Spotify Premium feature) because the authentication and authorization between you and Spotify servers are done exclusively by the app, and when you select from within their app your Linkplays speaker, it only gets a temporary authentication passed over by the app to the speaker, so the speaker is able to download contents directly without the app. And thus the linkplay speaker is able to forward metadata via UPnP to Home Assistant.

If App disappears from this environment, after a while Linkplay’s authorization will expire and app is needed again to activate it. This is how Spotify works and it’s their intention to make users hard to exclude their official apps.
I also tried HA’s Spotify integration but I’ve found it to be limited in usage and it cannot replace the official app just because of the above. It will behave pretty much like another Linkplay device - in regards to the Spotify API. You still need Spotify’s official app to use HA’s Spotify integration nevertheless.

Yeah I understand… like I said that’s my ultimate goal is to control media fully through HA. Maybe there’s another service that will work better to get me to that goal in the future besides Spotify, I just haven’t had the time to dig into it.

One thing I will mention is that you may want to check out the Spotify HA integration again, there were just some major updates in 0.115 with the media player functionality that make it much more usable.

Just to be clear - even though I have mDNS working, UPnP metadata will not work across VLANs? So there is no fix for this?

Well that depends on how your routing between VLANs is set up. It’s not enough to just enable mDNS forwarding between them, you also have to create allow rules on the router’s firewall for normal traffic to also pass through between the hosts. mDNS is just for announcing and discovery, real data is transferred clasically via HTTP of whatever is required by the services.

Ah yes, again you’re correct. I have allow rules for HA to have full access to devices on the IOT VLAN and also for the media players’ IP to access HA IP so it should work.

While playing, I’m taking a look at the filter attributes of the device and I see certain attributes updating, such as media duration and media position. Are those also UPnP? Should I be seeing album/artist/song metadata as filter attributes for the linkplay device in HA?

I’ve tried the AudioCast, iEast and 4stream apps.

What do you mean by “filter attributes”?