ZHA stopped working with my Bitronvideo 2010/10 Zigbee USB stick

OK, so I have searched everywhere I can think and I am not finding a solution.

I have a Hassbian install with Linux 9 (stretch) and kernel 4.19.42.v7+.
And I am running HA 0.94.4.
I have this zigbee USB stick: http://bvsite.smabit.eu/index.php/produkte/smart-home-produkte/zb-funkstick/ (site is in German)

My ZigBee USB stick is loading into the kernel as:
[ 3.901117] usbcore: registered new interface driver usbserial_generic
[ 3.901198] usbserial: USB Serial support registered for generic
[ 3.917294] usbcore: registered new interface driver cp210x
[ 3.917374] usbserial: USB Serial support registered for cp210x
[ 3.917528] cp210x 1-1.5:1.0: cp210x converter detected
[ 3.924977] usb 1-1.5: cp210x converter now attached to ttyUSB0

And when I was using an early 0.9x version of HA I could pair devices and control them via the ZHA management dashboard that was introduced in 0.90.0.

Now, I had tried to get zigbee2mqtt running without realizing that this ZigBee stick is not even supported. So, while I was setting this up I did upgrade Hassbian as well as HA.

After giving up on zigbee2mqtt (and maybe after doing another Hassbian and HA upgrade) I am no longer able to get ZHA working at all. I keep getting the same error while loading HA:

2019-06-25 14:08:37 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry /dev/ttyUSB0 for zha
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/config_entries.py", line 273, in async_setup
    hass, self)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/zha/__init__.py", line 94, in async_setup_entry
    await zha_gateway.async_initialize(config_entry)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/zha/core/gateway.py", line 69, in async_initialize
    self.zha_storage = await async_get_registry(self._hass)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/zha/core/store.py", line 160, in async_get_registry
    return cast(ZhaDeviceStorage, await task)
  File "/usr/lib/python3.5/asyncio/futures.py", line 382, in __iter__
    return self.result()  # May raise too.
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/config_entries.py", line 273, in async_setup
    hass, self)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/zha/__init__.py", line 94, in async_setup_entry
    await zha_gateway.async_initialize(config_entry)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/zha/core/gateway.py", line 69, in async_initialize
    self.zha_storage = await async_get_registry(self._hass)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/zha/core/store.py", line 160, in async_get_registry
    return cast(ZhaDeviceStorage, await task)
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/zha/core/store.py", line 155, in _load_reg
    await registry.async_load()
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/zha/core/store.py", line 112, in async_load
    power_source=device['power_source'],
KeyError: 'power_source'

I have deleted the ZHA integration and recreated it. I’ve deleted the zigbee.db and it is recreated after reinstalling the ZHA integration. Permissions seem fine since the zigbee.db file is created and the home assistant user is in the dialout group that is need for access to /dev/ttyUSB0.

Any ideas would be appreciated.

Oh, and I did try commenting out the line 112 of the store.py just for the fun of it and it just bails out at line 113 then. So, I don’t think the KeyError: ‘power_source’ is referencing the actual error.

Thanks for any advice someone might have.

Just in case someone is wondering, I did use the command

`pip3 install homeassistant==0.90.0`

in my HA environment to gradually back off on the HA version going from 0.94 to 0.93 as so forth to see if it was just a version of HA. But, the issue persisted. Of course I may have needed to do some things other than downgrade and restart HA to check. For instance, at that time I was not removing the ZHA integration and recreating it in case that would have been important to remove any fragments of the old ZHA from previous HA versions.
So, that could be another process I could try out if anybody thinks it is worth it.
Currently I am thinking this is an issue within Hassbian and not necessarily in the HA ZHA integration since downgrading HA didn’t help. But, maybe I was just being too hasty with the downgrading of HA and missed something important that plays a role other than the underlying OS version.

I think I have now partly answered my question above about which version potentially broke my ZHA.
I had only downgraded HA to 0.90.0 while testing. Now I went back to 0.89.2 (last stable version prior to 0.90.0) and now my ZHA works again.
I also notice that 0.89.2 doesn’t have the store.py in the ZHA component. So, it looks like the introduction of the store.py breaks ZHA for those using the same device as I am.
Here is the HA log with the successful joining divide using 0.89.2 in case it helps get the store.py fixed. I am fine with 0.89.2 for now, but I would like to be assured I can upgrade to newer versions in the future. So it would be nice if we can get this fixed.

2019-06-25 16:12:37 INFO (MainThread) [homeassistant.components.zha.api] Permitting joins for 60s
2019-06-25 16:12:39 INFO (MainThread) [zigpy.application] Device 0x5d1f (00:0d:6f:00:04:24:73:48) joined the network
2019-06-25 16:12:39 INFO (MainThread) [zigpy.device] [0x5d1f] Discovering endpoints
2019-06-25 16:12:40 INFO (MainThread) [zigpy.device] [0x5d1f] Discovered endpoints: [1]
2019-06-25 16:12:40 INFO (MainThread) [zigpy.endpoint] [0x5d1f:1] Discovering endpoint information
2019-06-25 16:12:40 INFO (MainThread) [zigpy.endpoint] [0x5d1f:1] Discovered endpoint information: <SimpleDescriptor endpoint=1 profile=260 device_type=769 device_version=0 input_clusters=[0, 1, 3, 10, 32, 513, 516, 2821] output_clusters=[3, 25]>
2019-06-25 16:12:41 DEBUG (MainThread) [homeassistant.components.zha.core.device] Bitron Home 902010/32: started configuration
2019-06-25 16:12:41 DEBUG (MainThread) [homeassistant.components.zha.core.device] Bitron Home 902010/32: channel: zdo-Bitron Home 902010/32_ZDO async_configure stage succeeded
2019-06-25 16:12:41 DEBUG (MainThread) [homeassistant.components.zha.core.channels] 0x5d1f:1:0x0000: finished channel configuration
2019-06-25 16:12:41 DEBUG (MainThread) [homeassistant.components.zha.core.helpers] 0x5d1f:1:0x0001: bound  'power' cluster: Status.SUCCESS
2019-06-25 16:12:41 DEBUG (MainThread) [homeassistant.components.zha.core.device] Bitron Home 902010/32: channel: basic-0x5d1f:1:0x0000 async_configure stage succeeded
2019-06-25 16:12:42 DEBUG (MainThread) [homeassistant.components.zha.core.helpers] 0x5d1f:1:0x0001: reporting 'battery_voltage' attr on 'power' cluster: 30/900/1: Result: '[[<ConfigureReportingResponseRecord status=0 direction=0 attrid=0>]]'
2019-06-25 16:12:43 DEBUG (MainThread) [homeassistant.components.zha.core.helpers] 0x5d1f:1:0x0001: reporting 'battery_percentage_remaining' attr on 'power' cluster: 30/900/1: Result: '[[<ConfigureReportingResponseRecord status=134 direction=0 attrid=33>]]'
2019-06-25 16:12:43 DEBUG (MainThread) [homeassistant.components.zha.core.channels] 0x5d1f:1:0x0001: finished channel configuration
2019-06-25 16:12:43 DEBUG (MainThread) [homeassistant.components.zha.core.device] Bitron Home 902010/32: channel: battery-0x5d1f:1:0x0001 async_configure stage succeeded
2019-06-25 16:12:43 DEBUG (MainThread) [homeassistant.components.zha.core.device] Bitron Home 902010/32: completed configuration
2019-06-25 16:12:43 DEBUG (MainThread) [homeassistant.components.zha.core.device] Bitron Home 902010/32: started initialization
2019-06-25 16:12:43 DEBUG (MainThread) [homeassistant.components.zha.core.device] Bitron Home 902010/32: channel: zdo-Bitron Home 902010/32_ZDO async_initialize stage succeeded
2019-06-25 16:12:44 DEBUG (MainThread) [homeassistant.components.zha.core.device] Bitron Home 902010/32: channel: basic-0x5d1f:1:0x0000 async_initialize stage succeeded
2019-06-25 16:12:45 DEBUG (MainThread) [homeassistant.components.zha.core.device] Bitron Home 902010/32: channel: battery-0x5d1f:1:0x0001 async_initialize stage succeeded
2019-06-25 16:12:45 DEBUG (MainThread) [homeassistant.components.zha.core.device] Bitron Home 902010/32: power source: Battery
2019-06-25 16:12:45 DEBUG (MainThread) [homeassistant.components.zha.core.device] Bitron Home 902010/32: completed initialization