Unifi - Couldn't find key: 'None'

Have someone the same “issuse” ? Everytime i restart HA - i receive this error:

Hassio 0.99.2
i have two unifi AC and two switches (UniFi Switch 8 POE-60W)
the unifi Controller is a VM

Error in Log:

grafik

2019-09-21 13:41:47 ERROR (MainThread) [aiounifi.api] Couldn't find key: 'None'
2019-09-21 13:41:47 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 266, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 300, in _async_write_ha_state
    state = self.state
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 554, in state
    return STATE_ON if self.is_on else STATE_OFF
  File "/usr/src/homeassistant/homeassistant/components/unifi/switch.py", line 202, in is_on
    return self.port.poe_mode != "off"
  File "/usr/src/homeassistant/homeassistant/components/unifi/switch.py", line 249, in port
    return self.device.ports[self.client.sw_port]
AttributeError: 'NoneType' object has no attribute 'ports'

Yes…

Error doing job: Task exception was never retrieved
8:36 PM components/unifi/switch.py (ERROR) - message first occured at September 27, 2019, 1:26 AM and shows up 30290 times

Couldn’t find key: ‘None’
8:36 PM components/unifi/switch.py (ERROR) - message first occured at September 27, 2019, 1:26 AM and shows up 30290 times

I also have 10000s of these logs:

Oct  1 00:09:27 hassbian hass[13305]: 2019-10-01 00:09:27 ERROR (MainThread) [aiounifi.api] Couldn't find key: 'None'
Oct  1 00:09:27 hassbian hass[13305]: 2019-10-01 00:09:27 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never ret
rieved
Oct  1 00:09:27 hassbian hass[13305]: Traceback (most recent call last):
Oct  1 00:09:27 hassbian hass[13305]:   File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 266, in asy
nc_update_ha_state
Oct  1 00:09:27 hassbian hass[13305]:     self._async_write_ha_state()
Oct  1 00:09:27 hassbian hass[13305]:   File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 300, in _as
ync_write_ha_state
Oct  1 00:09:27 hassbian hass[13305]:     state = self.state
Oct  1 00:09:27 hassbian hass[13305]:   File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 554, in sta
te
Oct  1 00:09:27 hassbian hass[13305]:     return STATE_ON if self.is_on else STATE_OFF
Oct  1 00:09:27 hassbian hass[13305]:   File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/unifi/switch.py", line 20
2, in is_on
Oct  1 00:09:27 hassbian hass[13305]:     return self.port.poe_mode != "off"
Oct  1 00:09:27 hassbian hass[13305]:   File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/unifi/switch.py", line 24
9, in port
Oct  1 00:09:27 hassbian hass[13305]:     return self.device.ports[self.client.sw_port]
Oct  1 00:09:27 hassbian hass[13305]: AttributeError: 'NoneType' object has no attribute 'ports'

I’m hunting down the reasons for this situation. Have done some improvements for hass 0.100. Probable cause is unifi bug marking wireless devices as wired

Same over here. Started recently

I’m on 99.2 and get these errors as well.

Well we know that the issue exists on pre-0.100, Im mainly interested in seeing if my improvements have improved the situation :slight_smile:

Im still experiencing this on 100.2 :confused:

Look at the entities being switches from UniFi and remove those you know aren’t real in the entity registry

1 Like

Not 100% that I follow. I have had a couple of devices(not sure what it is tbh) mapped as Switches in HA. I went into the Configuration->Entity Registry and deleted each of them. The other devices, mapped as sensors in HA, i left unchanged (currently marked as unknow as there is no contact with the unifyctrl). The I rebooted HA - was that what you ment me to do?

1 Like

Exactly. So you still see the issue?

Yes, problems seem to be gone now :+1::+1: Thanks for your effort :slight_smile:

1 Like

Hi,
I had the same error with a "device_tracker.", I removed that from .storage/core.entity_registry (couldn’t remove it from the UI) but still seem to have some troubles with my Unifi integration.

Please have a look and see if you understand what’s wrong:
https://paste.ubuntu.com/p/mKSt7Y98wx/

Those logs are on switch as well. Are you running 0.100

Yes, 0.100.2 to be exact.

System Health
arch	x86_64
dev	false
docker	true
hassio	false
os_name	Linux
python_version	3.7.4
timezone	Europe/Helsinki
version	0.100.2
virtualenv	false

Removed the integration then reimplemented and the integration and the problem seems to be gone.
Hooray! - I can use my logs for troubleshooting again! :smiley:

Any recommendations for finding the troublesome entities?

My system has evolved so much over the last few years, I’m not sure which ones may be causing this issue.

I’m on .100.2 and I’ve got over 3000 instances of this error since my last reboot.

Go into the unifi config in gui and then you need to guess what switches are wrongfully created as poe control switches

Hi Robban

What do you mean with ‘wrongfully created as poe control switches’ ?

I am having the same issue, with the newest version of Home Assistant 0.101.2

Well… I haven’t gotten to the bottom of all possible issues, one situation I have improved is that there will be fewer wireless clients from UniFi marked as wired which could in some cases get created as POE control switches.

1 Like