Android Companion 2022.2: Local Push Notifications!

yes and every user will have a different experience as each device is different.

It all depends on your setup, what external and internal URL is configured in the app. What URL was used by the app on the first connection etc… If you look at the logs under Companion App you should be able to see what URL is being used at the time of the disconnect. The app will try other URLs to reconnect but it all depends on your setup.

In the companion app I have “Home Assistant URL” as internal IP: http://192.168.1.231:8123/" the “Internal Connection URL” is the same and cannot be modified.

Note my app still works fine without internet, the issue I am seeing is that the websocket drops and losing ability to get local notifications sometime after I disconnect my router from the modem (drop internet connection), I worded it poorly above in regard to the app. The local notifications do work without internet for some time but drop seemingly when Android notices that there is no internet.

Took a look at the code quickly, have never looked before, I am unfamiliar with the language and platform so this might not actually matter at all but…

This line to me appears to indicate there is some internet connection requirement as part of websocket work.

From my quick search it appears that for newer versions of Android NetworkType.CONNECTED does a validation check that requires internet. Not sure if this is intended. I would have presumed websocket, meant for local notifications would not depend on internet connection. But I am admittedly naive in these areas.

Edit: Oops, not familiar with the posting platform, sorry for the deleted messages.

So the reason why this check is there is because Internet is indeed required when you are remote . The same check applies to sensor updates. The app needs to account for remote access in addition to local access.

I have tested a bit more, and immediately as the phone notices internet is lost (not actually when it is lost) is when the websocket goes down and notifications stop working.

So the question I would have is can the requirement for internet be dropped when the app is operating locally and doesn’t actually need internet for the websocket?

1 Like

Will this also work for Fire OS devices (where no Google services and no Firebase Messaging service is available)?

Can you create a feature request for this on GitHub so it doesn’t get lost in the comments?

Yup it works!

2 Likes

Thanks! First time filing: https://github.com/home-assistant/android/issues/2273 (filed with my current understanding of the issue).

I like the idea of the websockets. So far positive experience but I am seeing quite a different battery drain on 2 Google Pixels. Typically HA companion takes around 2-3%. On my wife’s phone (never even opened the app) its using around 7-8%. Just fyi for people.

Hi all,

could someone please tell me, what the benefit of this change is?

Just what I’ve gotten so far:

  1. if I choose ‘do not listen’ I won’t be notified at all, once my washing machine is done.
  2. if I use ‘only when the screen is turned on’, I need to be lucky, that I’m just checking my phone and the screen is on, when the machine is ready
  3. if I let it listen constantly, I need to be lucky that the battery did not die before the washing machine is ready

Is that correct? Is there a way (configuration) to use the old way? I mean, sometimes I’ve gotten the message a couple of minutes after the machine was ready, but at least it popped up.
Did someone run some tests to quantify the battery drain just to have some facts and to make a development decision?

Thank you,
Fridolin

What I understood is if you turn it off, it defaults back to normal FCM and pre-change connections. The alerting really then depends on Google’s FCM which can be delayed (like it was previously). websockets should be much faster. I turned mine off and I do indeed still see notifications and if I check notification history, I still get FCM tagged notifications.

Turning it off appears to correctly revert to the old way. Turning it on means much faster notifications and no google intermediate.

I am running some tests on my wife’s phone to quantify the change between off and always. She doesn’t use HA much so its a better test than my phone. She is also much more ‘consistent’ in her usage. My immediate reaction is that it uses more battery but might be knee-jerk reaction at this point. I’ll see.

2 Likes

Yup this is correct, FCM is the fallback so even if the app cannot make the persistent connection you can still expect to see FCM show up.

Has she had to change her charging habits due to the change? Once the first beta was live I went on my wifes phone and set the option to Always. I have not noticed her charging her phone more than she usually does and she hasn’t noticed a change either and she usually tells me when it drains like crazy.

The thing with battery life is that if you watch it all the time religiously then I think any user will say the app is draining battery. What it really comes down to is charging habits for those who don’t monitor it so closely. Now thats not to say this new feature won’t drain more battery because it would be silly for anyone to say that it doesn’t. Thats why charging habits are a better indication.

I get that back in the day with android battery life was a huge thing but a lot of changes were done to android since then and honestly battery life hasn’t been much of an issue since Android 8 or 9 which have been out for quite some time now.

For everyone else reading…

We have made a change in a hot fix that was released to Google yesterday as 2022.2.1. This change switches back to the default setting for Play Store installations to “Never”. If you already changed this setting the default change will not impact you. We also made some adjustments to the text of the settings page to make it more understandable. I hope this helps lessen some confusion around this new feature.

4 Likes

I’m noticing what seems to be a UI bug in the settings on my Samsung S20 FE 5G phone on Android 12. I cannot scroll from the page in the attached picture. Anyone else see this issue?

Edit: to clarify, that’s as far as I can scroll down

1 Like

I agree it is very difficult. Especially that the android screens will show ‘percent of usage’ which isn’t very useful. I noticed my battery dropped a lot but that can be placebo and maybe I was just using/checking it more. It is a very difficult thing to measure. I’ll be monitoring her usage and see. I can do some calculations on charging wth websockets on/off using the integration itself. Should give me a rough idea.

I’m not telling her anything so as not to introduce a placebo effect for her. She’s fairly consistent in her usage.

EDIT: I actually have an unused pixel that I am going to test with and without websockets. discharge time with zero activity, discharge time with screen on and home assistant active in foreground.

I should be able to add all the notifications I receive and let it just go for a number of cycles.

@calisro Thanks for answering my questions. I’ve switched it to off and got a message a couple of minutes later. So yes, the default fallback is working.
Let’s see what your battery test will show - maybe it makes sense to turn it back on :wink:

Thanks.

Anyone have an estimate on the usual delay for when f-droid ships the new version?

we do not maintain the fdroid app, you’ll want to ask them

1 Like

since they all have the same keys, you can just install the apk…

2 Likes

Thanks @calisro for the detailed clarification.

Has something changed in this version (2022.2) how the step_sensor works? Allthough i walk the same distances, numbers have dropped from 10000 to 40 steps. I use the minimal version b.t.w. Anyone else noticed the same?


SOLVED: The sollution was to give the app permission to the data.

1 Like