Skip to content
This repository has been archived by the owner on Dec 28, 2022. It is now read-only.

Change in zigbee-herdsman causes stop-work-condition for node-red-contrib-zigbee with message 'Error Resource temporarily unavailable Cannot lock port' #160

Open
hogthrob opened this issue Nov 25, 2021 · 1 comment

Comments

@hogthrob
Copy link
Contributor

hogthrob commented Nov 25, 2021

The result of integrating Koenkk/zigbee-herdsman#442 into the main zigbee-herdsman module on which node-red-contrib-zigbee depends on, is that it stops working and continuously reports that the serial port could not be opened because it is locked (which is kind of true, but not the root cause).

A little debugging brought to light what the problem is: the zigbee-herdman method supportsLED is no longer existing, hence

this.herdsman.supportsLED().then(supportsLED => {

fails and the connect() code is failing, but it does not release the serial port, so subsequent retries report the locked serial port.

It is very unfortunate that the maintainers of zigbee-herdsman did not follow semver and bumped up the minor number of the package to indicate a removal of API functions. Would have prevented the upgrade breaking my node-red flows. But it is like it is.

I would suggest to leave the led alone and remove the code or to run this code only if the method supportsLED is present.

Hope this helps others to understand the problem and not to waste time to find out what they did to break things.

A quick workaround is to downgrade zigbee-herdsman using npm to version 0.13.169 or older.
I just commented out the lines

this.herdsman.supportsLED().then(supportsLED => {
if (supportsLED === true) {
this.herdsman.setLED(this.led === 'enabled').then(() => {
this.debug(`setLED successfully set ${this.led}`);
}).catch(error => {
this.error(`setLED failed to set ${this.led} ${error.message}`);
});
} else if (this.led === 'enabled') {
this.error('Setting LED not supported on this adapter. To avoid this message at startup, set CC2531 LED to \'disabled\' in controller node');
}
});

Which also does the job but of course gets overwritten next time I update node-red...

@hogthrob hogthrob changed the title Change in zigbee-herdsman causes stop-work-condition for node-red-contrib-zigbee with message Error Resource temporarily unavailable Cannot lock port Change in zigbee-herdsman causes stop-work-condition for node-red-contrib-zigbee with message 'Error Resource temporarily unavailable Cannot lock port' Nov 25, 2021
@kender65
Copy link

kender65 commented Nov 27, 2021

Hi @hogthrob !
Thanks for doing the research and providing your solution(s)!
I discovered the same issue but didn't think about the error message causing the issue. I tried mutliple things but didn't get it running again until I tried your solution no. 2. Hopefully I don't have to do an update any time soon.

hogthrob added a commit to hogthrob/node-red-contrib-zigbee that referenced this issue Nov 28, 2021
We just check for the existence of the supportsLED method and only then run the code which used to work in older zigbee-herdsman versions.
In case of problems in connect we now properly stop the zigbee adapter before trying to restart it. This was a problem uncovered by hobbyquaker#160 but not the root cause (this was the call to a no-longer-existing method of zigbee-herdsman.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants