core icon indicating copy to clipboard operation
core copied to clipboard

ZHA can not initalize

Open majkrzak opened this issue 3 years ago • 9 comments

The problem

After upgrading the home assistant to the latest version, zha fails to set up with following error.

Logger: homeassistant.config_entries
Source: components/zha/core/gateway.py:170
First occurred: 18:49:07 (1 occurrences)
Last logged: 18:49:07
Error setting up entry ttyAMA0, s/n: n/a for zha

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 357, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/zha/__init__.py", line 112, in async_setup_entry
    await zha_gateway.async_initialize()
  File "/usr/src/homeassistant/homeassistant/components/zha/core/gateway.py", line 170, in async_initialize
    self.application_controller = await app_controller_cls.new(
  File "/usr/local/lib/python3.10/site-packages/zigpy/application.py", line 118, in new
    await app.startup(auto_form=auto_form)
  File "/usr/local/lib/python3.10/site-packages/zigpy/application.py", line 66, in startup
    await self.connect()
  File "/usr/local/lib/python3.10/site-packages/zigpy_zigate/zigbee/application.py", line 39, in connect
    await api.set_raw_mode()
  File "/usr/local/lib/python3.10/site-packages/zigpy_zigate/api.py", line 409, in set_raw_mode
    await self.command(CommandId.SET_RAWMODE, data)
  File "/usr/local/lib/python3.10/site-packages/zigpy_zigate/api.py", line 373, in command
    raise NoStatusError()
zigpy_zigate.api.NoStatusError

What version of Home Assistant Core has the issue?

2022.8.2

What was the last working version of Home Assistant Core?

2022.6.5

What type of installation are you running?

Home Assistant OS

Integration causing the issue

zha

Link to integration documentation on our website

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

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

majkrzak avatar Aug 08 '22 16:08 majkrzak

zha documentation zha source (message by IssueLinks)

Hey there @dmulcahey, @adminiuga, @puddly, mind taking a look at this issue as it has been labeled with an integration (zha) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

What ZiGate are you running?

puddly avatar Aug 08 '22 17:08 puddly

What ZiGate are you running?

PiZiGate

majkrzak avatar Aug 08 '22 17:08 majkrzak

I see reverting the update is not solving the issue, neither do reconfiguration.

majkrzak avatar Aug 08 '22 17:08 majkrzak

You may need to install GPIO python module which is no longer included with HA Core container

Adminiuga avatar Aug 08 '22 19:08 Adminiuga

See #75755

Adminiuga avatar Aug 08 '22 19:08 Adminiuga

If reverting HA Core to 2022.6.5 doesn't solve the issue, it likely isn't a software problem. Can you try fully powering down the Pi, unplugging it from power for a few seconds, and then turning it back on, to ensure the PiZiGate completely reboots?

puddly avatar Aug 08 '22 21:08 puddly

I upgraded the os to 8.2 which seems not to get reverted by the snapshot.

majkrzak avatar Aug 09 '22 18:08 majkrzak

Traceback (most recent call last):
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.10/site-packages/zigpy_zigate/common.py", line 84, in set_pizigate_running_mode
gpio0 = UnclosableOutputDevice(pin=GPIO_PIN0, initial_state=None)
File "/usr/local/lib/python3.10/site-packages/gpiozero/devices.py", line 108, in __call__
self = super(GPIOMeta, cls).__call__(*args, **kwargs)
TypeError: UnclosableOutputDevice.__init__() got an unexpected keyword argument 'initial_state'

I see error like this after upgrading to the os 8.5 + core 2022.8.6

majkrzak avatar Aug 19 '22 17:08 majkrzak

FYI, upcoming Home Assistant Core release 2022.8.7 will contain an updated zigpy-zigate library with some changes for GPIO:

https://github.com/home-assistant/core/pull/77125

Bump ZHA dependencies:

  • zigpy from 0.49.1 to 0.50.2
  • zigpy-zigate from 0.9.1 to 0.9.2
  • zigpy-znp from 0.8.1 to 0.8.2
  • bellows from 0.32.0 to 0.33.1

https://github.com/zigpy/zigpy-zigate/releases/tag/0.9.2

Changes

  • 0.9.2 Release @puddly (https://github.com/zigpy/zigpy-zigate/pull/128)
  • Ensure disconnect can be called multiple times @puddly (https://github.com/zigpy/zigpy-zigate/pull/129)
  • Fix typo in GPIO pin configuration kwargs and add unit test @puddly (https://github.com/zigpy/zigpy-zigate/pull/127)

Hedda avatar Aug 25 '22 10:08 Hedda

Looks like it is fixing the issue. I will now reload backups and do some testing.

majkrzak avatar Aug 26 '22 12:08 majkrzak

Fixed on 2022.8.7

majkrzak avatar Aug 26 '22 13:08 majkrzak

Still having this ZHA issue in HAOS 8.5, HA Core 2022.8.7 running on a physical RasPI4B: image

2022-08-26 17:20:00.055 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Sonoff Zigbee 3.0 USB Dong - /dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_5e7f41984498ec1192a4acd044d80d13-if00-port0, s/n: 5e7f41984498ec1192a4acd044d80d13 - ITead - 10C4:EA60 for zha
File "/usr/src/homeassistant/homeassistant/components/zha/__init__.py", line 112, in async_setup_entry
await zha_gateway.async_initialize()
File "/usr/src/homeassistant/homeassistant/components/zha/core/gateway.py", line 170, in async_initialize

Tried restarting all, but I can't physically power-cycle the RasPI4B. Any hint? Thanks

PieBru avatar Aug 26 '22 15:08 PieBru

You are using a different adapter, not a zigate so it is a different issue. Replug your USB stick and post the full traceback

Adminiuga avatar Aug 26 '22 15:08 Adminiuga

Yes, I'm using a Sonoff Zigbee USB Dongle Plus 3.0, reflashed with the latest ZStack 3.x.0 coordinator. I'm on the C(++) side, but I'm ignorant on Python. How do you suggest to get the traceback on a HAOS system? Thanks, Piero

PieBru avatar Aug 26 '22 18:08 PieBru

If you're using a different adapter, please open a new issue. You can enable ZHA debug logging (https://www.home-assistant.io/integrations/zha/#debug-logging) to get a verbose traceback and possibly see what the problem may be.

puddly avatar Aug 26 '22 18:08 puddly

Done, thanks. https://github.com/home-assistant/core/issues/77382

PieBru avatar Aug 26 '22 18:08 PieBru