Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zigbee things only work on a second click #322

Open
evert opened this issue Nov 8, 2021 · 3 comments
Open

Zigbee things only work on a second click #322

evert opened this issue Nov 8, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@evert
Copy link

evert commented Nov 8, 2021

At home I have a Webthings gateway (on raspberry pi). This pi has a zigbee adapter, and I have a couple of lights and switches.

When I click any 'thing' it typically does not respond. It almost feels like it takes a few minutes after interacting with it to 'wake up', after which they do work when turning on/off. This is very reliable, so when I use the gateway, I:

  1. Click the thing (nothing happens)
  2. Wait 30s - 1minute
  3. Click it again (it now turns on)

This is a bit frustrating, but it also means that my scheduled things (like turning on a light at a certain time of the day) typically doesn't work. My theory is that the events trigger the switches one, and then doesn't' try again after the 'wake up'.

I dusted off my Pi recently after not having used it for 10ish months, but I don't think this was ever an issue before.

This appears in my logs:

2021-11-08 16:21:11.223 ERROR  : zigbee-adapter: /home/pi/.webthings/addons/zigbee-adapter/lib/driver/conbee.js:338
2021-11-08 16:21:11.223 ERROR  : zigbee-adapter:                 value = value.toString(16).padStart(8, '0');
2021-11-08 16:21:11.224 ERROR  : zigbee-adapter:                               ^
2021-11-08 16:21:11.225 ERROR  : zigbee-adapter: 
2021-11-08 16:21:11.226 ERROR  : zigbee-adapter: TypeError: Cannot read property 'toString' of undefined
2021-11-08 16:21:11.227 ERROR  : zigbee-adapter:     at ConBeeDriver.dumpParameters (/home/pi/.webthings/addons/zigbee-adapter/lib/driver/conbee.js:338:31)
2021-11-08 16:21:11.227 ERROR  : zigbee-adapter:     at ConBeeDriver.run (/home/pi/.webthings/addons/zigbee-adapter/lib/driver/index.js:662:26)
2021-11-08 16:21:11.228 ERROR  : zigbee-adapter:     at ConBeeDriver.waitTimedOut (/home/pi/.webthings/addons/zigbee-adapter/lib/driver/index.js:719:22)
2021-11-08 16:21:11.229 ERROR  : zigbee-adapter:     at ontimeout (timers.js:436:11)
2021-11-08 16:21:11.230 ERROR  : zigbee-adapter:     at tryOnTimeout (timers.js:300:5)
2021-11-08 16:21:11.231 ERROR  : zigbee-adapter:     at listOnTimeout (timers.js:263:5)
2021-11-08 16:21:11.231 ERROR  : zigbee-adapter:     at Timer.processTimers (timers.js:223:10)
2021-11-08 16:21:11.246 INFO   : Plugin: zigbee-adapter died, code = 1 restarting after 30000
@benfrancis benfrancis transferred this issue from WebThingsIO/gateway Nov 12, 2021
@benfrancis benfrancis added the bug Something isn't working label Nov 12, 2021
@benfrancis
Copy link
Member

Thanks for the bug report @evert.

Some Zigbee devices do go to into sleep mode, but it's usually battery powered devices rather than mains powered devices which do that.

The error looks like there might be a bug in the Zigbee adapter which is worth investigating so I've moved the issue to the zigbee-adapter repository.

It might help if you provide the model numbers of the devices you're using as this may be difficult to reproduce.

@evert
Copy link
Author

evert commented Nov 21, 2021

Some Zigbee devices do go to into sleep mode, but it's usually battery powered devices rather than mains powered devices which do that.
The error looks like there might be a bug in the Zigbee adapter which is worth investigating so I've moved the issue to the zigbee-adapter repository.

Yeah my intuition is that this is not a sleep issue, especially since it switches to a 'broken' state relatively quickly after the plugin is restarted. Also worth noting that this used to never be a problem, and I've been a Webthings Gateway user for 2ish years.

The dongle is a Conbee II, this is my output from usb-devices:

T:  Bus=01 Lev=03 Prnt=03 Port=02 Cnt=02 Dev#=  8 Spd=12  MxCh= 0
D:  Ver= 2.01 Cls=02(commc) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=1cf1 ProdID=0030 Rev=01.00
S:  Manufacturer=dresden elektronik ingenieurtechnik GmbH
S:  Product=ConBee II
S:  SerialNumber=DE1963954
C:  #Ifs= 2 Cfg#= 1 Atr=80 MxPwr=100mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=02 Prot=01 Driver=cdc_acm
I:  If#=0x1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_acm

If there is a way I can assist with this, let me know! It makes webthings very hard to use right now, because a lot of what I do is based on events & timers.

@evert
Copy link
Author

evert commented Nov 23, 2021

So I've started hacking in the conbee.js file and I managed to stop it from crashing. Probably entirely in a bad way, maybe by ignoring an underlying problem.

There are 2 places in conbee.js where there's a block like

if (paramId == C.PARAM_ID.SCAN_CHANNELS) {
  value = value.toString(16).padStart(8, '0');
}

This fails because in my case value is sometimes undefined. I changed this to:

if (paramId == C.PARAM_ID.SCAN_CHANNELS && value) {
  value = value.toString(16).padStart(8, '0');
}

This stops the zigbee adapter from crashing every minute. I have no idea if this is an appropriate fix though. The 2 places where I had to do this was in asDeviceInfo and dumpParameters.

Happy to submit this as a PR too, but I don't know if there's additional adverse effects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants