Android Companion 2022.2: Local Push Notifications!

I noticed, after the last update, a big battery usage if i use websocket option. Which are the the contros in terms of usage if i don’t use that option? And more, is the number of created widgets affecting the battery usage or not?

The ability to customize the websocket notification to make it actually useful would be great. Then there would be less reason to hide it which can introduce issues with delivery. Add buttons, change the text (possibly dynamic text based on sensors if possible?)

Does this fallback to firebase if the socket is unavailable?

What happens if the socket isn’t available? Does it retry? Queue? These are important details we need to know please.

2 Likes

Reading this, I’ve now restarted 3x, not getting rid of this :frowning:

This is really an Android question. Without the persistent notification Android “can” terminate it to save memory. This is very device usage specific.

2 Likes

if the app cannot maintain a connection then yes the notification will go away, takes about 30 seconds for that check to occur.

Sorry we won’t do this, we have too many users who skip release notes and blog posts and end up creating an issue for a new feature where its not even an issue its that the feature is present. This pop-up only shows up once when you update the app.

The persistent notification is for the websocket connection, setting it to silent has no impact on the notifications itself

correct

HA core waits for a confirmation message from the app that it was received so it can remove it from the message queue.

If you set it to never it goes back to how things were

no as soon as you have 1 widget created instant widgets start working

you can place feature requests on github

yes it does fallback to FCM

The app does retries in the background based on your connection preference to maintain the connection.

Umm I think you posted in the wrong post :wink:

3 Likes

Done! RFE: Customizable text (and possibly more) for websocket persistent notification · Issue #2267 · home-assistant/android · GitHub

1 Like

Maybe I missed it, but is there a way to know its working with the local push vs using FCM?

Check notification history, it will list where the notification came from.

1 Like

Alright, I can probably survive if it’s only gonna happen once a month or so (not running beta) :slight_smile: thanks for taking the time to answer!

If I update the app and i skip a version doing so, will I get the changelog for both versions then in the same dialog?

Didn’t have history turned on. Did that and sent a few message through but not seeing anything obvious in the list that calls that out.

Hmm… I see it here, at the end of the date and time the notification was received.

2 Likes

Ooo I was looking at notification history on android not in the app! Didn’t know that was there. Thanks!

1 Like

The change log will only consist of the current month. It will show point releases but once a new monthly release is cut it will be different.

1 Like

if the app cannot maintain a connection then yes the notification will go away, takes about 30 seconds for that check to occur.

The Wi-Fi network is still up and I can access home assistant via the app. Is it expected that the app cannot maintain a connection in this circumstance when the network isn’t connected to the internet? I’ll need to test some more but it seems that it stops working when my phone recognizes that there is no internet connection, but until then it still works to send notification even without internet.

And in terms of battery drain 1 widget or 10 widgets is the same?

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