#Force Companion app to use use mobile data / keep connection alive when WiFi loses connection

1 messages · Page 1 of 1 (latest)

fervent island
#

Whenever I leave my house, Home Assistant loses connection to my WiFi and reconnects using mobile data. When my phone is in my pocket, this takes about 10-20 seconds (whenever HA is opened on my Google Pixel 6), it's a little bit faster.

In this time, I want some information to be send to Home Assistant (for example, the distance to my car to automatically lock and unlock it), which come in at a delay while the HA app is switching connection from WiFi to Mobile.

Is there a way to force the Home Assistant Companion app to use Mobile/cellular data only, or keep a line over that connection as well, so WiFi connections don't cause a lag?

#

I've already tried with the AdGuard app, which has a Firewall build in to enable/disable WiFi or Cellular data for specific app, but that didn't work as intended: Whenever HA App is connected over WiFi, no connection can be made at all instead of routing this traffic over mobile.

#

On Linux I would just route an IP over a specific interface but I don't think I can do that without root on my Pixel. Maybe I can let Android tell Home Assistant that WiFi is metered and 4G/5G is unmetered...

chilly shore
#

if this was possible i imagine it would be from the phones OS level and not the app.
can you expose the ability to turn wifi off? that way you could have something trigger turning wifi off on your phone entirily when your heading out? that way it will already be on mobile when you need it to be? then switch it back on when your out of range so it resumes normal opporation? then can do the same when returning

#

something like: put the car keys on a hook with a sensor. so when you pick them up it turns wifi off on your phone

fervent island
#

The problem is, I don't know exactly when I'm leaving and I don't want to push a button or do something before-hand

#

Yeah, that would work when I'm at home, but I also disconnect WiFi when leaving work and walking to the car, for example

#

Or leaving friends and their WiFi

#

Thanks @chilly shore for thinking along

chilly shore
#

your going to struggle with a device that jumps connections. maybe you can make android force the issue but i dont know

fervent island
#

The alternative would to disable WiFi altogether, but I used 70GB on Youtube over WiFi last month

#

And I'm on a data plan

chilly shore
#

maybe if you use a udp based vpn like wireguard it would transition quicker? because it wouldnt nessasarily need to rehandshake. but it might not make a difference

fervent island
#

Hmm, good point. That could work

chilly shore
#

just looked on a phone looks like you can do it android (although might be version related)

fervent island
#

I already have a Wireguard tunnel here somewhere, should be easy to test. Too bad I can't specify an outgoing interface in the client config but still worth a shot

#

I've seen screenshots like that but my Pixel doesn't show that option. Im curious: If you disable WiFi data and are connected to WiFi, can you still connect to HA?

#

Or does it work like AdGuard so it blocks HA alltogether on WiFi?

chilly shore
#

apps - home assistant - mobile data usage

#

i dont have external access set up currently so i cant test

fervent island
#

I only have Backgrounddata and Unlimited mobile data

chilly shore
#

which android version are you on?

fervent island
#

I thnk 14 or 15, Google Pixel 6

#

Yeah Android 15

chilly shore
#

i am on 15 also but LinageOS. dont know if that makes a difference. maybe there is a hardware thing too

fervent island
#

Do you have root?

chilly shore
#

having LinageOS allows me to do whatever.

fervent island
#

for example your Browser and checking your IP?

chilly shore
#

sure give me a sec

fervent island
#

To verify it uses mobile while connected to Wifi?

chilly shore
#

tried it, and no it actually doesnt seem to work. it seems to block the app from connecting entirily when phone is connected to wifi

#

so thats a no go

fervent island
#

To give you some background: I bought a (used) car with keyless start/stop but not keyless access. I've setup a ble beacon using an old OnePlus One phone running Lineageos and the HA app to broadcast a beacon.

My phone has a beacon monitor enabled in the HA app and whenever I'm near an HA automation calls the VW API to open the car

#

And it works reasonably well, expect the Wifi disconnect causes too big of a delay

#

Great, thanks for testing! I think I will still experiment with LineageOS as that give me root and more options to force such a behaviour

#

Might be as simple as " ip route add 123.31.21.21/32 dev eth1"

chilly shore
#

probably worth trying WG setup to see if it helps. specially if you alreayd have it semi set up

fervent island
#

Yeah right, I'll give that a go in a bit and report back

chilly shore
#

i dont know how android handles network traffic in the background but it might be that easy yeah

fervent island
#

Another option I just thought of: Giving the OnePlus One in the car a SIM and turning it around: My phone being the beacon and the OPO the beacon monitor

chilly shore
#

yeah that could work

fervent island
#

Using Wireguard to tunnel the connection through did make a difference @chilly shore: I don't get the pop-up in Home Assistant anymore about it losing connection and reconnecting. However, it seems the updates from my phones beacon monitor now just get lost instead 😆 .

Need to do some more testing though, it could still save a little time.