Core: Unifi Switch Port Error

Created on 12 Aug 2019  路  29Comments  路  Source: home-assistant/core

Home Assistant release with the issue:

0.97.2

Last working Home Assistant release (if known):

Operating environment (Hass.io/Docker/Windows/etc.):

Hass.io VM

Component/platform:

https://www.home-assistant.io/components/unifi/#switch

Description of problem:

After installation of current 0.97.2 upgrade to resolve unifi "upgradeable" issue, the new switch issue appeared.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):


N/A - Unifi configured through Integration

Traceback (if applicable):

AttributeError: 'NoneType' object has no attribute 'ports'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 254, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 278, in _async_write_ha_state
    state = self.state
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 528, in state
    return STATE_ON if self.is_on else STATE_OFF
  File "/usr/src/homeassistant/homeassistant/components/unifi/switch.py", line 209, in is_on
    return self.port.poe_mode != "off"
  File "/usr/src/homeassistant/homeassistant/components/unifi/switch.py", line 256, in port
    return self.device.ports[self.client.sw_port]
AttributeError: 'NoneType' object has no attribute 'ports'
Connected

Additional information:
Cloud-hosted Unifi Controller.
Controller: 5.11.36
Switch FW: 4.0.49.10569

unifi

Most helpful comment

This issue seems to be back in 0.104:
Can't find this in breaking changes, so leaving a comment here.

2020-01-16 09:51:36 ERROR (MainThread) [aiounifi.api] Couldn't find key: 'None' 2020-01-16 09:51:36 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 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'

All 29 comments

Hey there @kane610, mind taking a look at this issue as its been labeled with a integration (unifi) you are listed as a codeowner for? Thanks!

I have the same problem I think

2019-08-19 22:14:58 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 254, in async_update_ha_state
    self._async_write_ha_state()
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 278, in _async_write_ha_state
    state = self.state
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 528, in state
    return STATE_ON if self.is_on else STATE_OFF
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/unifi/switch.py", line 209, in is_on
    return self.port.poe_mode != "off"
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/unifi/switch.py", line 256, in port
    return self.device.ports[self.client.sw_port]
AttributeError: 'NoneType' object has no attribute 'ports'

I have the same:

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 402, in _async_add_entity
    await entity.async_update_ha_state()
  File "/usr/src/app/homeassistant/helpers/entity.py", line 254, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/app/homeassistant/helpers/entity.py", line 278, in _async_write_ha_state
    state = self.state
  File "/usr/src/app/homeassistant/helpers/entity.py", line 528, in state
    return STATE_ON if self.is_on else STATE_OFF
  File "/usr/src/app/homeassistant/components/unifi/switch.py", line 209, in is_on
    return self.port.poe_mode != "off"
  File "/usr/src/app/homeassistant/components/unifi/switch.py", line 256, in port
    return self.device.ports[self.client.sw_port]
AttributeError: 'NoneType' object has no attribute 'ports'

Plus another error in this component:
Couldn't find key: 'None'

This seems to happen when something gets disconnected from the network, I'm investigating what can be the cause of this.

Hey guys! Anyone interested in verifying this fix in the betas starting later today?

Absolutely. I'll give it a go and report back.

So what you need to do is also to go into the entity registry and remove those POE control switches that are reporting that issue. The reason for this is that I think that a UniFi bug which causes wireless devices to show as wired devices triggers these faulty poe control switch entities

Apologies for the lack of updates鈥攂elieve it or not my USG failed on me and I'm waiting for a replacement... 馃檮

@aaronwolen too bad :/. Fortunately you don't need the USG to test this, only a controller and a POE switch

I'd be happy to help test...I too am seeing this error. You mention deleting the POE control switches in the entity registry. Can you help me understand which entities to delete? How do I identify them?

Any difference after 0.100?

Unfortunately, I've found the errors to be too inconsistent. Sometimes after a restart I don't get them. I didn't receive them on 0.100.2, but the device_tracker component is blowing up for Unifi, so I'm back to running 0.99.3 (my home automation relies heavily on presence).

Describe blowing up please :)

Thanks Kane610! Now that I have device_tracker working again, I'm not seeing these errors on 0.100.2.

Re: device_tracker: I still had it configured in YAML. Apparently I missed the breaking notes to remove it.

I still have this problem in 0.101.2

Log Details (ERROR)
Thu Nov 07 2019 15:17:01 GMT+0100 (Central European Standard Time)
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 275, in async_update_ha_state
    self._async_write_ha_state()
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 309, in _async_write_ha_state
    state = self.state
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 576, in state
    return STATE_ON if self.is_on else STATE_OFF
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/unifi/switch.py", line 204, in is_on
    return self.port.poe_mode != "off"
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/unifi/switch.py", line 249, in port
    return self.device.ports[self.client.sw_port]
AttributeError: 'NoneType' object has no attribute 'ports'

image

any updates on this? Still seeing it in the latest (0.102.3) release.

I have this on 0.102.3 on my unifi with 1 UniFi AP-nanoHD + UniFi AP-AC-LR + 1 UniFi Switch 8 POE-60W:

2019-12-08 21:40:11 ERROR (MainThread) [aiounifi.api Couldn't find key: 'None'
2019-12-08 21:40:11 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 275, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 309, in _async_write_ha_state
    state = self.state
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 576, in state
    return STATE_ON if self.is_on else STATE_OFF
  File "/usr/src/homeassistant/homeassistant/components/unifi/switch.py", line 204, 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'

This issue seems to be back in 0.104:
Can't find this in breaking changes, so leaving a comment here.

2020-01-16 09:51:36 ERROR (MainThread) [aiounifi.api] Couldn't find key: 'None' 2020-01-16 09:51:36 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 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'

+1 Seeing this behaviour on 104 also

+1 Seeing this behaviour on 104.3 also

+1 Seeing this behavior on 104.3 as well.

+1 seeing this. Can't start homeassistant, can't remove integration(through homeassistant UI)

+1 seeing the same - my indicates 34k times!

I'm seeing this in 105.2. Can't figure out how to turn it off in the logs either. homeassistant.components.unifi: fataldoes nothing - though maybe that's not the correct one.

+1 here... I also am experincing this. Can we re-open this or should I log a new one?

Started seeing it today as well. Over 2K times in the last few hours.

+1 on this issue for me

been happening for months now for me

@wbradmoore Your posted reminded me to share what has worked for me: Simply removing and re-adding the integration.

For whatever reason, it solved it for me.

Was this page helpful?
0 / 5 - 0 ratings