elad-bar / ha-edgeos

Integration with EdgeOS (Ubiquiti)
133 stars 24 forks source link

Failed to extract Devices data, Error: 'NoneType' object has no attribute 'get', Line: 799 #105

Open rosstroha opened 1 year ago

rosstroha commented 1 year ago

What can I do to stop this error from showing up hundreds of times?

image
elad-bar commented 1 year ago

can you please provide debug log level to understand what led for that issue?

thanks

elad-bar commented 1 year ago

I will also need more details as the last release was 4 months ago, is it new issue? are you new user of that integration? what device are you using?

thanks

rosstroha commented 1 year ago

@elad-bar Hey sorry for not providing that information to begin with!

It's not a new issue. I think I've seen it around for a while, but just haven't asked about it.

Device: EdgeRouter X using EdgeOS 2.0.9-hotfix7

Contextual debug logs (I can provide more if needed)

2023-07-10 09:00:59.132 INFO (MainThread) [custom_components.edgeos.component.managers.home_assistant] API Status changed to Connected, WS Status: NotConnected
2023-07-10 09:00:59.226 DEBUG (SyncWorker_5) [custom_components.edgeos.component.managers.home_assistant] Loading entities
2023-07-10 09:01:01.657 DEBUG (SyncWorker_4) [custom_components.edgeos.component.managers.home_assistant] Loading entities
2023-07-10 09:01:01.678 DEBUG (MainThread) [custom_components.edgeos.component.api.api] Loading sys_info data
2023-07-10 09:01:01.711 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.frigate
2023-07-10 09:01:01.712 INFO (MainThread) [homeassistant.components.camera] Setting up camera.frigate
2023-07-10 09:01:01.713 INFO (MainThread) [homeassistant.components.number] Setting up number.frigate
2023-07-10 09:01:01.714 INFO (MainThread) [homeassistant.components.switch] Setting up switch.frigate
2023-07-10 09:01:01.715 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.frigate
2023-07-10 09:01:01.716 INFO (MainThread) [homeassistant.components.update] Setting up update.frigate
2023-07-10 09:01:01.760 DEBUG (MainThread) [custom_components.edgeos.component.api.api] Loading dhcp_stats data
2023-07-10 09:01:01.976 DEBUG (MainThread) [custom_components.edgeos.component.api.api] Loading dhcp-leases data
2023-07-10 09:01:02.249 DEBUG (MainThread) [custom_components.edgeos.component.managers.home_assistant] Extracting API Data
2023-07-10 09:01:02.249 INFO (MainThread) [custom_components.edgeos.component.managers.home_assistant] ['User hass level is operator, Interface status switch will not be created as it requires admin role']
2023-07-10 09:01:02.250 ERROR (MainThread) [custom_components.edgeos.component.managers.home_assistant] Failed to extract Devices data, Error: 'NoneType' object has no attribute 'get', Line: 799
2023-07-10 09:01:02.253 DEBUG (MainThread) [custom_components.edgeos.component.api.websocket] Initializing WebSocket connection
2023-07-10 09:01:02.253 INFO (MainThread) [custom_components.edgeos.core.api.base_api] Performing login
2023-07-10 09:01:02.253 INFO (MainThread) [custom_components.edgeos.component.managers.home_assistant] WS Status changed to Connecting, API Status: Connected
2023-07-10 09:01:02.256 INFO (MainThread) [custom_components.edgeos.component.managers.home_assistant] WS Status changed to Connected, API Status: Connected
2023-07-10 09:01:02.256 INFO (MainThread) [custom_components.edgeos.component.api.websocket] Starting to listen connected
2023-07-10 09:01:02.256 DEBUG (MainThread) [custom_components.edgeos.component.api.websocket] Subscription data to be sent: 164{"SUBSCRIBE":[{"name":"export"},{"name":"interfaces"},{"name":"system-stats"},{"name":"discover"}],"UNSUBSCRIBE":[],"SESSION_ID":"21dad6b0060a4b0d835a184fb69cfbba"}
2023-07-10 09:01:02.256 INFO (MainThread) [custom_components.edgeos.component.api.websocket] Subscribed to WS payloads
rosstroha commented 1 year ago

I think it's happening while extracting API data. The error seems to show up most often right before that log message

2023-07-10 09:04:00.340 DEBUG (MainThread) [custom_components.edgeos.component.managers.home_assistant] Extracting API Data
2023-07-10 09:04:00.340 ERROR (MainThread) [custom_components.edgeos.component.managers.home_assistant] Failed to extract Devices data, Error: 'NoneType' object has no attribute 'get', Line: 799
2023-07-10 09:04:00.439 DEBUG (SyncWorker_3) [custom_components.edgeos.component.managers.home_assistant] Loading entities
rosstroha commented 1 year ago

I think it's this line https://github.com/elad-bar/ha-edgeos/blob/62e66ac5d67d2704cd8d602db9b5f1f490ed8f1f/custom_components/edgeos/component/managers/home_assistant.py#L799

It seems to be an edge case where hostname or device name aren't configured in the router, maybe?

rosstroha commented 1 year ago

Hi @elad-bar have you had a chance to look into this?