Limych / media_player.linkplay

Deprecated. Please, use https://github.com/nagyrobi/home-assistant-custom-components-linkplay
MIT License
31 stars 58 forks source link

Connection refused #15

Closed Limych closed 4 years ago

Limych commented 4 years ago

Source: https://community.home-assistant.io/t/linkplay-integration/33878/128?u=limych

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:

GitHub

AndersFluur/IEastMediaRoom The specification of the Sonoe IEast protocol translated from French and PDF. The protocol is also valid for receivers branded 'Roxcore' - AndersFluur/IEastMediaRoom

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

craggyh commented 4 years ago

Hi

I also see this in the logs when trying to pause/play etc.

'NoneType' object is not iterable Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 134, in handle_call_service connection.context(msg), File "/usr/src/homeassistant/homeassistant/core.py", line 1226, in async_call await asyncio.shield(self._execute_service(handler, service_call)) File "/usr/src/homeassistant/homeassistant/core.py", line 1251, in _execute_service await handler.func(service_call) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 201, in handle_service self._platforms.values(), func, call, service_name, required_features File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 335, in entity_service_call future.result() # pop exception if have File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 357, in _handle_service_platform_call await getattr(entity, func)(*data) 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 392, in media_pause for slave in self._slave_list: TypeError: 'NoneType' object is not iterable

craggyh commented 4 years ago

I see another log entry whi might shed some light

Update for media_player.kitchen_speakers fails

Traceback (most recent call last): File "/config/custom_components/linkplay/media_player.py", line 699, in update if upnpclient.Device(entry.location).friendly_name == \ File "/usr/local/lib/python3.7/site-packages/upnpclient/upnp.py", line 107, in init resp.raise_for_status() File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 940, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: http://10.10.50.174:49153/description0.xml

During handling of the above exception, another exception occurred:

The thing is that ip is not the ip of the speakers. I'm not sure where the component is getting it from as it's not in the config anywhere.

craggyh commented 4 years ago

I believe I've figured it out and can't believe it was so simple.

In configuration.yaml I had the host ip and device_name but didn't think I needed the name as well because I thought I read somewhere that the device_name is used as the name if it's not supplied. Once I added the name and rebooted the speakers came online and can be controlled properly. The state is updating fine too.

Sorry if my stupidity wasted your time.

Limych commented 4 years ago

Stop! But from this place in more detail, please.

If the error comes out, then this is an error. And it must be corrected so that others do not suffer.

What exactly did you do that the error disappeared? Please show what kind of config it was and what it became.

craggyh commented 4 years ago

Ok, so I've traced back all the steps I took and it turns out that it wasn't the addition of name: to the config that resolved the issue. It was actually removing the following from line 705 in media_player.py

lxml.etree.XMLSyntaxError):

and changing it to just

):

I'm not sure what that line does but removing it resolved the issue and doesn't seem to have any adverse effect (yet).

One thing I have noticed though is that some stations of Tunein radio don't show their cover artwork. Not sure how that info is gathered but it does show in the Smartonix App on my phone when selecting the station to play.

craggyh commented 4 years ago

So all was going fine for a couple of days then after a few reboots of homeassistant the component stopped working with the following error:

2020-01-29 20:27:07 ERROR (MainThread) [homeassistant.helpers.entity] Update for media_player.kitchen_speakers 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 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 699, in update if upnpclient.Device(entry.location).friendly_name == \ File "/usr/local/lib/python3.7/site-packages/upnpclient/upnp.py", line 109, in init root = etree.fromstring(resp.content) File "src/lxml/etree.pyx", line 3236, in lxml.etree.fromstring File "src/lxml/parser.pxi", line 1876, in lxml.etree._parseMemoryDocument File "src/lxml/parser.pxi", line 1764, in lxml.etree._parseDoc File "src/lxml/parser.pxi", line 1127, in lxml.etree._BaseParser._parseDoc File "src/lxml/parser.pxi", line 601, in lxml.etree._ParserContext._handleParseResultDoc File "src/lxml/parser.pxi", line 711, in lxml.etree._handleParseResult File "src/lxml/parser.pxi", line 640, in lxml.etree._raiseParseError File "", line 1 lxml.etree.XMLSyntaxError: Start tag expected, '<' not found, line 1, column 1

craggyh commented 4 years ago

I see there was an update to help fix the upnp errors. I updated and when I reboot hass I get continuous linkplay component errors where it’s trying to get upnp info from every upnp device on the network except the linkplay speakers. It’s not until I play something new on tunein or Spotify that the errors stop. The good news is that it does read the now playing status by upnp once I do this.

craggyh commented 4 years ago

Hi

Whenever I restart Homeassistant I get thousands of errors like this:

Error '404 Client Error: Not Found for url: http://10.10.50.26:8008/ssdp/notfound' for http://10.10.50.26:8008/ssdp/device-desc.xml

Error '401 Client Error: Unauthorized for url: http://10.10.50.13:49153/description0.xml' for http://10.10.50.13:49153/description0.xml

Error 'HTTPConnectionPool(host='10.10.50.189', port=60000): Max retries exceeded with url: /upnp/dev/5543d938-547d-568f-0000-00007119edb5/desc (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9f2faec210>: Failed to establish a new connection: [Errno 111] Connection refused'))' for http://10.10.50.189:60000/upnp/dev/5543d938-547d-568f-0000-00007119edb5/desc

It looks like the linkplay component is trying to connect to every media device on my network via upnp or ssdp except the actual linkplay speakers. It's only when I reboot the speakers that the component connects and the errors stop. If I don't restart the speakers the errors keep spamming the logs and I can't see any current playing media from the speakers but I can pause/resume and change volume.

smgt commented 4 years ago

The component uses upnp to lookup devices on the network. Upnp tries to figure out information about all devices on the network to find your configured device and this process does not always work. I will see if I can silence the output errors.

smgt commented 4 years ago

I've submitted a PR that will remove the log outputs from other UPNP devices on the network. #19