Just verified.
The error is gone with the above modification plus the one made by me:
if (
self.device.last_seen
and (dt_util.utcnow()
- dt_util.utc_from_timestamp(float(self.device.last_seen))
) < detection_time):
return True
return False
But now, there is another error
2019-08-06 10:47:07 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 399, in _async_add_entity
await entity.async_update_ha_state()
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 286, in _async_write_ha_state
attr.update(self.device_state_attributes or {})
File "/usr/src/homeassistant/homeassistant/components/unifi/device_tracker.py", line 342, in device_state_attributes
attributes["upgradable"] = self.device.upgradable
File "/usr/local/lib/python3.7/site-packages/aiounifi/devices.py", line 101, in upgradable
return self.raw['upgradable']
KeyError: 'upgradable'
It seems that if all the devices are Online at Home Assistant startup, the error doesnât show up. But, if one of the devices goes offline, the last error appears again and it goes when the device is online againâŚ
I can reproduce this by disconnecting one of the APs.
Also, if the AP was online at HA start, when it goes offline it appears as âAwayâ instead of âUnavailableâ.
I think there should be a check if the device is Ubiquity AP, SW, Router, etc, it shouldnât be tracked, or the property âstateâ should be used to mark the device Available/Unavailable
Unfortunately, the error is still present when there is a device that have a value for âlast_seenâ, but itâs offline in the controller ('state': 0)âŚ
Here is the error:
2019-08-07 11:21:23 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 254, in async_update_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 286, in _async_write_ha_state
attr.update(self.device_state_attributes or {})
File "/usr/src/homeassistant/homeassistant/components/unifi/device_tracker.py", line 344, in device_state_attributes
attributes["upgradable"] = self.device.upgradable
File "/usr/local/lib/python3.7/site-packages/aiounifi/devices.py", line 101, in upgradable
return self.raw['upgradable']
KeyError: 'upgradable'
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 286, in _async_write_ha_state
attr.update(self.device_state_attributes or {})
File "/usr/src/homeassistant/homeassistant/components/unifi/device_tracker.py", line 344, in device_state_attributes
attributes["upgradable"] = self.device.upgradable
File "/usr/local/lib/python3.7/site-packages/aiounifi/devices.py", line 101, in upgradable
return self.raw['upgradable']
KeyError: 'upgradable'
You can easily reproduce this by unplugging an access point and wait untill it appears âDisconnectedâ in Unifi Controller.
As soon as it appears âDisconnectedâ, the error pops out in the logs.
When you plug it back in, as soon as itâs available in Unifi Controller, the error disappears.
2019-10-11 15:39:02 INFO (MainThread) [homeassistant.components.switch] Setting up switch.unifi
2019-10-11 15:39:02 ERROR (MainThread) [homeassistant.setup] Error during setup of component device_tracker
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/setup.py", line 167, in _async_setup_component
hass, processed_config
File "/usr/src/homeassistant/homeassistant/components/device_tracker/__init__.py", line 142, in async_setup
legacy_platforms = await setup.async_extract_config(hass, config)
File "/usr/src/homeassistant/homeassistant/components/device_tracker/setup.py", line 114, in async_extract_config
platform.name, platform.type
ValueError: Unable to determine type for unifi: None
I removed the ios and unifi from my configuration.yaml and everything is working again. Thank you very much. I guess I missed that in the release notes.
Robban write the this configutation is not supported anymore.
How did you change the configuration to get the device_tracker to work again?
Did you add any other configuration for Unifi ?