Battery level status 'not' updating when charging

I have a tablet for which I try to keep the battery between 20 and 80%.
Charging is done with a smart plug and automation.

Lately it happens often that the automation doesn’t run and the tablet is charged 100% whereas the 20% level is recognized.
If I check the state in HA, the value doesn’t change when charging.
By sending a command_update_sensors it does update the value of course.
I could hack this problem by sending this command regularly but I prefer to find the cause of this because this has worked fine.

Companion app: 2023.10.2
HA Core: 2023.11.0

What could be the reason for this?

Battery level updates with the wither schedule so every 15 minutes unless you adjusted sensor update frequency

Hi Daniel, thank you for replying!

The battery level is set to update every 15 min and the sensor update frequency also is set to 15 min.
Is there anything else that influences this?

battery optimization can delay the schedule

I’m not that good with mobile systems but this is what I see: (settings were always like this)

probably settings > apps > home assistant

every device is going ot be different so you may need to go on a hunt in settings.

you can also check the app has background access by opening the HA app and going to Settings > Companion App and checking the background access tile. This may not be enough for some manufacturers as they may add other options like power savings etc…

1 Like

→ not optimized

Is checked and apparently I cannot modify it

It’s a Lenovo (with Android 10) and I cannot find any other item that seems to be related.
This has worked though so I doubt that it is related to the device settings.

You have a battery protection mode in that screenshot, which do somewhat what you want, al though a bit conservative with 60% as max.
Battery Saver or Battery Manager might actually be more what you want, so test them.
No need to hack HA, if the phone can do it itself.

after checking the app has proper permission to run in teh background, the only next option is to check the app logs when the issue occurs to see if there was a failure

From what I have picked up multiple times, keeping the battery between 20 and 80% is the ideal scenario.
Since the device is not always plugged in, controlling the charging with HA and get notified of it, gives me more control.
Also, it has worked and my curiosity why this has changed is also a reason for me to solve this.

Is that from the app log and with the ‘error occurs’ do you mean when charging and the sensor is not updated?

The device makers knows this and that is why they add something like Battery Protection Mode.
Monitoring in HA is fine, but why try to control it from HA, if the device can do it itself and probably react to the changes better and faster?

how long do you see a delay in updates? 15 minutes is an estimate honestly

There are no updates when charging, starting from 20%, the status doesn’t change so instead of the automation triggering at +80%, the device is charged 100%

It takes about 2h to go from 20 → 80%

Next time it’s charging check

Settings > companion app > troubleshooting > show and share logs and look for any failures may need to open the app once before charging and seeing what the error is about 15 minutes later.

1 Like

Hi Daniel & Waly

Wishing both you and your loved ones the very best for 2024!

I finally remembered to take these snapshots of the log:
Before starting to charge (rebooted though)

--------- beginning of main
30-12 21:40:44.349  1708  1708 D SensorReceiver: Received intent: android.intent.action.SCREEN_ON
30-12 21:40:44.352  1708  1708 D SensorReceiver: Sensor is_interactive corresponding to received event android.intent.action.SCREEN_ON is disabled, skipping sensors update
30-12 21:40:44.361  1708  1708 D ButtonWidget: Broadcast received: 
30-12 21:40:44.361  1708  1708 D ButtonWidget: Broadcast action: android.intent.action.SCREEN_ON
30-12 21:40:44.361  1708  1708 D ButtonWidget: AppWidgetId: -1
30-12 21:40:44.375  1708  1708 D ServerConnectionInfo: localUrl is: false, usesInternalSsid is: false, usesWifi is: true
30-12 21:40:44.386  1708  1708 D MediaPlayCtrlsWidget: Broadcast received: 
30-12 21:40:44.386  1708  1708 D MediaPlayCtrlsWidget: Broadcast action: android.intent.action.SCREEN_ON
30-12 21:40:44.386  1708  1708 D MediaPlayCtrlsWidget: AppWidgetId: -1
30-12 21:40:44.391  1708  1708 D ServerConnectionInfo: localUrl is: false, usesInternalSsid is: false, usesWifi is: true
30-12 21:40:44.414  1708  1708 D ServerConnectionInfo: localUrl is: false, usesInternalSsid is: false, usesWifi is: true
30-12 21:40:44.560  1708  1708 D SensorReceiver: Received intent: android.intent.action.SCREEN_OFF
30-12 21:40:44.564  1708  1708 D SensorReceiver: Sensor is_interactive corresponding to received event android.intent.action.SCREEN_OFF is disabled, skipping sensors update
30-12 21:40:44.565  1708  1708 D ButtonWidget: Broadcast received: 
30-12 21:40:44.565  1708  1708 D ButtonWidget: Broadcast action: android.intent.action.SCREEN_OFF
30-12 21:40:44.565  1708  1708 D ButtonWidget: AppWidgetId: -1
30-12 21:40:44.568  1708  1708 D MediaPlayCtrlsWidget: Broadcast received: 
30-12 21:40:44.568  1708  1708 D MediaPlayCtrlsWidget: Broadcast action: android.intent.action.SCREEN_OFF
30-12 21:40:44.568  1708  1708 D MediaPlayCtrlsWidget: AppWidgetId: -1
30-12 21:40:49.697  1708  1708 I BeaconManager: BeaconManager started up on pid 1708 named 'io.homeassistant.companion.android.minimal' for application package 'io.homeassistant.companion.android.minimal'.  isMainProcess=true
30-12 21:40:50.619  1708  1857 I SensorReceiver: Sensor updates and sync completed
30-12 21:44:11.981  1708  1708 W ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@ea04ea
30-12 21:44:12.111  1708  1708 W android.minima: Accessing hidden method Landroid/view/WindowInsetsAnimationController;->getHiddenStateInsets()Landroid/graphics/Insets; (blacklist, linking, denied)
30-12 21:44:12.112  1708  1708 W android.minima: Accessing hidden method Landroid/view/View;->getWindowInsetsController()Landroid/view/WindowInsetsController; (blacklist, linking, denied)
30-12 21:44:12.120  1708  1708 W android.minima: Accessing hidden method Landroid/view/WindowInsetsAnimationController;->getShownStateInsets()Landroid/graphics/Insets; (blacklist, linking, denied)
30-12 21:44:12.121  1708  1708 W android.minima: Accessing hidden method Landroid/view/WindowInsetsAnimationController;->getCurrentInsets()Landroid/graphics/Insets; (blacklist, linking, denied)
30-12 21:44:12.330  1708  1708 I SurfaceFactory: [static] sSurfaceFactory = com.mediatek.view.impl.SurfaceFactoryImpl@84e8ea2
30-12 21:44:12.488  1708  1708 W android.minima: Class androidx.compose.runtime.snapshots.SnapshotStateMap failed lock verification and will run slower.
30-12 21:44:12.489  1708  1708 W android.minima: Common causes for lock verification issues are non-optimized dex code
30-12 21:44:12.489  1708  1708 W android.minima: and incorrect proguard optimizations.
30-12 21:44:12.515  1708  1708 W android.minima: Accessing hidden method Landroid/view/WindowInsets$Type;->ime()I (blacklist, linking, denied)
30-12 21:44:12.520  1708  1708 W android.minima: Accessing hidden method Landroid/graphics/Canvas;->drawPatch(Landroid/graphics/NinePatch;Landroid/graphics/Rect;Landroid/graphics/Paint;)V (greylist-max-o, linking, denied)
30-12 21:44:12.520  1708  1708 W android.minima: Accessing hidden method Landroid/graphics/Canvas;->drawPatch(Landroid/graphics/NinePatch;Landroid/graphics/RectF;Landroid/graphics/Paint;)V (greylist-max-o, linking, denied)
30-12 21:44:12.522  1708  1708 W android.minima: Accessing hidden method Landroid/view/WindowInsetsController;->show(I)V (blacklist, linking, denied)
30-12 21:44:12.526  1708  1708 W android.minima: Accessing hidden method Landroid/view/WindowInsetsController;->hide(I)V (blacklist, linking, denied)
30-12 21:44:12.583  1708  1708 W android.minima: Accessing hidden method Landroid/content/res/Resources$Theme;->getKey()Landroid/content/res/Resources$ThemeKey; (greylist-max-o, reflection, denied)
30-12 21:44:12.661  1708  1708 E GraphicExt: Can't load libboost_ext_fwk
30-12 21:44:12.661  1708  1708 E GraphicExt: GraphicExtModuleLoader::CreateGraphicExtInstance false
30-12 21:44:12.663  1708  3834 I GPUD    : @gpudInitialize: successfully initialized with GL, dbg=0 mmdump_dbg=0 mmpath_dbg=0
30-12 21:44:12.704  1708  3834 W Gralloc3: mapper 3.x is not supported
30-12 21:44:12.708  1708  3834 E ion     : ioctl c0044901 failed with code -1: Invalid argument
30-12 21:44:12.815  1708  1708 W ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@40116c3
30-12 21:44:12.843  1708  3844 I System.out: [socket]:check permission begin!
30-12 21:44:13.582  1708  3884 E linker  : library "" ("/system/lib64") needed or dlopened by "/system/lib64/vndk-sp-29/libRS_internal.so" is not accessible for the namespace: [name="(default)", ld_library_paths="", default_library_paths="/system/lib64:/system/product/lib64", permitted_paths="/system/lib64/drm:/system/lib64/extractors:/system/lib64/hw:/system/product/lib64:/system/framework:/system/app:/system/priv-app:/vendor/framework:/vendor/app:/vendor/priv-app:/system/vendor/framework:/system/vendor/app:/system/vendor/priv-app:/odm/framework:/odm/app:/odm/priv-app:/oem/app:/system/product/framework:/system/product/app:/system/product/priv-app:/data:/mnt/expand:/apex/com.android.runtime/lib64/bionic:/system/lib64/bootstrap"]
30-12 21:44:13.582  1708  3884 E RenderScript: Failed loading RS driver: dlopen failed: library "" needed or dlopened by "/system/lib64/vndk-sp-29/libRS_internal.so" is not accessible for the namespace "rs"
30-12 21:44:13.582  1708  3884 E RenderScript: Failed to load runtime , loading default
30-12 21:44:13.695  1708  3889 W IMGSRV  : glGetString:4370: Override GL_RENDERER PowerVR SGX Clark 
30-12 21:44:13.708  1708  3889 I chatty  : uid=10187(io.homeassistant.companion.android.minimal) Chrome_InProcGp identical 2 lines
30-12 21:44:13.729  1708  3889 W IMGSRV  : glGetString:4370: Override GL_RENDERER PowerVR SGX Clark 
30-12 21:44:13.785  1708  3889 W AudioCapabilities: Unsupported mime audio/x-adpcm-ms
30-12 21:44:13.785  1708  3889 W AudioCapabilities: Unsupported mime audio/x-adpcm-dvi-ima
30-12 21:44:13.785  1708  3889 W AudioCapabilities: Unsupported mime audio/alac
30-12 21:44:13.785  1708  3889 W AudioCapabilities: Unsupported mime audio/ape
30-12 21:44:13.786  1708  3889 W AudioCapabilities: Unsupported mime audio/x-ms-wma
30-12 21:44:13.795  1708  3889 W VideoCapabilities: Unrecognized profile/level 1/32 for video/mp4v-es
30-12 21:44:13.795  1708  3889 W VideoCapabilities: Unrecognized profile/level 32768/2 for video/mp4v-es
30-12 21:44:13.795  1708  3889 W VideoCapabilities: Unrecognized profile/level 32768/64 for video/mp4v-es
30-12 21:44:13.799  1708  3889 W VideoCapabilities: Unsupported mime video/x-ms-wmv
30-12 21:44:13.801  1708  3889 W VideoCapabilities: Unsupported mime video/xvid
30-12 21:44:13.806  1708  3889 W VideoCapabilities: Unrecognized profile/level 1/32 for video/mp4v-es
30-12 21:44:13.859  1708  3889 W IMGSRV  : glGetString:4370: Override GL_RENDERER PowerVR SGX Clark 
30-12 21:44:13.876  1708  3889 I chatty  : uid=10187(io.homeassistant.companion.android.minimal) Chrome_InProcGp identical 4 lines
30-12 21:44:13.877  1708  3889 W IMGSRV  : glGetString:4370: Override GL_RENDERER PowerVR SGX Clark 
30-12 21:44:14.061  1708  1708 I Choreographer: Skipped 74 frames!  The application may be doing too much work on its main thread.
30-12 21:44:14.097  1708  1708 E GraphicExt: GraphicExtModuleLoader::CreateGraphicExtInstance false
30-12 21:44:14.166  1708  3834 I OpenGLRenderer: Davey! duration=1342ms; Flags=1, IntendedVsync=241163286472, Vsync=242396619830, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=242403157091, AnimationStart=242403206629, PerformTraversalsStart=242406711629, DrawStart=242445320783, SyncQueued=242452266091, SyncStart=242454165168, IssueDrawCommandsStart=242454365552, SwapBuffers=242505804475, FrameCompleted=242507535783, DequeueBufferDuration=0, QueueBufferDuration=1033000, 
30-12 21:44:14.386  1708  3889 W IMGSRV  : glGetString:4370: Override GL_RENDERER PowerVR SGX Clark 
30-12 21:44:14.393  1708  3889 W IMGSRV  : glGetString:4370: Override GL_RENDERER PowerVR SGX Clark 
30-12 21:44:14.436  1708  1708 E WebviewActivity: onReceivedHttpError: 404 : Not Found for: http://172.16.0.4:8123/local/ThemeOverride.js
30-12 21:44:14.496  1708  3889 W IMGSRV  : glGetString:4370: Override GL_RENDERER PowerVR SGX Clark 
30-12 21:44:14.881  1708  1857 I WebViewPresenterImpl: Found color -16537100.
30-12 21:44:14.883  1708  1857 I WebViewPresenterImpl: Found color -328966.
30-12 21:44:21.767  1708  1857 I WebViewPresenterImpl: Found color -15720924.
30-12 21:44:21.768  1708  1857 I WebViewPresenterImpl: Found color -15658735.
30-12 21:44:23.481  1708  1708 E WebviewActivity: onReceivedHttpError: 404 : Not Found for: http://172.16.0.4:8123/custom_components/webrtc/www/webrtc-camera.js
30-12 21:44:23.510  1708  1708 E WebviewActivity: onReceivedHttpError: 404 : Not Found for: http://172.16.0.4:8123/config-template-card.js
30-12 21:44:24.822  1708  3889 W IMGSRV  : glGetString:4370: Override GL_RENDERER PowerVR SGX Clark 
30-12 21:44:24.828  1708  3889 W IMGSRV  : glGetString:4370: Override GL_RENDERER PowerVR SGX Clark 
30-12 21:44:43.472  1708  1745 I android.minima: NativeAlloc concurrent copying GC freed 59587(2575KB) AllocSpace objects, 6(264KB) LOS objects, 47% free, 6663KB/12MB, paused 235us total 166.381ms
30-12 21:44:45.637  1708  1708 W ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@cb96665
30-12 21:44:45.910  1708  1708 E GraphicExt: GraphicExtModuleLoader::CreateGraphicExtInstance false
30-12 21:44:46.423  1708  3916 I SensorReceiver: Sensor updates and sync completed
30-12 21:44:56.830  1708  1708 W android.minima: Accessing hidden method Landroid/view/WindowInsets$Builder;->setVisible(IZ)Landroid/view/WindowInsets$Builder; (blacklist, linking, denied)
30-12 21:44:56.830  1708  1708 W android.minima: Accessing hidden method Landroid/view/Window;->getInsetsController()Landroid/view/WindowInsetsController; (blacklist, linking, denied)
30-12 21:44:56.831  1708  1708 W android.minima: Accessing hidden method Landroid/view/WindowInsets;->isVisible(I)Z (blacklist, linking, denied)
30-12 21:44:56.832  1708  1708 W android.minima: Accessing hidden method Landroid/view/WindowInsets;->getInsets(I)Landroid/graphics/Insets; (blacklist, linking, denied)
30-12 21:44:56.832  1708  1708 W android.minima: Accessing hidden method Landroid/view/WindowInsets$Builder;->setInsets(ILandroid/graphics/Insets;)Landroid/view/WindowInsets$Builder; (blacklist, linking, denied)
30-12 21:44:56.833  1708  1708 W android.minima: Accessing hidden method Landroid/view/WindowInsets$Type;->systemGestures()I (blacklist, linking, denied)
30-12 21:44:56.833  1708  1708 W android.minima: Accessing hidden method Landroid/view/WindowInsets$Type;->mandatorySystemGestures()I (blacklist, linking, denied)
30-12 21:44:56.834  1708  1708 W android.minima: Accessing hidden method Landroid/view/WindowInsets$Type;->tappableElement()I (blacklist, linking, denied)

Some time later, still while charging but the state of the sensor has not been updated until I wake the screen to get the log:

--------- beginning of main
30-12 22:45:10.391  1708  1745 W android.minima: Reducing the number of considered missed Gc histogram windows from 355 to 100
30-12 22:49:32.231  1708  1708 I Choreographer: Skipped 33 frames!  The application may be doing too much work on its main thread.
30-12 22:49:32.240  1708  1708 E GraphicExt: GraphicExtModuleLoader::CreateGraphicExtInstance false
30-12 22:49:32.701  1708  4884 I System.out: [socket]:check permission begin!
30-12 22:49:34.084  1708  4669 I WebViewPresenterImpl: Found color -15720924.
30-12 22:49:34.110  1708  4669 I WebViewPresenterImpl: Found color -15658735.
30-12 22:49:39.166  1708  1708 W ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@24e0864
30-12 22:49:39.292  1708  1708 E GraphicExt: GraphicExtModuleLoader::CreateGraphicExtInstance false
30-12 22:49:39.599  1708  4892 I System.out: [socket]:check permission begin!
30-12 22:49:39.963  1708  4653 I SensorReceiver: Sensor updates and sync completed

I can’t make anything out of it. :blush:

EDIT: in the meantime I updated the app to v2023.12.4, already before these logs

Have you tried unplugging the usb lead from the tablet? I have a similar issue here with discharging. If the tablet is connected to the usb charger, even with the charger off the battery level doesn’t update regularly or sometimes not at all. (in my case it updates while charging but not while discharging. My intention was to have it turn on the charger at 20% and off at 90% I think the usb data lines remain connected when the smart switch turns off the charger and this is confusing to some usb implementations.