vanviegen / hue-thief

Factory reset Philips Hue bulbs using an EZSP-based Zigbee USB stick. After a reset, bulbs can easily join any type of compatible bridge.
GNU General Public License v3.0
178 stars 20 forks source link

NCP entered failed state. Requesting APP controller restart #23

Closed Tertiush closed 1 year ago

Tertiush commented 1 year ago

First off, thanks so much for this script and keeping it updated! I know these things can become a burden, but its much appreciated!

I've got a few original Hue E27 bulbs, trying to migrate them over to another bridge of my own. When running the script I get the error below. I'm on a fresh Debian buster (64bit) install on a PI 3, with a USB conected Sonoff ZBDongle-E running a newer EZSP version (think its v7+). Not knowing an awful lot of Zigbee I don't know where to start to debug my issue :(

The bulb does flash twice when the script reaches channel 20, but then turns back on and the script fails. I have switched off the Hue (original) hub and the Zigbee integration on Home Assistant (also powered off its WiFi connected Zigbee bridge).

Any help will be greatly appreciated! Thanks!

pi@mypi:/opt/hue-thief $ sudo python3 hue-thief.py /dev/ttyACM0 --baudrate 115200
Scanning on channel 11
Scanning on channel 12
Scanning on channel 13
Scanning on channel 14
Scanning on channel 15
Scanning on channel 16
Scanning on channel 17
Scanning on channel 18
Scanning on channel 19
Scanning on channel 20
NCP entered failed state. Requesting APP controller restart
Traceback (most recent call last):
  File "/root/.local/lib/python3.9/site-packages/bellows/ezsp/protocol.py", line 152, in command
    return await future
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/hue-thief/hue-thief.py", line 135, in <module>
    asyncio.get_event_loop().run_until_complete(steal(args.device, args.baudrate, args.channel))
  File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/opt/hue-thief/hue-thief.py", line 105, in steal
    await dev.mfglibSendPacket(frame)
  File "/root/.local/lib/python3.9/site-packages/bellows/ezsp/protocol.py", line 152, in command
    return await future
  File "/root/.local/lib/python3.9/site-packages/async_timeout/__init__.py", line 129, in __aexit__
    self._do_exit(exc_type)
  File "/root/.local/lib/python3.9/site-packages/async_timeout/__init__.py", line 212, in _do_exit
    raise asyncio.TimeoutError
asyncio.exceptions.TimeoutError
Tertiush commented 1 year ago

Got it to work by commenting out the await in line 105, to simply have the code run. Didn't expect much but it worked

Removed the await from:

await dev.mfglibSendPacket(frame)

Result:

pi@mypi:/opt/hue-thief $ sudo python3 hue-thief.py /dev/ttyACM0 --baudrate 115200
Scanning on channel 11
Scanning on channel 12
Scanning on channel 13
Scanning on channel 14
Scanning on channel 15
Scanning on channel 16
Scanning on channel 17
Scanning on channel 18
Scanning on channel 19
Scanning on channel 20
/opt/hue-thief/hue-thief.py:107: RuntimeWarning: coroutine 'ProtocolHandler.command' was never awaited
  dev.mfglibSendPacket(frame)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Do you want to factory reset the light that just blinked? [y|n]
y
Factory resetting 00:17:88:01:00:d1:d8:1d
NCP entered failed state. Requesting APP controller restart
Traceback (most recent call last):
  File "/root/.local/lib/python3.9/site-packages/bellows/ezsp/protocol.py", line 152, in command
    return await future
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/hue-thief/hue-thief.py", line 137, in <module>
    asyncio.get_event_loop().run_until_complete(steal(args.device, args.baudrate, args.channel))
  File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/opt/hue-thief/hue-thief.py", line 121, in steal
    await dev.mfglibSendPacket(frame)
  File "/root/.local/lib/python3.9/site-packages/bellows/ezsp/protocol.py", line 152, in command
    return await future
  File "/root/.local/lib/python3.9/site-packages/async_timeout/__init__.py", line 129, in __aexit__
    self._do_exit(exc_type)
  File "/root/.local/lib/python3.9/site-packages/async_timeout/__init__.py", line 212, in _do_exit
    raise asyncio.TimeoutError
asyncio.exceptions.TimeoutError
pranavb25 commented 1 year ago

I'm getting the same error. The bulb blinks and then I get the "NCP entered failed state. Requesting APP controller restart" message.