zwave-js / node-red-contrib-zwave-js

The most powerful, high performing and highly polished Z-Wave node for Node-RED based on Z-Wave JS. If you want a fully featured Z-Wave framework in your Node-RED instance, you have found it.
MIT License
47 stars 6 forks source link

BUG: Power cycling a Pi 4 with this pallet results is Zwave all off line #88

Closed WarrenEvans closed 3 years ago

WarrenEvans commented 3 years ago

Contact Details (optional)

warrenevans@xtra.co.nz

What happened?

If you power cycle a pi4 with this pallet install, when the node red starts up the zwave device is stuck off line. Below is a cut from the log. Restarting Node red will fix the problem. It looks like the node red pallet is running before the Aeotec Z-Stick Gen5 is ready. The pallet does not retry the connection. 2021-07-22T23:33:00.586Z DRIVER « [RES] [GetSUCNodeId]

                                payload: 0x01

2021-07-22T23:33:00.594Z CNTRLR This is the SUC

2021-07-22T23:33:00.607Z DRIVER Failed to initialize the driver: Failed to lock DB file "/root/.node-red/zwave

                              -js-cache/ec16151b.values.jsonl"!

2021-07-22T23:33:00.609Z NDERED [ERROR] [DRIVER] Failed to initialize the driver: Failed to lock DB file "/roo

                              t/.node-red/zwave-js-cache/ec16151b.values.jsonl"!

2021-07-22T23:33:00.612Z DRIVER destroying driver instance...

2021-07-22T23:40:54.884Z NDERED « [EVENT] Payload received.

2021-07-22T23:40:54.887Z NDERED [ERROR] [INPUT] Node 20 does not exist.

How to reproduce?

  1. Setup zwave pallet on a pi4 with 1 device.
  2. Reboot pi4 with out power cycling.
  3. Test zwave working.
  4. Remove power from pi4
  5. Re-connect power to pi4
  6. Zwave Pallet not stuck at starting.

to fix this problem, restart node red or do a soft reboot (with out removing power) on the pi4

Version

v4.1.0

Node-RED Version

1.3.x

What hardware are you seeing the problem on?

Raspberry Pi

Relevant Z-Wave-JS log output

2021-07-22T23:33:00.586Z DRIVER « [RES] [GetSUCNodeId]

                                    payload: 0x01

2021-07-22T23:33:00.594Z CNTRLR   This is the SUC

2021-07-22T23:33:00.607Z DRIVER   Failed to initialize the driver: Failed to lock DB file "/root/.node-red/zwave

                                  -js-cache/ec16151b.values.jsonl"!

2021-07-22T23:33:00.609Z NDERED   [ERROR] [DRIVER] Failed to initialize the driver: Failed to lock DB file "/roo

                                  t/.node-red/zwave-js-cache/ec16151b.values.jsonl"!

2021-07-22T23:33:00.612Z DRIVER   destroying driver instance...

2021-07-22T23:40:54.884Z NDERED « [EVENT] Payload received.

2021-07-22T23:40:54.887Z NDERED   [ERROR] [INPUT] Node 20 does not exist.
marcus-j-davies commented 3 years ago

Good Morning,

Thanks for reporting the issue. The backend driver, that this module uses, employs file locking.

And given the nature of pulling the power, means a file lock may still be... well ..... locked. There should be a 10s stale time however - so not sure why the locking mechanism seems to think, it all happened within 10 seconds (Though not impossible)

In any case, I don't recommend just pulling the power like this, but if you really need to, allow 5 seconds before restoring power - for the file lock to expire fully.

Or the better option, reboot correctly, which the file locking mechanism knows how to handle.

Also, You don't need to restart, just make a change on the controller node (renaming it is good enough), then redeploy, this will restart the driver.

In the mean time, I could look to work around this behaviour - But I am not overly excited, for building work arounds like this.

marcus-j-davies commented 3 years ago

@WarrenEvans,

I have now implemented recovery logic. If, for whatever reason, there is a file lock upon startup, it will retry up to a maximum of 3 times (5 second wait in-between).

This also covers any other critical error, say if the USB stick suddenly has an episode of power loss.

I will try and push out an update later today.

marcus-j-davies commented 3 years ago

V4.3.0 Released.