LinkPlay Integration

:joy: my wife would kill me if I would put more time in to home automation. We are expecting or third kid i a couple of weeks so computer time is a bit limited for a while. But I will think about it :wink:

1 Like

Hi

I tried connecting to my Linkplay wireless ceiling speakers with this plugin and getting the following error on the logs:

Update for media_player.kitchen_speakers fails

Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/urllib3/connection.py”, line 157, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw
File “/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py”, line 84, in create_connection
raise err
File “/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py”, line 74, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

I can connect to the speakers fine and get a json response:

http://my-ip/httpapi.asp?command=getStatus

{ “language”: “en_us”, “ssid”: “Wifi Speaker_5F10”, “hideSSID”: “0”, “firmware”: “3.6.4122”, “build”: “release”, “project”: “Lumi_WSP-6_A31”, “priv_prj”: “Lumi_WSP-6_A31”, “Release”: “20170222”, “group”: “0”, “expired”: “0”, “internet”: “1”, “uuid”: “FF31F01281534F88B617C394”, “MAC”: “removed”, “date”: “2020:01:21”, “time”: “16:38:16”, “netstat”: “2”, “essid”: “486F6D655F57696669”, “apcli0”: “ip-removed”, “eth2”: “0.0.0.0”, “hardware”: “A31”, “VersionUpdate”: “0”, “NewVer”: “0”, “mcu_ver”: “1611”, “mcu_ver_new”: “0”, “ra0”: “ip-removed”, “temp_uuid”: “CE407CCBF3E01539”, “cap1”: “0x0”, “capability”: “0x20680200”, “languages”: “0x6”, “dsp_ver”: “”, “streams_all”: “0xfffffff”, “streams”: “0xfffffff”, “region”: “unknown”, “external”: “0x0”, “preset_key”: “6”, “plm_support”: “0x2”, “WifiChannel”: “11”, “RSSI”: “-70”, “battery”: “0”, “battery_percent”: “0”, “securemode”: “1”, “auth”: “WPAPSKWPA2PSK”, “encry”: “AES”, “psk”: “removed”, “upnp_version”: “1004”, “upnp_uuid”: “uuid:FF31F012-8153-4F88-B617-C394FF31F012”, “uart_pass_port”: “8899”, “communication_port”: “8819”, “web_firmware_update_hide”: “0”, “privacy_mode”: “0”, “user1”: “278:524”, “user2”: “5959:6291”, “DeviceName”: “Kitchen Speakers”, “GroupName”: “Kitchen Speakers” }

The speakers work with any commands I’ve tried from here:

Any ideas where to go from here?
Thanks

Also seeing this in the logs if it helps:

Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 279, in async_update_ha_state
await self.async_device_update()
File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 461, in async_device_update
await self.hass.async_add_executor_job(self.update)
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 705, in update
lxml.etree.XMLSyntaxError):
NameError: name ‘lxml’ is not defined

It is more correct to send bugreports here:

I created a bugreport according to your information, but so far I can’t promise that I can solve the problem. I myself hardly understand this program…

Ok, thanks. I added additional log info to the bug report.

1 Like

Any idea why the linkplay media_player.device doesn’t get seen by Alexa as a device when exported by Homeassistant? I’d like to be able to control volume/playback by Alexa but it doesn’t seem to be discovered eventhough Homeassisant exports it as s speaker device with “Power,Speaker,StepSpeaker,Volume” etc. just like any other media_player which can be controlled by Alexa.

Edit: I figured this out. I customized the entity “mediaplayer.kitchen_speakers” and added “supported_features 56253” (the same as alexa in my kitchen) and once I did that Alexa finds the linkplay speakers and I can play/pause/control volume etc. of my linkplay speakers via Alexa now.

1 Like

I decided to radically modify a few things here&there in the code for myself, but didn’t want to mess with the original repo and pull requests one by one, so I’ve created my own fork:

Requires Home Assistant 0.110 or above.

A few new features:

  • Configurable input sources list, to match choices in HA with the pyhsical inputs available on each device
  • Configurable Icecast / Shoutcast webradio streams as additional input sources
  • Retrieval of current playing content metadata from Icecast / Shoutcast webradio streams and filenames on directly attached USB sticks, Tidal, Dezzer
  • Retrieval of coverart from last.fm service based on current playing content metadata from icecast or filenames
  • Multirooom in both WiFi-Direct and Router mode, using Sonos-like ‘join’ and ‘unjoin’ service calls.
  • Recall of music presets stored on the device
  • Snapshot and restore state of the player for smooth usage with TTS or alerts
  • Browsing and playing media files from the directly attached USB sticks through Lovelace UI
  • Linkplay-chipset specific commands through HA service calls
media_player:
    - platform: linkplay
      host: 192.168.1.11
      name: Sound Room1
      icecast_metadata: 'StationNameSongTitle'
      multiroom_wifidirect: False
      sources: 
        {
          'optical': 'TV sound', 
          'line-in': 'Radio tuner', 
          'bluetooth': 'Bluetooth',
          'udisk': 'USB stick'
          'http://94.199.183.186:8000/jazzy-soul.mp3': 'Jazzy Soul',
        }

    - platform: linkplay
      host: 192.168.1.12
      name: Sound Room2
      icecast_metadata: 'Off'  # valid values: 'Off', 'StationName', 'StationNameSongTitle'
      sources: {}

Note that this is heavily work in progress. Also this is not backwards-compatible with the previous linkplay integration. Read the documentation carefully.

1 Like

Added state icon handling.

Added possibility to add webradios (http-based streams) as input sources.

Much better multiroom now. As the current fimwares allow for connection through the existing network - no need for WiFidirect AP etc. changed integration to support that.
It’s now possible to make multiroom setup bewteen ethernet and wifi devices from different manufacturers.

Doing something wrong?
This is shown when checking configuration.

> Configuration invalid
> 
> Invalid config for [media_player.linkplay]: [icecast_metadata] is an invalid option for [media_player.linkplay]. Check: media_player.linkplay->icecast_metadata. (See ?, line ?).

are you using the integration from the link above? Or the one from hacs?

From the link above.

Can’t help without seeing your config.

This was used for testing:

    - platform: linkplay
      host: 192.168.0.151
      devicename: StreamBoxAlbastru
      name: Bucatarie
      icecast_metadata: 'StationNameSongTitle'
      unavailable_message: '<Indisponibil>'
      sources: 
        {
          'wifi': 'WiFi', 
          'optical': 'TV sound', 
          'line-in': 'Radio tuner', 
          'bluetooth': 'Bluetooth',
          'udisk': 'USB HDD',
          'http://94.199.183.186:8000/jazzy-soul.mp3': 'Jazzy Soul',
          'http://1.2.3.4:8000/your_radio': 'Your Radio',
          'http://icecast.streamserver.tld/mountpoint.aac': 'Another radio'
        }
1 Like

I think you’re still using the old integration.

  • make sure you really replaced the media_player.py with exactly this one
  • remove linkplay config completely
  • restart HA
  • add the config above
  • restart HA again.

Ok, done that and now there is no error when checking configuration.

But there is something in the logs:

Log Details (ERROR)
Logger: homeassistant.helpers.entity
Source: custom_components/linkplay/media_player.py:1086
First occurred: June 27, 2020, 11:52:41 PM (111 occurrences)
Last logged: 12:01:54 AM

Update for media_player.streamboxalbastru fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 472, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  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 1086, in update
    if player_status['uri'] != "":
KeyError: 'uri'

I remember I had the same error in the past: https://community.home-assistant.io/t/linkplay-integration/33878/26

What model is your player?
What app do you use to control from Android?

From the Android app, start playing a web radio (from vtuner).
While playing, visit the following status pages:
http://your.player.ip.address/httpapi.asp?command=getStatus
http://your.player.ip.address/httpapi.asp?command=getPlayerStatus
And post the results here to see what’s wrong.

The speaker is a Promate Streambox-L https://uae.souq.com/ae-en/promate-true-wireless-speaker-powerful-bluetooth-speaker-with-wifi-streaming-and-digital-internet-radio-built-in-mic-sd-card-slot-usb-input-and-aux-input-for-smartphones-tablets-mp3-and-mp4-streambox-l-blk-blu-22046599/i/

On the electronics inside it is written LinkPlay A31 https://fccid.io/2AAPP-A31/User-Manual/15-A31-UserMan-pdf-3034717

It can be controlled using https://github.com/AndersFluur/IEastMediaRoom

The app on Android is Audio Pro.

Made some modifications on media_player.py and it`s working good. Commented lines 1086, 1091 and 1092.
Metadata seems is not working.

getStatus:

{ "language": "en_us", "ssid": "StreamBoxAlb", "hideSSID": "0", "firmware": "3.5.4522", "build": "release", "project": "StreamBoxL", "priv_prj": "StreamBoxL", "Release": "20170622", "group": "0", "expired": "0", "internet": "1", "uuid": "FF31F00673311706E1F5A00C", "MAC": "00-22-6C-60-FD-FC", "date": "2020:06:28", "time": "10:11:02", "netstat": "2", "essid": "4169724E6574", "apcli0": "192.168.0.152", "eth2": "0.0.0.0", "hardware": "A31", "VersionUpdate": "0", "NewVer": "0", "mcu_ver": "120", "disable_mcu": "0", "mcu_ver_new": "0", "ra0": "10.10.10.254", "temp_uuid": "7460BC27C9808586", "cap1": "0x104200", "capability": "0x8002000", "languages": "0x6", "streams_all": "0x7ffffffe", "streams": "0x7ffffffe", "region": "unknown", "external": "0x0", "preset_key": "6", "plm_support": "0x0", "WifiChannel": "1", "RSSI": "-61", "battery": "0", "battery_percent": "0", "securemode": "0", "upnp_version": "1001", "uart_pass_port": "8899", "communication_port": "8819", "web_firmware_update_hide": "0", "user1": "303:524", "user2": "5160:6291", "DeviceName": "StreamBoxAlb", "GroupName": "StreamBoxAlb" }

getPlayerStatus:

{"type":"0","ch":"0","mode":"10","loop":"0","eq":"0","status":"play","curpos":"875005","totlen":"0","Title":"4142432052656C6178","Artist":"54756E65496E","Album":"","alarmflag":"0","plicount":"1","plicurr":"1","vol":"37","mute":"0"}

The reason for your errors is that the firmware on your unit is very old (v3.5.4522 from 2107.06). It is missing functionality required for metadata retrieval etc.

Try installing the app named 4STREAM from play store, and trigger a check for firmware update from there. Current 2020 versions are already at 4.2.8+…

Meanwhile i’ll try to add exceptions to the code to provide an error-less experience for older firmwares.

Could not trigger a firmware update. There is no option for this in 4STREAM.

Checked http://s000.linkplay.com:8020/wifi_audio_image_7688/ for an update by UUID, but there is nothing new for my UUID (FF31F006).
Are there any other sources for firmware upgrade? Could not find on Goole.

Try with:
/httpapi.asp?command=getMvRemoteUpdateStartCheck
Then
/httpapi.asp?command=getMvRemoteUpdateStart
Then
/httpapi.asp?command=getMvRemoteUpdateStatus