home-assistant / android

:iphone: Home Assistant Companion for Android
https://companion.home-assistant.io/
Apache License 2.0
2.07k stars 587 forks source link

Add a remaining charge time sensor for supported devices #4346

Closed dshokouhi closed 2 weeks ago

dshokouhi commented 1 month ago

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 commented 4 weeks ago

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 commented 4 weeks ago

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 commented 4 weeks ago

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 commented 4 weeks ago

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

jpelgrom commented 3 weeks ago

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 commented 3 weeks ago

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 commented 3 weeks ago

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