home-assistant / android

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

Huge battery comsumption of the WearOS app when HA is down. #2933

Open yzlnew opened 2 years ago

yzlnew commented 2 years ago

Home Assistant Android version: beta-2732-cabd41e6-full Android version: 12L Phone model: OnePlus 8Pro with Samsung Galaxy Watch 4 Classic Home Assistant version: 2022.9.5 Last working Home Assistant release (if known):

Description of problem: WearOS app rank top1 in battery usage even though my ha instance is offline. Traceback (if applicable, to get the logs you may refer to: https://companion.home-assistant.io/docs/troubleshooting/faqs/#android-crash-logs):

Screenshot of problem: Provided later.

Additional information:

dshokouhi commented 2 years ago

Can you let us know more about your usage? Do you have tiles? Are you using complications? Did you leave the sensors enabled?

dshokouhi commented 2 years ago

The app also has no idea if your HA instance is down until it tries to connect, it also needs to keep trying to see if the instance is back up otherwise how will it connect again. Curious to see if others have similar battery consumption. Could you share a picture of the drain?

dshokouhi commented 2 years ago

here is my drain, where the app does not show up. I have sensors enabled as well as tiles and complications.

image

yzlnew commented 2 years ago

The app also has no idea if your HA instance is down until it tries to connect, it also needs to keep trying to see if the instance is back up otherwise how will it connect again. Curious to see if others have similar battery consumption. Could you share a picture of the drain?

Update screenshots in op. I'm using tiles, no complications. Battery sensors are all enabled. It seems normal after I restart my HA instance back home, would report battery usage next charging cycle.

dshokouhi commented 2 years ago

It seems normal after I restart my HA instance back home,

so this happens when your server is in a hung state and needs to be restarted? I am not sure how much the app can do to solve that issue if its having connection issues to the server and the server needs to be restarted. The app needs to try to make a connection to send updates otherwise it cannot.

jpelgrom commented 2 years ago

so this happens when your server is in a hung state and needs to be restarted? I am not sure how much the app can do to solve that issue if its having connection issues to the server and the server needs to be restarted. The app needs to try to make a connection to send updates otherwise it cannot.

Unless you're actively using the app an online vs offline server shouldn't make that much of a difference, right (especially on Wear OS)? It's still making the same requests, just getting a different response. Nothing to keep alive/connected on a watch when the app is closed.

dshokouhi commented 2 years ago

Unless you're actively using the app an online vs offline server shouldn't make that much of a difference, right (especially on Wear OS)?

thats what I was thinking but if the server is in a bad state maybe the calls are taking too long to complete keeping things alive longer?

yzlnew commented 2 years ago

I can confirm it's caused by a down instance, because everything is fine after my instance is back online.

dshokouhi commented 2 years ago

What do you mean by down instance? Are you shutting down HA or is it inaccessible?

yzlnew commented 2 years ago

What do you mean by down instance? Are you shutting down HA or is it inaccessible?

My HA hang up on certain circumstances and can't be accessed (can't find out the root cause for now).

dshokouhi commented 2 years ago

If you are able to get the logcat errors we can see if there is anything we can do. I'm not sure what if anything the app can do in these cases. Are you sure the phone app doesn't have similar issue when this occurs? What kind of setup do you have for the server?

dshokouhi commented 1 year ago

For the past 36 hours my own HA instance has been down. I am not experiencing any worse drain than when it's up. There must be some other error being encountered here.

Jonoox commented 1 year ago

I can also confirm high battery drain by Home Assistant app when HA server is down. My HA server won't boot up after power outage on it's own and watch app battery usage skyrocketed. OnePlus 7 Pro with Samsung Galaxy Watch 4. Phone app doesn't seem to be affected that much? Tho my phone battery died earlier than normal today, yet HA app is like 0.5% on phone's battery stats so this may be coincidence. Or is it?

Screenshot_2022-12-05-17-20-31-51_7b142989cde9e3e82c42c360a14f17f0

dshokouhi commented 1 year ago

@Jonoox can you please confirm that you are on teh latest version 2022.11.0 ?

Jonoox commented 1 year ago

@Jonoox can you please confirm that you are on teh latest version 2022.11.0 ?

I confirm, it's Wear OS [v.2022.11.0]. On the phone it's beta-2914-23e65c49-full if it matters. I had default sensors enabled(battery sensor I think), I had these two available tiles on right screen but they were empty as I haven't really started to use and set the app properly.

dshokouhi commented 1 year ago

This morning my HA server was down for a few hours but my pixel watch had very minimal drain, same as normal when im sleeping :) When you guys see this high drain can you try to get us the on device logs using either android studio or adb logcat? Unfortunately there is no easy way to get the logs. I would like to see what type of communication is going on when there is high drain.

asides from using tiles do you also use the entity state complication on the watch face?

Jonoox commented 1 year ago

Ah, yeah by "two available tiles" I meant both tile complication and entity state complication. Both empty with no entities added. I turned back the battery sensors to keep everything as it was today. Tomorrow will keep an eye on battery and will try to get logcat if something happens. My HA will be not running until tomorrow evening so maybe I'll catch something. That's log from few hours back, not sure if it's still draining because of too short timespan. Can't see anything wrong with it but maybe you'll get something. If not, I'll report back later.

Logs ``` Linia 3726: 12-05 19:20:58.318 16292 31568 D WCS : [ComplicationController]scheduleImmediateUpdateForAllFromProvider ComponentInfo{io.homeassistant.companion.android/io.homeassistant.companion.android.complications.EntityStateDataSourceService} Linia 4328: 12-05 19:21:08.449 573 911 D BaseRestrictionMgr: callerPkgName:android calleePackage:io.homeassistant.companion.android action:android.intent.action.SCREEN_OFF for type:broadcast Linia 5045: 12-05 19:21:14.064 573 911 D BaseRestrictionMgr: callerPkgName:android calleePackage:io.homeassistant.companion.android action:android.intent.action.SCREEN_ON for type:broadcast Linia 5049: 12-05 19:21:14.074 573 911 D BaseRestrictionMgr: callerPkgName:android calleePackage:io.homeassistant.companion.android action:android.intent.action.SCREEN_ON for type:broadcast Linia 5052: 12-05 19:21:14.087 573 609 D BaseRestrictionMgr: callerPkgName:io.homeassistant.companion.android calleePackage:com.google.android.wearable.app action:android.support.wearable.complications.ACTION_REQUEST_UPDATE_ALL for type:broadcast Linia 5054: 12-05 19:21:14.090 16292 31569 D WCS : [ComplicationController]scheduleImmediateUpdateForAllFromProvider ComponentInfo{io.homeassistant.companion.android/io.homeassistant.companion.android.complications.EntityStateDataSourceService} Linia 6184: 12-05 19:21:24.695 573 8418 D BaseRestrictionMgr: callerPkgName:android calleePackage:io.homeassistant.companion.android action:android.intent.action.SCREEN_OFF for type:broadcast Linia 19218: 12-05 20:14:39.600 573 10116 D BaseRestrictionMgr: callerPkgName:android calleePackage:io.homeassistant.companion.android action:android.intent.action.SCREEN_ON for type:broadcast Linia 19222: 12-05 20:14:39.606 573 10116 D BaseRestrictionMgr: callerPkgName:android calleePackage:io.homeassistant.companion.android action:android.intent.action.SCREEN_ON for type:broadcast Linia 19225: 12-05 20:14:39.610 573 609 D BaseRestrictionMgr: callerPkgName:io.homeassistant.companion.android calleePackage:com.google.android.wearable.app action:android.support.wearable.complications.ACTION_REQUEST_UPDATE_ALL for type:broadcast Linia 19226: 12-05 20:14:39.612 16292 32316 D WCS : [ComplicationController]scheduleImmediateUpdateForAllFromProvider ComponentInfo{io.homeassistant.companion.android/io.homeassistant.companion.android.complications.EntityStateDataSourceService} Linia 19474: 12-05 20:14:42.433 573 573 D BaseRestrictionMgr: callerPkgName:android calleePackage:io.homeassistant.companion.android action:null for type:bindService Linia 19491: 12-05 20:14:42.550 23260 23260 D sysproxy: [T:245] Establishing a new TCP stream to: 192.168.1.111:8123 (uid=10135) (package=io.homeassistant.companion.android) Linia 19492: 12-05 20:14:42.558 23260 23260 D sysproxy: [T:246] Establishing a new TCP stream to: 192.168.1.111:8123 (uid=10135) (package=io.homeassistant.companion.android) Linia 19640: 12-05 20:14:45.032 30960 32760 E WebSocketRepository: at io.homeassistant.companion.android.common.data.HomeAssistantApis$configureOkHttpClient$$inlined$-addNetworkInterceptor$1.intercept(OkHttpClient.kt:1080) Linia 19662: 12-05 20:14:45.035 30960 25886 I WM-WorkerWrapper: Worker result SUCCESS for Work [ id=19e8f01a-91ac-4110-b91f-588fc6199b62, tags={ io.homeassistant.companion.android.sensors.SensorWorker } ] Linia 20454: 12-05 20:14:54.659 573 3340 D BaseRestrictionMgr: callerPkgName:android calleePackage:io.homeassistant.companion.android action:android.intent.action.SCREEN_OFF for type:broadcast Linia 22942: 12-05 20:22:46.398 573 1237 D BaseRestrictionMgr: callerPkgName:android calleePackage:io.homeassistant.companion.android action:android.intent.action.SCREEN_ON for type:broadcast Linia 22946: 12-05 20:22:46.405 573 1237 D BaseRestrictionMgr: callerPkgName:android calleePackage:io.homeassistant.companion.android action:android.intent.action.SCREEN_ON for type:broadcast Linia 22953: 12-05 20:22:46.435 573 609 D BaseRestrictionMgr: callerPkgName:io.homeassistant.companion.android calleePackage:com.google.android.wearable.app action:android.support.wearable.complications.ACTION_REQUEST_UPDATE_ALL for type:broadcast Linia 22964: 12-05 20:22:46.446 16292 31569 D WCS : [ComplicationController]scheduleImmediateUpdateForAllFromProvider ComponentInfo{io.homeassistant.companion.android/io.homeassistant.companion.android.complications.EntityStateDataSourceService} Linia 23488: 12-05 20:22:51.645 573 2913 D BaseRestrictionMgr: callerPkgName:android calleePackage:io.homeassistant.companion.android action:android.intent.action.SCREEN_OFF for type:broadcast Linia 24757: 12-05 20:26:25.257 573 2913 D BaseRestrictionMgr: callerPkgName:android calleePackage:io.homeassistant.companion.android action:android.intent.action.SCREEN_ON for type:broadcast Linia 24762: 12-05 20:26:25.264 573 2913 D BaseRestrictionMgr: callerPkgName:android calleePackage:io.homeassistant.companion.android action:android.intent.action.SCREEN_ON for type:broadcast Linia 24765: 12-05 20:26:25.273 573 609 D BaseRestrictionMgr: callerPkgName:io.homeassistant.companion.android calleePackage:com.google.android.wearable.app action:android.support.wearable.complications.ACTION_REQUEST_UPDATE_ALL for type:broadcast Linia 24767: 12-05 20:26:25.285 16292 31569 D WCS : [ComplicationController]scheduleImmediateUpdateForAllFromProvider ComponentInfo{io.homeassistant.companion.android/io.homeassistant.companion.android.complications.EntityStateDataSourceService} Linia 25684: 12-05 20:26:40.303 573 2913 D BaseRestrictionMgr: callerPkgName:android calleePackage:io.homeassistant.companion.android action:android.intent.action.SCREEN_OFF for type:broadcast Linia 26868: 12-05 20:31:05.198 573 573 D BaseRestrictionMgr: callerPkgName:android calleePackage:io.homeassistant.companion.android action:null for type:bindService Linia 26881: 12-05 20:31:05.277 23260 23260 D sysproxy: [T:250] Establishing a new TCP stream to: 192.168.1.111:8123 (uid=10135) (package=io.homeassistant.companion.android) Linia 26882: 12-05 20:31:05.282 23260 23260 D sysproxy: [T:251] Establishing a new TCP stream to: 192.168.1.111:8123 (uid=10135) (package=io.homeassistant.companion.android) Linia 26980: 12-05 20:31:07.762 30960 32760 E WebSocketRepository: at io.homeassistant.companion.android.common.data.HomeAssistantApis$configureOkHttpClient$$inlined$-addNetworkInterceptor$1.intercept(OkHttpClient.kt:1080) Linia 27002: 12-05 20:31:07.769 30960 25876 I WM-WorkerWrapper: Worker result SUCCESS for Work [ id=19e8f01a-91ac-4110-b91f-588fc6199b62, tags={ io.homeassistant.companion.android.sensors.SensorWorker } ] Linia 33929: 12-05 20:55:09.747 573 1166 D BaseRestrictionMgr: callerPkgName:android calleePackage:io.homeassistant.companion.android action:android.intent.action.SCREEN_ON for type:broadcast Linia 33946: 12-05 20:55:09.769 573 1166 D BaseRestrictionMgr: callerPkgName:android calleePackage:io.homeassistant.companion.android action:android.intent.action.SCREEN_ON for type:broadcast Linia 33952: 12-05 20:55:09.782 573 609 D BaseRestrictionMgr: callerPkgName:io.homeassistant.companion.android calleePackage:com.google.android.wearable.app action:android.support.wearable.complications.ACTION_REQUEST_UPDATE_ALL for type:broadcast Linia 34006: 12-05 20:55:09.917 16292 31569 D WCS : [ComplicationController]scheduleImmediateUpdateForAllFromProvider ComponentInfo{io.homeassistant.companion.android/io.homeassistant.companion.android.complications.EntityStateDataSourceService} Linia 34469: 12-05 20:55:12.720 573 573 D BaseRestrictionMgr: callerPkgName:android calleePackage:io.homeassistant.companion.android action:null for type:bindService Linia 34537: 12-05 20:55:12.984 23260 23260 D sysproxy: [T:259] Establishing a new TCP stream to: 192.168.1.111:8123 (uid=10135) (package=io.homeassistant.companion.android) Linia 34548: 12-05 20:55:13.025 23260 23260 D sysproxy: [T:260] Establishing a new TCP stream to: 192.168.1.111:8123 (uid=10135) (package=io.homeassistant.companion.android) Linia 35147: 12-05 20:55:15.443 30960 1386 E WebSocketRepository: at io.homeassistant.companion.android.common.data.HomeAssistantApis$configureOkHttpClient$$inlined$-addNetworkInterceptor$1.intercept(OkHttpClient.kt:1080) Linia 35169: 12-05 20:55:15.445 30960 25886 I WM-WorkerWrapper: Worker result SUCCESS for Work [ id=19e8f01a-91ac-4110-b91f-588fc6199b62, tags={ io.homeassistant.companion.android.sensors.SensorWorker } ] Linia 36227: 12-05 20:55:18.075 573 1237 D BaseRestrictionMgr: callerPkgName:android calleePackage:io.homeassistant.companion.android action:android.intent.action.SCREEN_OFF for type:broadcast Linia 36604: 12-05 20:55:18.613 573 1166 D BaseRestrictionMgr: callerPkgName:android calleePackage:io.homeassistant.companion.android action:android.intent.action.SCREEN_ON for type:broadcast Linia 36608: 12-05 20:55:18.622 573 1166 D BaseRestrictionMgr: callerPkgName:android calleePackage:io.homeassistant.companion.android action:android.intent.action.SCREEN_ON for type:broadcast Linia 36615: 12-05 20:55:18.631 573 609 D BaseRestrictionMgr: callerPkgName:io.homeassistant.companion.android calleePackage:com.google.android.wearable.app action:android.support.wearable.complications.ACTION_REQUEST_UPDATE_ALL for type:broadcast Linia 36617: 12-05 20:55:18.633 16292 2034 D WCS : [ComplicationController]scheduleImmediateUpdateForAllFromProvider ComponentInfo{io.homeassistant.companion.android/io.homeassistant.companion.android.complications.EntityStateDataSourceService} Linia 37511: 12-05 20:55:33.606 573 1237 D BaseRestrictionMgr: callerPkgName:android calleePackage:io.homeassistant.companion.android action:android.intent.action.SCREEN_OFF for type:broadcast Linia 42839: 12-05 21:10:54.650 573 10116 D BaseRestrictionMgr: callerPkgName:android calleePackage:io.homeassistant.companion.android action:android.intent.action.SCREEN_ON for type:broadcast Linia 42855: 12-05 21:10:54.665 573 10116 D BaseRestrictionMgr: callerPkgName:android calleePackage:io.homeassistant.companion.android action:android.intent.action.SCREEN_ON for type:broadcast Linia 42858: 12-05 21:10:54.670 573 609 D BaseRestrictionMgr: callerPkgName:io.homeassistant.companion.android calleePackage:com.google.android.wearable.app action:android.support.wearable.complications.ACTION_REQUEST_UPDATE_ALL for type:broadcast Linia 42860: 12-05 21:10:54.674 16292 2034 D WCS : [ComplicationController]scheduleImmediateUpdateForAllFromProvider ComponentInfo{io.homeassistant.companion.android/io.homeassistant.companion.android.complications.EntityStateDataSourceService} ```
dshokouhi commented 1 year ago

Ah, yeah by "two available tiles" I meant both tile complication and entity state complication.

We actually have 2 tiles and 1 complication.

Both empty with no entities added.

I would definitely remove them if they are not being used

The logs look like you are filtering by homeassistant and they are incomplete as a result. For example this points to an error but we don't really know what.

    Linia 26980: 12-05 20:31:07.762 30960 32760 E WebSocketRepository:  at io.homeassistant.companion.android.common.data.HomeAssistantApis$configureOkHttpClient$$inlined$-addNetworkInterceptor$1.intercept(OkHttpClient.kt:1080)
Jonoox commented 1 year ago

Pastebin wouldn't accept big file so there you go https://drive.google.com/file/d/1Fc8bnc6WVWEJTdTRB26XRACaIbjqvNBZ/view?usp=share_link

dshokouhi commented 1 year ago

ok I can see the following error.

12-05 20:14:45.032 30960   318 E WebSocketRepository: Websocket: onFailure
12-05 20:14:45.032 30960   318 E WebSocketRepository: java.io.IOException: unexpected end of stream on http://192.168.1.111:8123/...

Interesting error, personally I would expect to see request timed out or something else but not an end of stream. Almost suggests like its able to talk but not really 🤔

Jonoox commented 1 year ago

It can't really talk to any HA server because now I'm not even on my home network and there's no device here on 192.168.1.111 that could respond somehow.

Jonoox commented 1 year ago

Here's log from the night. https://drive.google.com/file/d/1SeHhdoq5206Iqi7iHZYRXRR9rU8zge5W/view?usp=drivesdk No complications used this time at all, only battery sensors turned on. Home Assistant app battery usage went to 10.5% and battery was also used more than before so there should be something in this log.

dshokouhi commented 1 year ago

I do not see any errors or attempt to communicate out. At this point we may need a developer who experiences this issue to take a closer look. I would also recommend fixing the issue with HA going down as it seems to put the server in a bad state which may also be the cause of the issue.

Jonoox commented 1 year ago

To add to this - since I've set up better HA server with cloudflare routing so my watch can access HA everytime and everywhere I haven't seen battery drain problem at all. I have all tiles enabled and even watchface complication that seems to be updating everytime I wake up the watch, the HA app stays below 1% of battery usage.

tstill88 commented 1 year ago

Im seeing a massive drain of battery from HA on my Fossil Gen 5. Watch last at max maybe 4 - 5 hours with HA consuming 38% of the battery. For me no issues with my instance not being reachable either

dshokouhi commented 1 year ago

Im seeing a massive drain of battery from HA on my Fossil Gen 5. Watch last at max maybe 4 - 5 hours with HA consuming 38% of the battery. For me no issues with my instance not being reachable either

It would be helpful to know things like if you use tiles or complications and what sensors you enabled.

alexanderi96 commented 1 year ago

I also have problems of battery drain with HA on my Galaxy watch 5 pro, specially when I'm not @home.

dshokouhi commented 1 year ago

I also have problems of battery drain with HA on my Galaxy watch 5 pro, specially when I'm not @home.

Is your instance remotely accessible?

alexanderi96 commented 1 year ago

Is your instance remotely accessible?

No, I only use it on the local network atm. Can it be set up to test connections only if I'm connected to my home network and sleep otherwise?

Huber1 commented 1 year ago

Cam confirm this issue still exists. My HA instance is not accessible remotely. As soon as I leave my home, the battery drain goes down very fast (in Homeoffice battery holds normal). I'm sure that HA is the issue. I don't have many apps installed and uninstalling home assistant solved it.

dshokouhi commented 1 year ago

Just out of curiosity what do you expect to get out of the Wear OS app if your server is not remotely accessible? The app actually prefers to use the external URL as the app does not have any URL switching being done. Personally I went on a cruise and did not experience any crazy drain as mentioned here when my server could not be reached. Are you guys using tiles and complications that may request teh app to update its state when teh scree turns on?

Huber1 commented 1 year ago

Nope. Just the app installed. I can post my versions when I'm home. I'm working in making my instance accessible, but ATM it is not the case

dshokouhi commented 1 year ago

Nope. Just the app installed. I can post my versions when I'm home. I'm working in making my instance accessible, but ATM it is not the case

so all you did was install the app and login? did you enable any sensors or anything?

Huber1 commented 1 year ago

yes, in the phone app i disabled most of the sensors. i don't know if i can manage sensors on the watch separately, if yes, i didn't change anything

iulko commented 4 months ago

Could the app check if it has more than 1 connection to the instance at the time and close not needed ones or timeout them automatically?

iulko commented 4 months ago

https://mastodon.world/@Mer__edith/111563866152334347