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
74k stars 31.05k forks source link

Unable to install ZWave integration on Raspberry Pi 4 with Aeotec Z-Stick 700 #78988

Closed TangoOversway closed 2 years ago

TangoOversway commented 2 years ago

The problem

Systems involved: Raspberry Pi4 and Aeotec Z-Stick 700. (Same equipment on 2 systems.) I used 32GB SDCards and USB memory sticks for the HA images. I ran tests using both, in case extra use of a USB connector or device-dependent speed was an issue.

On both systems I did the same thing: I had a working version of HA on them, with the ZWave integration fully working. I removed the SD Card or USB memory stick and rebooted with Home Assistant on a SD card or on a USB stick. I did many tests, using HA 8.5 for most, but also 8.1 and 9.0. Even though HA had no problem adding my Z-Stick on the pervious versions I had been running, on the new versions (the ones listed a sentence ago), could not install the ZWave integration successfully.

I finally installed ZWaveJS2MQTT and got it working by bypassing ZWaveJS, but there was no way I could get it to install using ZWaveJS. I have since upgraded my older versions of HA, the ones where ZWave was working. They’re okay, so the issue is in setup and install, not in continued use.

In all the variations I tried, the log always gave me the same stack trace, included below.

I have been told this looks like an issue in USB discovery. (Logs included as log info in details.)

What version of Home Assistant Core has the issue?

8.1, 8.5, 9.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

ZWave

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2022-09-17 17:22:13.917 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
resp = await request_handler(request)
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.10/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 60, 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 82, 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 136, in handle
result = await result
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 169, in get
return await super().get(request, flow_id)
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 96, in get
result = await self._flow_mgr.async_configure(flow_id)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 280, in async_configure
result = await self._async_handle_step(
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
result: FlowResult = await getattr(flow, method)(user_input)
File "/usr/src/homeassistant/homeassistant/components/zwave_js/config_flow.py", line 609, in async_step_configure_addon
ports = await async_get_usb_ports(self.hass)
File "/usr/src/homeassistant/homeassistant/components/zwave_js/config_flow.py", line 144, in async_get_usb_ports
return await hass.async_add_executor_job(get_usb_ports)
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/homeassistant/components/zwave_js/config_flow.py", line 128, in get_usb_ports
usb_device = usb.usb_device_from_port(port)
File "/usr/src/homeassistant/homeassistant/components/usb/utils.py", line 13, in usb_device_from_port
vid=f"{hex(port.vid)[2:]:0>4}".upper(),
TypeError: 'NoneType' object cannot be interpreted as an integer

Additional information

No response

homeassistant commented 2 years ago

Hey there @home-assistant/z-wave, mind taking a look at this issue as it has been labeled with an integration (zwave_js) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)


zwave_js documentation zwave_js source (message by IssueLinks)

MegaMattMiller commented 2 years ago

I'm having the same issue as above. Same Pi 4 and same Z-Wave USB stick. When adding the Z-Wave integration, after checking the box to install the supervisor add-on and clicking next, I get the following error in the logs. This is a fresh install of Home Assistant from https://github.com/home-assistant/operating-system/releases/download/9.0/haos_rpi4-64-9.0.img.xz on a Raspberry Pi 4, 64 bit. This was working previously before my ancient Micro SD card died Monday.

Logger: aiohttp.server
Source: components/usb/utils.py:13
First occurred: 11:16:44 AM (2 occurrences)
Last logged: 11:17:10 AM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/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 60, 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 82, 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 136, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 178, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 73, 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 280, in async_configure
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/usr/src/homeassistant/homeassistant/components/zwave_js/config_flow.py", line 550, in async_step_on_supervisor
    return await self.async_step_configure_addon()
  File "/usr/src/homeassistant/homeassistant/components/zwave_js/config_flow.py", line 609, in async_step_configure_addon
    ports = await async_get_usb_ports(self.hass)
  File "/usr/src/homeassistant/homeassistant/components/zwave_js/config_flow.py", line 144, in async_get_usb_ports
    return await hass.async_add_executor_job(get_usb_ports)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/zwave_js/config_flow.py", line 128, in get_usb_ports
    usb_device = usb.usb_device_from_port(port)
  File "/usr/src/homeassistant/homeassistant/components/usb/utils.py", line 13, in usb_device_from_port
    vid=f"{hex(port.vid)[2:]:0>4}".upper(),
TypeError: 'NoneType' object cannot be interpreted as an integer

Screenshot 2022-09-28 112146

MegaMattMiller commented 2 years ago

Looking at the logs more, this appears to be an issue in usb_device_from_port in utils.py in HomeAssistant itself @homeassistant

TangoOversway commented 2 years ago

Try re-interviewing the device with driver debug logging active in a separate window.

https://www.home-assistant.io/integrations/zwave_js/#how-to-access-the-z-wave-logs

Similar issue: #78419

Lesser experience HA user here - is this different than just using logging to a file? And when you say "driver," do you mean ZWaveJS? The integration itself? Where is the actual driver in HA?

MartinHjelmare commented 2 years ago

Sorry, that comment was meant for another issue.

MartinHjelmare commented 2 years ago

Seems like one of the USB port properties, port.vid isn't returning data as expected, when enumerating the ports.

TangoOversway commented 2 years ago

Seems like one of the USB port properties, port.vid isn't returning data as expected, when enumerating the ports.

Considering that there was no problem earlier in the summer (speaking from the Northern Hemisphere) when I set up one system, it seems like it must be recent. Beyond that, I don't know stats for HA, or many people run it on a Pi, or how many a month set up a new system on a Pi. It seems to me it might be a specific error related to the combination of the Pi and this particular USB stick. I might be way off on that, but I would think if more people were seeing it, there would be more posts on the forum about it and when I brought it up, nobody was sure just what it was, indicating to me I was the first to bring it up.

MegaMattMiller commented 2 years ago

Got some time to do more troubleshooting. I uninstalled the Z-Wave JS add-on. Reinstalled it, started it, then selected the proper USB port in the Z-Wave JS configuration. After that, when I went to add the Z-Wave integration, it finally let me set it up properly. @TangoOversway this might work for you.

TangoOversway commented 2 years ago

Reinstalled it, started it, then selected the proper USB port in the Z-Wave JS configuration. After that, when I went to add the Z-Wave integration, it finally let me set it up properly. @TangoOversway this might work for you.

I tried that early on - and I used the long name for the device, the one in the by-id tree to be sure it was connecting to the right device.

But, in terms of troubleshooting, I'm busy for the next few days. After that, if you give me a list of things to try, I can them. I'll even try this one you specified again. I remember trying it, seeing it fail, going into ZWaveJS (which was there after the 1st attempt at the integration install), editing the settings (including specifying the proper device), and trying again. If I read it right, that's what you did, right?

Also, there have been, I think, 2 updates to ZWaveJS since I filed this. I don't know if they'd interact with this. But I don't know if the Python script that is crashing has had any updates and it seems to me that should be looked into so it can report that error properly, and clearly enough so people know what to fix.

Codel1417 commented 2 years ago

Encountering on 2022.10 with both the Z-Wave and Zigbee Integration. For ZWave I used the workaround of setting up the addon first

wpi4pi4 commented 2 years ago

Raspberry Pi 4 Home Assistant 2022.10.1 Supervisor 2022.09.1 Operating System 9.0 Frontend 20221006.0 - latest

User clicked Settings -> Devices & Services -> Add Integration -> Z-Wave (use the Z-Wave JS Supervisor add-on is checked)

Expected integration success message but instead saw this error: Logger: aiohttp.server Source: components/usb/utils.py:13 First occurred: 9:07:49 PM (21 occurrences) Last logged: 9:25:10 PM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/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 60, 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 82, 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 136, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 180, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 73, 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 280, in async_configure
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/usr/src/homeassistant/homeassistant/components/zwave_js/config_flow.py", line 550, in async_step_on_supervisor
    return await self.async_step_configure_addon()
  File "/usr/src/homeassistant/homeassistant/components/zwave_js/config_flow.py", line 609, in async_step_configure_addon
    ports = await async_get_usb_ports(self.hass)
  File "/usr/src/homeassistant/homeassistant/components/zwave_js/config_flow.py", line 144, in async_get_usb_ports
    return await hass.async_add_executor_job(get_usb_ports)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/zwave_js/config_flow.py", line 128, in get_usb_ports
    usb_device = usb.usb_device_from_port(port)
  File "/usr/src/homeassistant/homeassistant/components/usb/utils.py", line 13, in usb_device_from_port
    vid=f"{hex(port.vid)[2:]:0>4}".upper(),
TypeError: 'NoneType' object cannot be interpreted as an integer
Alan-Guggenheim commented 2 years ago

Same problem.

vpathuis commented 2 years ago

I stumbled onto this problem using the usb component for another integration. I can confirm this is a problem in the usb_device_from_port function. It tries to make a pretty name with vid, but it scans available ports and if one of the ports (not necessarilly the usb stick) returns no vid, it fails, crashing the entire config flow.

In my case (also Pi4), its this port that has no vid: /dev/ttyAMA0

A simpel if port.vid: before calling usb_device_from_port prevents this, but this should be solved within usb_device_from_port.