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

feat: make timeout to send devices back to sleep configurable, lower default to 250 ms #6312

Merged
merged 4 commits into from
Sep 25, 2023

Conversation

apella12
Copy link
Contributor

On change from 1000 to 500: I do not think shorter sleep is worth a user parameter that then has to be checked. Active battery time is 12.5mA; sleep 1uA, so 1/2 second savings is 26 extra daya a year (700 device). More for 500 devices.

By the time this is called all pending messages are cleared, so all the work is done.
Signed-off-by: Bob Eckhoff [email protected]

apella12 and others added 4 commits September 23, 2023 17:18
On change from 1000 to 500: I do not think shorter sleep is worth a user parameter that then has to be checked. Active battery time is 12.5mA; sleep 1uA, so 1/2 second savings is 26 extra daya a year (700 device). More for 500 devices.

By the time this is called all pending messages are cleared, so all the work is done.
See an error, but not sure what it is. Trying this

Signed-off-by: Bob Eckhoff <[email protected]>
have an issue trying to find format error.  See if file reversion works
Copy link
Member

@AlCalzone AlCalzone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I lowered the default timeout to 250ms, since there should really not be a reason to keep the device awake for longer, other than giving the application more time to do something.

Also, I decided to make this configurable after all, in case someone has a weird edge case that needs a higher timeout.

@AlCalzone AlCalzone changed the title feat(config): save battery device life by seven percent feat: make timeout to send devices back to sleep configurable, lower default to 250 ms Sep 25, 2023
@AlCalzone
Copy link
Member

@zwave-js-bot automerge

@zwave-js-bot zwave-js-bot enabled auto-merge (squash) September 25, 2023 08:41
@zwave-js-bot zwave-js-bot merged commit 9b9f43f into zwave-js:master Sep 25, 2023
16 checks passed
AlCalzone added a commit that referenced this pull request Sep 25, 2023
### Features
* The default time after which battery-powered devices with no pending commands are sent back to sleep is now `250 ms` (down from `1000ms`). This timeout is now configurable using the driver option `timeouts.sendToSleep`. This should result in significant battery savings for devices that frequently wake up. (#6312)

### Bugfixes
* Add missing export for `PartialZWaveOptions` (#6319)

### Config file changes
* Add Heatit Z-Water 2 (#6299)

### Changes under the hood
* Correct build configuration for ESLint plugin (#6315)
* Fixed the interpretation of `limit_options` in OpenSmartHouse import script (#6313)
AlCalzone added a commit that referenced this pull request Sep 26, 2023
### Breaking changes · [Migration guide](https://zwave-js.github.io/node-zwave-js/#/getting-started/migrating-to-v12)
* Remove support for Node.js 14 and 16 (#6245)
* Subpath exports are now exposed using the `exports` field in `package.json` instead of `typesVersions` (#5839)
* The `"notification"` event now includes a reference to the endpoint that sent the notification (#6083)
* Keep separate Supervision session ID counters for each node (#6175)
* Validate the device fingerprint before installing firmware update instead of when checking for updates (#6192)
* Removed some deprecated methods (#6250)
* Managing SUC routes with the non-SUC method variants is no longer allowed (#6251)
* "Heal (network)" was renamed to "rebuild routes" to better reflect what it does (#6252)
* Corrected the argument type for `Driver.constructor`, `updateLogConfig` and `updateOptions` (#6254, #6319)

### Features
* Detect an unresponsive stick and reset it (#6244)
* The default time after which battery-powered devices with no pending commands are sent back to sleep is now `250 ms` (down from `1000ms`). This timeout is now configurable using the driver option `timeouts.sendToSleep`. This should result in significant battery savings for devices that frequently wake up. (#6312)

### Bugfixes
* A bug in the `7.19.x` SDK has surfaced where the controller gets stuck in the middle of a transmission. Previously this would go unnoticed because the failed commands would cause the nodes to be marked dead until the controller finally recovered. Since `v11.12.0` however, Z-Wave JS would consider the controller jammed and retry the last command indefinitely. This situation is now detected and Z-Wave JS attempts to recover by soft-resetting the controller when this happens. (#6296)
* Removed auto-disabling of soft-reset capability (#6256)
* Default to RF protection state `Unprotected` if not given for `Protection CC` V2+ (#6257)

### Config file changes
* Add Heatit Z-Water 2 (#6299)
* Add Shelly Wave 1PM (#6280, #6317)
* Add Heatit Z-TRM6 (#6263)
* Increase poll delay for ZW500D (#6270)
* Add fingerprint for Simon IO Master Roller Blind (#6262)
* Add HOPPE eHandle ConnectSense (#6269)
* Add parameters to Zooz ZEN17 from firmware 1.30 (#6189)
* Update Zooz ZEN32 config to the latest firmware, include 800 series (#6283)

### Changes under the hood
* Fixed the interpretation of `limit_options` in OpenSmartHouse import script (#6313)
* Some Z-Wave JS specific implementation checks are now done using a custom ESLint plugin (#6276, #6279, #6315)
* Migrated more Z-Wave JS specific checks to the custom ESLint plugin (#6297, #6302)
* Use ESLint to enforce consistent property ordering in config parameters and avoid unnecessary `minValue/maxValue` (#6321, #6322)
* `yarn test` now only runs tests affected by changed files by default. This is also done on CI in PRs to speed up check times (#6274)
* Upgraded lots of dependencies (#6258)
@apella12 apella12 deleted the sleeping-devices branch September 26, 2023 14:07
@apella12
Copy link
Contributor Author

First thanks. Second with the OpenHab binding I have been using 250 ms. I wasn't sure you would buy that so hedged originally at 500 ms. ;-)

Lastly, at least with my understanding, the description The default should be enough time for applications to react to devices waking up could tempt users to change this is for unrelated problems. What I assumed the flow was 1) wakeup notice by device 2) after acking wakeup notice, ZJS checks for queued messages, sends them and waits until completion (with Acks) 3) Queue empty, wait 250 ms and send back to sleep. Maybe "Sleep delay after all queued messages processed" I'm also assuming that it the queued commands don't get processed, ZJS marks the node as asleep again and the sleep message is never sent? Anyway I don't understand the "for applications to react" means. I didn't want to open a can of worms.

@AlCalzone
Copy link
Member

Maybe what I wrote is worded badly. Enough time for applications to react refers to the time applications get after wakeup or each processed command to queue additional commands before the device gets sent back to sleep.

E.g. they might want to refresh a value, or do things based on the result of a command. Considering that the chain to the actual application might be quite long (e.g. node-zwave-js -> Z-Wave JS UI -> Z-Wave JS Server -> TCP connection -> HA Python Library -> Home Assistant Addon -> Home Assistant`) , and Z-Wave JS may be running on slower hardware, I didn't dare to go much lower

@apella12
Copy link
Contributor Author

Thanks. That makes sense. I have observed short periods with an empty queue (at least in the OpenHab zwave binding) while the next command gets created, (generally with the initial interview) where the data from the prior command was needed to formulate the next message. I'm assuming that besides the empty queue check, zwave-js also checks if the device is fully configured before sending the sleep?
I was not advocating for lower. In the battery PR that was merged in OH zwave, I used 500 ms, but was testing 250 ms locally. I have some Sensative sticks that make me paranoid about battery life. ;-)

@AlCalzone
Copy link
Member

I'm assuming that besides the empty queue check, zwave-js also checks if the device is fully configured before sending the sleep?

Not explicitly, but as long as the interview isn't completed, there should always be pending messages on the queue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants