Skip to content

drained: handle missed "changing" events - #4188

Merged
gfwilliams merged 2 commits into
espruino:masterfrom
bobrippling:drained-backstop
Sep 11, 2026
Merged

drained: handle missed "changing" events#4188
gfwilliams merged 2 commits into
espruino:masterfrom
bobrippling:drained-backstop

Conversation

@bobrippling

Copy link
Copy Markdown
Collaborator

Sometimes my watch will change (with drained active) past the threshold and not deactivate drained. On debugging, the interval isn't set, so we set it unconditionally to ensure we have a charge "watcher".

@thyttan

thyttan commented Mar 10, 2026

Copy link
Copy Markdown
Collaborator

Does this mean something is broken in the event handling somewhere?

I mean, why would we be missing to set the interval in the 'charging'-listener?

@thyttan

thyttan commented Mar 10, 2026

Copy link
Copy Markdown
Collaborator

We also discussed some weird event listener behavior on #4141.

Could this be something similar?

@bobrippling

Copy link
Copy Markdown
Collaborator Author

Good memory! I would initially say no, and that drained just starts too late but that can't be the case - drained is running when I plug my watch in to charge 🤔

It could well be something with the firmware, like #4141. I'll see if I can get more details

@thyttan

thyttan commented Apr 4, 2026

Copy link
Copy Markdown
Collaborator

@bobrippling I'm thinking of opening an issue re event handling on espruino/Espruino. Have you managed to understand the problem any more?

@bobrippling

Copy link
Copy Markdown
Collaborator Author

I'm afraid not - still at square one!

@stweedo

stweedo commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

There is one specific case i found with version 0.08 of drained where if it's started while the watch is charging, it will not deactivate when crossing the threshold until a new charging event happens by reconnecting the charger.

@gfwilliams

Copy link
Copy Markdown
Member

Just mentioned in espruino/Espruino#2702 (comment) but:

I don't think drained uses notify? But there was an issue with notify calling stopEventPropagation on hide, so if any other app did show a notification with notify (eg 'low battery') and then hide it on a charging event then any other 'charging' event handlers would not be called and it'd cause this exact issue

@bobrippling

Copy link
Copy Markdown
Collaborator Author

Yeah, no use of notify - I haven't gotten to the bottom of this so maybe we merge this PR to handle the problem until I do suss it out?

@thyttan

thyttan commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

It feels a bit antithetical to start running an interval while we try to preserve battery as much as possible. But maybe it's negligible.

Comment thread apps/drained/app.js
@bobrippling

Copy link
Copy Markdown
Collaborator Author

What about this change I've just pushed?

@thyttan

thyttan commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

Looks good to me!

@gfwilliams

Copy link
Copy Markdown
Member

Looks great to me!

@gfwilliams
gfwilliams merged commit 91875d8 into espruino:master Sep 11, 2026
2 checks passed
@bobrippling
bobrippling deleted the drained-backstop branch September 11, 2026 11:05
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.

4 participants