I think 0.104 broke the Unifi component

Hi all,

Today I upgraded to 0.104. This broke the Unifi integration for me. I dont see any breaking changes in the release notes but i’m getting this error since 0.104:

2020-01-16 15:16:36 ERROR (MainThread) [aiounifi.api] Couldn't find key: 'None'
2020-01-16 15:16:37 ERROR (MainThread) [aiounifi.api] Couldn't find key: 'None'
2020-01-16 15:16:37 ERROR (MainThread) [aiounifi.api] Couldn't find key: 'None'
2020-01-16 15:16:37 ERROR (MainThread) [aiounifi.api] Couldn't find key: 'None'
2020-01-16 15:16:37 ERROR (MainThread) [aiounifi.api] Couldn't find key: 'None'
2020-01-16 15:16:37 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 419, in _async_add_entity
    await entity.async_update_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 284, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state
    state = self.state
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 588, in state
    return STATE_ON if self.is_on else STATE_OFF
  File "/usr/src/homeassistant/homeassistant/components/unifi/switch.py", line 219, in is_on
    return self.port.poe_mode != "off"
  File "/usr/src/homeassistant/homeassistant/components/unifi/switch.py", line 264, in port
    return self.device.ports[self.client.sw_port]
AttributeError: 'NoneType' object has no attribute 'ports'

The error above is being spammed many times a minute.

This is my config:

configuration.yaml:

unifi: !include unifi.yaml

unifi.yaml

controllers:
  - host: 192.168.7.xxx
    site: My Site Name
    ssid_filter:
      - 'MySSID'

I hope someone can help me out.

Thanks in advance.

EDIT: Fix in the codeblock. It did not show the controllers property

you’re missing controllers

unifi: !include unifi.yaml
  controllers:
  - host: 192.168.7.xxx
    site: My Site Name
    ssid_filter:
      - 'MySSID'

Ah in my post I made a formatting error. The unifi file DOES have the controllers: on top. Does the Unifi component work for you?

I’m not on 0.104. But I switched to the UI configuration about 2 months ago.

I am running 0.104 and it is working as expected for me, my config is

#setting extra value in the unifi system to reduce tracking
unifi:
  controllers:
    - host: 192.168.0.7
      site: Default
      ssid_filter:
        - '┓┏凵=╱⊿┌┬┐'
      dont_track_clients: false
      dont_track_devices: true
      dont_track_wired_clients: true
      detection_time: 30

Yes that is my SSID :slight_smile:
I have this in my configuration.yaml

2 Likes

Ah, a man of good taste

I trust it’s free?

Well i just updated and i’m getting this error. I’ll see what fixes it

EDIT: looks like a bug. Has to do with the ‘switches’ for turning on and off ports on a unifi poe switch.

EDIT2: I just reinstalled the integration and the error went away.

EDIT3: I’m gonna write the issue up. Not sure what can be done seeing that the error goes away if you reinstall via ui. I’m guessing it loses track of the port number. Not sure.

So how do you reinstall this? You just remove it from config and add it to the Integrations under the “Configuration” tab?

I removed the integration and added it back. So in your case, you’d delete the configuration and add the integration.

This works! Thanks!

It’s a pity it doesn’t work from config anymore

I think it does. But not sure what you have to to do ‘reconfigure’ it. The whole situation is odd. It’s definitely a bug with stored data. I’m wondering if there’s information in .storage that is created and destroyed on configuring/unconfiguring.