core: Unifi direct error, Unifi does not return list of connected clients

The problem

Lots of errors are coming from the Ubiquiti UniFi AP component in my set up. Something is wrong in how the module operates.

image

It seems that the code logs into the UAP and processes the results of the mca-dump | tr -d “\n” command. I have 4 UAPs and dumped the JSON from each of them then tested the code used in the component. The following JSON output breaks the module.

{ "architecture": "mips", "board_rev": 17, "bootid": 1, "bootrom_version": "unifi-enlarge-buf.-1-g63fe9b5d-dirty", "cfgversion": "895fac54d8ea4d11", "connect_request_ip": "192.168.1.107", "connect_request_port": "36530", "default": false, "discovery_response": false, "dualboot": true, "hash_id": "019c47e264300b13", "hostname": "Garage", "inform_as_notif": true, "inform_url": "http://172.16.1.2:8080/inform", "ip": "192.168.1.107", "isolated": false, "kernel_version": "4.4.153", "locating": false, "mac": "78:8a:20:29:14:01", "manufacturer_id": 2, "model": "U7LR", "model_display": "UAP-AC-LR", "netmask": "255.255.255.0", "notif_payload": "", "notif_reason": "cmd", "required_version": "3.4.1", "selfrun_beacon": true, "serial": "788A20211111", "state": 2, "time": 1588757968, "time_ms": 2, "uptime": 9407959, "version": "4.0.80.10875"}

The module is expecting the command to return details of the connected devices. I suspect Unifi have issued a firmware update and this is no longer happening. Some of my devices return the correct data, some don’t, so this change might be related to the hardware revision perhaps.

The effect of this is that the device tracker no longer works / is no longer reliable. At my home I use the device tracker in automatons which sometimes didn’t fire. I suspect this is the case.

I’m not sure this component can be reliably fixed using the mca-dump command. At the very least raise a user readable error message at this point in the code https://github.com/home-assistant/core/blob/f1d3c0d19b4065a1f6ec80ecdc080380f728196c/homeassistant/components/unifi_direct/device_tracker.py#L126 if UNIFI_SSID_TABLE can’t be found.

Environment

arch | armv7l dev | false docker | false hassio | false os_name | Linux os_version | 4.19.97-v7+ python_version | 3.7.3 timezone | Europe/London version | 0.109.4 virtualenv | true

Affected and Unaffected is the same: 4.0.80.10875

  • Home Assistant Core release with the issue: 0.109.4
  • Last working Home Assistant Core release (if known): Unknown
  • Operating environment (Home Assistant/Supervised/Docker/venv): venv
  • Integration causing this issue: unifi_direct
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/unifi_direct/

Problem-relevant configuration.yaml

Traceback/Error logs

2020-05-06 10:15:45 ERROR (SyncWorker_1) [homeassistant.components.unifi_direct.device_tracker] Failed to decode response from AP.
2020-05-06 10:16:06 ERROR (SyncWorker_12) [homeassistant.components.unifi_direct.device_tracker] Failed to decode response from AP.
2020-05-06 10:16:06 ERROR (SyncWorker_7) [homeassistant.components.unifi_direct.device_tracker] Failed to decode response from AP.
2020-05-06 10:16:27 ERROR (SyncWorker_0) [homeassistant.components.unifi_direct.device_tracker] Failed to decode response from AP.
2020-05-06 10:16:48 ERROR (SyncWorker_5) [homeassistant.components.unifi_direct.device_tracker] Failed to decode response from AP.
2020-05-06 10:17:09 ERROR (SyncWorker_12) [homeassistant.components.unifi_direct.device_tracker] Failed to decode response from AP.
2020-05-06 10:17:09 ERROR (SyncWorker_2) [homeassistant.components.unifi_direct.device_tracker] Failed to decode response from AP.
2020-05-06 10:17:09 ERROR (SyncWorker_11) [homeassistant.components.unifi_direct.device_tracker] Failed to decode response from AP.
2020-05-06 10:17:51 ERROR (SyncWorker_3) [homeassistant.components.unifi_direct.device_tracker] Failed to decode response from AP.
2020-05-06 10:18:54 ERROR (SyncWorker_18) [homeassistant.components.unifi_direct.device_tracker] Failed to decode response from AP.
2020-05-06 10:18:54 ERROR (SyncWorker_14) [homeassistant.components.unifi_direct.device_tracker] Failed to decode response from AP.
2020-05-06 10:18:54 ERROR (SyncWorker_3) [homeassistant.components.unifi_direct.device_tracker] Failed to decode response from AP.
2020-05-06 10:19:15 ERROR (SyncWorker_13) [homeassistant.components.unifi_direct.device_tracker] Failed to decode response from AP.
2020-05-06 10:19:36 ERROR (SyncWorker_15) [homeassistant.components.unifi_direct.device_tracker] Failed to decode response from AP.
2020-05-06 10:19:36 ERROR (SyncWorker_8) [homeassistant.components.unifi_direct.device_tracker] Failed to decode response from AP.

Additional information

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 3
  • Comments: 55 (12 by maintainers)

Most upvoted comments

I’m having this issue as well. From the comment on the closed PR above it sounds like this will not be fixed until the integration is re-built based on an external library? Such an external library doesn’t seem to exist yet - all I can find interacts with the controller and not the APs themselves or am I missing something? It seems harsh to favor a broken integration over a properly integrated one, though.

FFS, is this the fix? Someone bothered to go out of their way to fix it and it wasn’t applied!

What a waste of everyone’s time.

I know that this will not be merged , because it needs refactoring. But why not merge this easy fix and keep users happy, until a new maintainer is found.

Please merge!

Verry disappointing that the PR is closed and that I have to change the official integration for a custom component. 😞

I can’t understand why the PR got closed. My workaround was to copy the unifi_direct component to my custom_components directory and apply the patch myself ( https://github.com/home-assistant/core/pull/36944/files ).

unifi_direct has been reworked in version 2024.1 please try now and let me know if you still have issues

With the official integration it will eventually break with the error specified in the first post. That’s one way you can tell

You have to go into your custom_components folder and run the git command there. I suggest to rename the cloned folder to unifi_direct so that you have .homeassistant/custom_components/unifi_direct/.

I made a repo, run the following and errors should go away. Thanks to @realthk and @lichtteil

cd .homeassistant
mkdir custom_components
git clone https://github.com/i-am-shodan/HomeAssistantUnifiDirect