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

Add a remaining charge time sensor for supported devices #4346

Merged

Conversation

dshokouhi
Copy link
Member

@dshokouhi dshokouhi commented Apr 17, 2024

Summary

Fixes: #3934 by adding the sensor for devices on Android P +

Sensor reports in minutes so have used the duration class. This sensor will only update during the normal sensor update interval and may work better if using the fast while charging sensor update frequency setting.

Screenshots

image

Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#1058

Any other notes

@jpelgrom
Copy link
Member

This will probably change on every sensor update, lots of updates in the state machine.

Would it make sense to round this to minutes (as all devices seem to do this in settings etc.), and/or maybe report is a timestamp?

@dshokouhi
Copy link
Member Author

Would it make sense to round this to minutes (as all devices seem to do this in settings etc.)

This sounds reasonable and good point about too many updates, every minute will also line up with fast while charging update frequency :)

and/or maybe report is a timestamp?

I think this may still be subject to a lot of updates right? Using the phone while charging may also impact this number as I can see battery temp and voltage being impacted too

@jpelgrom
Copy link
Member

jpelgrom commented Apr 19, 2024

This does not appear to work correctly / produces results that are different from the settings app and lock screen and seem impossible. (Pixel 7a with Android 14)

The sensor does correctly change from unavailable when unplugged > 0 min at first > 4 min after a while > stays at 4 min despite charging and the estimate in the settings app changing.

Screenshot_20240419-163210.png

Also suggestion: use sentence case for the sensor name to be more consistent with others.

@dshokouhi
Copy link
Member Author

Thank you! Both should be corrected in the next push :)

@jpelgrom
Copy link
Member

Awesome, this seems to match the system's estimate almost perfectly during the ~15 min I observed.

Almost, because the system seems to always show 1 minute less remaining, meaning it rounds down whereas the app rounds up. Can we change that for consistency?

@dshokouhi
Copy link
Member Author

Almost, because the system seems to always show 1 minute less remaining, meaning it rounds down whereas the app rounds up. Can we change that for consistency?

So always round down or round down in certain cases?

@jpelgrom
Copy link
Member

Right now it looks like always round down is the way to do this.

@dshokouhi dshokouhi merged commit 38e5da1 into home-assistant:master May 3, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get sensor : time left before full charge
2 participants