home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.7k stars 30.83k forks source link

'NoneType' object is not subscriptable #98227

Closed Unbeaten4350 closed 1 year ago

Unbeaten4350 commented 1 year ago

The problem

Netgear integration issues. Model: R7000. UPnP is enabled (UPnP integration finds the unit). Integration has previously worked. Worked on previous firmware and started having issues, so I updated firmware recently and worked again for a brief time, then began having issues again. Have confirmed login information is correct. I've deleted the integration and then added it through "+Add Integration" with no success (below pynetgear errors are from that), and I have also done it through auto-discovery with no success.

I have looked through whatever I could find in regards to the Netgear integration issues to see if anything would work for me, and nothing so far really has. (Also why I knew to go ahead and get logger information for you!)

Also, the ping sensor throws an error, I believe because of the inclusion of 'ms' in the value provided.

2023-08-10 19:36:46.375 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 181, in post
    return await super().post(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 296, in async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 392, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/netgear/config_flow.py", line 207, in async_step_user
    await self.async_set_unique_id(info["SerialNumber"], raise_on_progress=False)
                                   ~~~~^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

Netgear logger at debug level shows the following:

2023-08-10 19:57:38.591 DEBUG (MainThread) [homeassistant.components.netgear.config_flow] Netgear ssdp discovery info: SsdpServiceInfo(ssdp_usn='uuid:f1725800-001e-8b44-3667-9e095382117f::upnp:rootdevice', ssdp_st='upnp:rootdevice', upnp={'X_hardwareId': 'VEN_01f2&DEV_0016&REV_01 VEN_01f2&DEV_8000&SUBSYS_01&REV_01 VEN_01f2&DEV_8000&REV_01 VEN_0033&DEV_0008
&REV_01', 'X_deviceCategory': ['NetworkInfrastructure.Router', 'Network.Router.Wireless'], 'X_compatibleId': 'urn:schemas-upnp-org:device:InternetGatewayDevice:1', 'deviceType': 'urn:schemas-upnp-org:device:InternetGatewayDevice:1', 'friendlyName': 'R7000 (Gateway)', 'manufacturer': 'NETGEAR, Inc.', 'manufacturerURL': 'http://www.NETGEAR.com', 'modelDescri
ption': 'NETGEAR R7000 802.11ac Wireless Router', 'modelNumber': 'R7000', 'modelName': 'R7000', 'modelURL': 'http://www.netgear.com/home/products/networking/wifi-routers/R7000.aspx', 'serialNumber': '3LG4457TA07F4', 'UDN': 'uuid:f1725800-001e-8b44-3667-9e095382117f', 'iconList': {'icon': {'mimetype': 'image/x-icon', 'width': '64', 'height': '64', 'depth': 
'32', 'url': 'http://192.168.1.1/upnp.ico'}}, 'serviceList': {'service': {'serviceType': 'urn:schemas-upnp-org:service:Layer3Forwarding:1', 'serviceId': 'urn:upnp-org:serviceId:L3Forwarding1', 'SCPDURL': '/Public_UPNP_Layer3F.xml', 'controlURL': '/Public_UPNP_C1', 'eventSubURL': '/Public_UPNP_Event_1'}}, 'deviceList': {'device': {'deviceType': 'urn:schemas
-upnp-org:device:WANDevice:1', 'friendlyName': 'WAN Device', 'manufacturer': 'NETGEAR, Inc.', 'manufacturerURL': 'http://www.NETGEAR.com', 'modelDescription': 'NETGEAR R7000 802.11ac Wireless Router', 'modelNumber': 'R7000', 'modelName': 'R7000', 'modelURL': 'http://www.netgear.com/home/products/networking/wifi-routers/R7000.aspx', 'serialNumber': '3LG4457
TA07F4', 'UDN': 'uuid:f1725800-011e-8b44-3667-9e095382117f', 'iconList': {'icon': {'mimetype': 'image/x-icon', 'width': '64', 'height': '64', 'depth': '32', 'url': 'http://192.168.1.1/upnp.ico'}}, 'serviceList': {'service': {'serviceType': 'urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1', 'serviceId': 'urn:upnp-org:serviceId:WANCommonIFC1', 'SCPDU
RL': '/Public_UPNP_WAND.xml', 'controlURL': '/Public_UPNP_C2', 'eventSubURL': '/Public_UPNP_Event_2'}}, 'deviceList': {'device': {'deviceType': 'urn:schemas-upnp-org:device:WANConnectionDevice:1', 'friendlyName': 'WAN Connection Device', 'manufacturer': 'NETGEAR, Inc.', 'manufacturerURL': 'http://www.NETGEAR.com', 'modelDescription': 'NETGEAR R7000 802.11a
c Wireless Router', 'modelNumber': 'R7000', 'modelName': 'R7000', 'modelURL': 'http://www.netgear.com/home/products/networking/wifi-routers/R7000.aspx', 'serialNumber': '3LG4457TA07F4', 'UDN': 'uuid:f1725800-021e-8b44-3667-9e095382117f', 'iconList': {'icon': {'mimetype': 'image/x-icon', 'width': '64', 'height': '64', 'depth': '32', 'url': 'http://192.168.1
.1/upnp.ico'}}, 'serviceList': {'service': [{'serviceType': 'urn:schemas-upnp-org:service:WANEthernetLinkConfig:1', 'serviceId': 'urn:upnp-org:serviceId:WANEthLinkC1', 'SCPDURL': '/Public_UPNP_WANEtherLinkCfg.xml', 'controlURL': '/Public_UPNP_C4', 'eventSubURL': '/Public_UPNP_Event_4'}, {'serviceType': 'urn:schemas-upnp-org:service:WANIPConnection:1', 'ser
viceId': 'urn:upnp-org:serviceId:WANIPConn1', 'SCPDURL': '/Public_UPNP_WANIPConn.xml', 'controlURL': '/Public_UPNP_C3', 'eventSubURL': '/Public_UPNP_Event_3'}, {'serviceType': 'urn:schemas-upnp-org:service:WANPPPConnection:1', 'serviceId': 'urn:upnp-org:serviceId:WANPPPConn1', 'SCPDURL': '/Public_UPNP_WANPPPConn.xml', 'controlURL': '/Public_UPNP_C5', 'even
tSubURL': '/Public_UPNP_Event_5'}]}}}}}, 'presentationURL': 'http://www.routerlogin.net'}, ssdp_location='http://192.168.1.1:5000/Public_UPNP_gatedesc.xml', ssdp_nt='upnp:rootdevice', ssdp_udn='uuid:f1725800-001e-8b44-3667-9e095382117f', ssdp_ext=None, ssdp_server='Linux/2.6.12, UPnP/1.0, NETGEAR-UPNP/1.0', ssdp_headers={'HOST': '239.255.255.250:1900', 'CA
CHE-CONTROL': 'max-age=3600', 'LOCATION': 'http://192.168.1.1:5000/Public_UPNP_gatedesc.xml', 'NT': 'upnp:rootdevice', 'NTS': 'ssdp:alive', 'SERVER': 'Linux/2.6.12, UPnP/1.0, NETGEAR-UPNP/1.0', 'USN': 'uuid:f1725800-001e-8b44-3667-9e095382117f::upnp:rootdevice', '_timestamp': datetime.datetime(2023, 8, 10, 19, 57, 38, 589533), '_host': '192.168.1.1', '_por
t': 47323, '_local_addr': ('0.0.0.0', 1900), '_remote_addr': ('192.168.1.1', 47323), '_udn': 'uuid:f1725800-001e-8b44-3667-9e095382117f', '_location_original': 'http://192.168.1.1:5000/Public_UPNP_gatedesc.xml', 'location': 'http://192.168.1.1:5000/Public_UPNP_gatedesc.xml'}, x_homeassistant_matching_domains={'netgear'})

Pynetgear logger at debug level:

2023-08-10 19:36:45.835 DEBUG (SyncWorker_5) [pynetgear.router] Login v2, port '5555', ssl, 'True'                                                                                                                                                                                                                                                                    
2023-08-10 19:36:45.843 DEBUG (SyncWorker_5) [pynetgear.router] RequestException while logging in host 192.168.1.1:5555 ssl True: HTTPSConnectionPool(host='192.168.1.1', port=5555): Max retries exceeded with url: /soap/server_sa/ (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f5813fd50>: Failed to establish a new connection
: [Errno 111] Connection refused'))                                                                                                                                                                                                                                                                                                                                   
2023-08-10 19:36:45.844 DEBUG (SyncWorker_5) [pynetgear.router] Login v1, port '5555', ssl, 'True'                                                                                                                                                                                                                                                                    
2023-08-10 19:36:45.852 DEBUG (SyncWorker_5) [pynetgear.router] RequestException while logging in host 192.168.1.1:5555 ssl True: HTTPSConnectionPool(host='192.168.1.1', port=5555): Max retries exceeded with url: /soap/server_sa/ (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f58136090>: Failed to establish a new connection
: [Errno 111] Connection refused'))                                                                                                                                                                                                                                                                                                                                   
2023-08-10 19:36:45.852 DEBUG (SyncWorker_5) [pynetgear.router] Call GetInfo                                                                                                                                                                                                                                                                                          
2023-08-10 19:36:45.852 DEBUG (SyncWorker_5) [pynetgear.router] Login re-attempt within the login, ignoring.                                                                                                                                                                                                                                                          
2023-08-10 19:36:45.852 DEBUG (SyncWorker_5) [pynetgear.router] Could not successfully get GetInfo                                                                                                                                                                                                                                                                    
2023-08-10 19:36:45.852 DEBUG (SyncWorker_5) [pynetgear.router] Login v1, port '443', ssl, 'True'                                                                                                                                                                                                                                                                     
2023-08-10 19:36:45.857 DEBUG (SyncWorker_5) [pynetgear.router] RequestException while logging in host 192.168.1.1:443 ssl True: HTTPSConnectionPool(host='192.168.1.1', port=443): Max retries exceeded with url: /soap/server_sa/ (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f68a7cd50>: Failed to establish a new connection: 
[Errno 111] Connection refused'))                                                                                                                                                                                                                                                                                                                                     
2023-08-10 19:36:45.857 DEBUG (SyncWorker_5) [pynetgear.router] Call GetInfo                                                                                                                                                                                                                                                                                          
2023-08-10 19:36:45.857 DEBUG (SyncWorker_5) [pynetgear.router] Login re-attempt within the login, ignoring.                                                                                                                                                                                                                                                          
2023-08-10 19:36:45.857 DEBUG (SyncWorker_5) [pynetgear.router] Could not successfully get GetInfo                                                                                                                                                                                                                                                                    
2023-08-10 19:36:45.857 DEBUG (SyncWorker_5) [pynetgear.router] Login v2, port '443', ssl, 'True'                                                                                                                                                                                                                                                                     
2023-08-10 19:36:45.861 DEBUG (SyncWorker_5) [pynetgear.router] RequestException while logging in host 192.168.1.1:443 ssl True: HTTPSConnectionPool(host='192.168.1.1', port=443): Max retries exceeded with url: /soap/server_sa/ (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f4403bd90>: Failed to establish a new connection: 
[Errno 111] Connection refused'))                                                                                                                                                                                                                                                                                                                                     
2023-08-10 19:36:45.862 DEBUG (SyncWorker_5) [pynetgear.router] Login v2, port '5000', ssl, 'False'                                                                                                                                                                                                                                                                   
2023-08-10 19:36:45.909 INFO (SyncWorker_5) [pynetgear.router] Login succeeded using non default port '5000' and ssl 'False'.                                                                                                                                                                                                                                         
2023-08-10 19:36:45.911 DEBUG (SyncWorker_2) [pynetgear.router] Call GetInfo                                                                                                                                                                                                                                                                                          
2023-08-10 19:36:45.944 DEBUG (SyncWorker_2) [pynetgear.router] Unauthorized response, let's login and retry...                                                                                                                                                                                                                                                       
2023-08-10 19:36:45.945 DEBUG (SyncWorker_2) [pynetgear.router] Login v2, port '5000', ssl, 'False'                                                                                                                                                                                                                                                                   
2023-08-10 19:36:46.369 ERROR (SyncWorker_2) [pynetgear.router] Unauthorized response, re-login failed                                                                                                                                                                                                                                                                
2023-08-10 19:36:46.372 DEBUG (SyncWorker_2) [pynetgear.router] Could not successfully get GetInfo

Let me know what else I can help provide on this!

What version of Home Assistant Core has the issue?

core-2023.8.1

What was the last working version of Home Assistant Core?

core-2023.8.1

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Netgear

Link to integration documentation on our website

https://www.home-assistant.io/integrations/netgear/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 year ago

Hey there @hacf-fr, @quentame, @starkillerog, mind taking a look at this issue as it has been labeled with an integration (netgear) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `netgear` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign netgear` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


netgear documentation netgear source (message by IssueLinks)

starkillerOG commented 1 year ago

@Unbeaten4350 it is getting a Unauthorized response so it seems like the router is eather blocking the HomeAssistant IP because of too many attempts or something or the username/password is wrong. Are you sure you are using the correct password? Maybe try a simpler password if you are using special caracters which HomeAssistant might be struggeling with....

Did you already reboot the router?

B4dC4rd commented 1 year ago

I have a similar issue. The integration was working fine for months, but lately I noticed Failed Setup error in the integration and I have this message in the Log:

`Logger: homeassistant.components.netgear Source: components/netgear/router.py:181 Integration: NETGEAR (documentation, issues) First occurred: 21:35:32 (4 occurrences) Last logged: 21:37:53

Unexpected error fetching MR60 Devices data: 'NoneType' object has no attribute 'strip' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 283, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 242, in _async_update_data return await self.update_method() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/netgear/init.py", line 85, in async_update_devices return await router.async_update_device_trackers() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/netgear/router.py", line 193, in async_update_device_trackers ntg_devices = await self.async_get_attached_devices() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/netgear/router.py", line 181, in async_get_attached_devices return await self.hass.async_add_executor_job( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pynetgear/router.py", line 580, in get_attached_devices decoded = node.text.strip().replace( ^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'strip' `

I made no changes except updating HA I have MR60 Mesh system.

Maybe this more detailed bit helps:

AttributeError: 'NoneType' object has no attribute 'strip' 2023-08-14 22:42:17.717 DEBUG (SyncWorker_4) [pynetgear.router] Login v2, port '443', ssl, 'True' 2023-08-14 22:42:17.872 DEBUG (SyncWorker_4) [pynetgear.router] Call GetInfo 2023-08-14 22:42:17.962 DEBUG (SyncWorker_4) [homeassistant.components.netgear.router] Netgear track_devices = 'True', device mode '0' 2023-08-14 22:42:17.964 DEBUG (SyncWorker_3) [pynetgear.router] Get attached devices 2023-08-14 22:42:33.511 ERROR (MainThread) [homeassistant.components.netgear] Unexpected error fetching MR60 Devices data: 'NoneType' object has no attribute 'strip' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 283, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 242, in _async_update_data return await self.update_method() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/netgear/__init__.py", line 85, in async_update_devices return await router.async_update_device_trackers() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/netgear/router.py", line 193, in async_update_device_trackers ntg_devices = await self.async_get_attached_devices() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/netgear/router.py", line 181, in async_get_attached_devices return await self.hass.async_add_executor_job( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pynetgear/router.py", line 580, in get_attached_devices decoded = node.text.strip().replace( ^^^^^^^^^^^^^^^

Unbeaten4350 commented 1 year ago

@Unbeaten4350 it is getting a Unauthorized response so it seems like the router is eather blocking the HomeAssistant IP because of too many attempts or something or the username/password is wrong. Are you sure you are using the correct password? Maybe try a simpler password if you are using special caracters which HomeAssistant might be struggeling with....

Did you already reboot the router?

Hi @starkillerOG --

Confirmed password is correct, and is only alphanumeric (no special characters). Router was rebooted on every new attempt.

The final log above shows a success near the end amongst the failures; false negatives or...?

starkillerOG commented 1 year ago

@Unbeaten4350 yea the one success seems strange but once logged in, when sending the first request GetInfo it imediatly gives another Unauthorized response.....

starkillerOG commented 1 year ago

@B4dC4rd your issue schould be fixed by this commit: https://github.com/MatMaul/pynetgear/commit/9e75f43ca2a972f53535bd33f8025ff0b29cc9e6

starkillerOG commented 1 year ago

@B4dC4rd This PR will fix the issue in HomeAssistant: https://github.com/home-assistant/core/pull/100242, it is tagged to be part of HomeAssistant 2023.9.2 which will be released in 2 days.

starkillerOG commented 1 year ago

@B4dC4rd the PR has been merged just too late to make it into HA 2023.9.2, it will be included in HA 2023.9.3. Please let me know if the errors re-occur once you are on HA 2023.9.3.

If you appreciate the Netgear integration and want to support its development, please consider sponsering the upstream library.