HA app notifications when disconnected from home wifi

Hi, I set up an automation such that, when I leave the house, the door sensor notifies me via email and via the Companion app.

I am surprised that the app can notify me even if I am not connected to the home wifi network.

I was not expecting that, since I am not subscribed to the Nabu Casa cloud service.

It is what I want, but I wonder how it works.

How can the app notify me? Does the local HA instance keep a connection to the Android app via the Internet?

Thank you

Can you use your app outside your wifi network?

I have opened up my network, so i can access it from anywhere, and my notifications work fine anywhere , no need for nabu casa :wink:

No, I can’t. And that makes sense, because it is a private IP. I cannot access it from the outside.

I plan to configure Wireguard VPN access on the HA system (a Raspberry PI), and port forwarding on the router towards it. But, until then, I cannot access HA from outside the home wifi network.

I wonder if there is a service that I am not aware of that allows my phone to receive these notifications in the Companion app, while connected to the SIM mobile data.

It uses Google FCM service and, AFAIK, is free but rate limited to 500 notifications per day.

Once you set Wireguard up, you can flip notifications to use a web socket instead. It’s a direct connection between HA and the app so there’s no limit and they’re generally faster.

3 Likes

I see. It does not sound very privacy-friendly, if it relies on Google’s servers.

I looked into the Companion git repo at GitHub - home-assistant/android: 📱 Home Assistant Companion for Android

There, they mention:

If you do not generate your own file FCM push notification will never work, only websocket notifications will

But I am not sure whether it refers only to the development environment setup.

I feel that if something relied on a third-party service (i.e. Google), there would be a big warning somewhere in HA about privacy implications. But I did not see any such warning during setup.

Somehow, the phone is reachable from the HA instance while the phone is not connected to the same local network. That means that my phone is communicating its new IP to some service on the Internet. And HA is contacting the same service to fetch the phone’s IP, and send notifications to it. It could totally be FCM but… no mention of it, anywhere?

Are there other ways around it?

I will try reading the source code but, in case someone knows more, that would help me a lot.

In the meantime, I thank you all for contributing your answers.

1 Like

tis documented you just missed it.

https://companion.home-assistant.io/docs/notifications/notification-details

use the minimal build not found in teh play store to avoid google services, also mentioned in the docs

https://companion.home-assistant.io/docs/core/android-flavors

2 Likes

Thanks for the links.

In an app that is privacy-focused, I feel this piece of information should be shown to the end user, both in HA and in the Companion apps.

That way, the user finds out that there are two apps, and that there is a reason for it.

I understand that, for a mobile app developer, it is close to obvious that push notifications are not a thing without Google Play Services. But an end user might not be aware of this. I found out by hitting the incident.

Which leaves me feeling: is there something else leaking information to third-party services, without explicit consent? Anything else I should be aware of?

Thanks for sharing the knowledge.

No, HA is pushing the notification to the FCM instance in the cloud which relays it to the app on your phone. No trading of IP addresses per se.

Correct, this is referring to if you’re building the app yourself.

Regardless of which app (full or minimal) one is using?

only the full version has the google services API for firebase messaging. The full version is the play store version.

Another noteworthy link: Local Push | Home Assistant Companion Docs

@dshokouhi Is HA aware of whether it is sending a notification to a FCM-equipped app?

Because from @FriedCheese answer, I gather that it is. But not from yours?

I have now installed the “minimal” version.

If you are using the minimal flavor you will want to keep this setting as “Always”

I wonder why this recommendation, in case one only wants notifications at home.

yes the apps notify the server when its using the websocket instead of FCM. FCM is only used if the token is provided. there are error messages around it if its not working properly.

up to the user, most users want notifications all the time

1 Like

You just bake this into the automation/script/etc. that’s pushing the notification. You just write in a condition to only push the notification if your location is “home”.