home-assistant / android

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

High Accuracy mode does not turn off when leaving set zone #4353

Open angrycatmeowmeow opened 1 month ago

angrycatmeowmeow commented 1 month ago

Home Assistant Android app version(s): 2024.4.1-full Android version(s): 14 Device model(s): Samsung Z Fold 4 Home Assistant version: 2024.4.3 Last working Home Assistant release (if known):

Description of problem, include YAML if issue is related to notifications: I have two zones that have a small overlap, home and the_block that should enable high accuracy mode when also connected to the Bluetooth of either of my cars. I start in home, and enter into the_block on my way out, but high accuracy mode does not turn off when I leave these zones. When I start my journey outside of these zones, high accuracy mode turns on as it should only when I enter either zone. As far as I can tell from cross referencing the logs and my location history, the logs show I was in the zone when my location history shows I was far outside of the zone.

Companion App Logs: homeassistant_companion_log_3-19-2024_8-48-35.txt

Screenshot or video of problem: Screenshot_20240419_085047_Home Assistant

Additional information:

dshokouhi commented 1 month ago

received zone update and turned on

04-19 08:40:16.552 25206 25206 D LocBroadcastReceiver: Received geofence update.
04-19 08:40:16.557 25206 17886 D LocBroadcastReceiver: Last Location: 
04-19 08:40:16.557 25206 17886 D LocBroadcastReceiver: Coords:(lat431872, -long800414)
04-19 08:40:16.557 25206 17886 D LocBroadcastReceiver: Accuracy: 20.0
04-19 08:40:16.557 25206 17886 D LocBroadcastReceiver: Bearing: 269.0
04-19 08:40:16.559 25206 17886 D LocBroadcastReceiver: Begin evaluating if location update should be skipped
04-19 08:40:16.559 25206 17886 D LocBroadcastReceiver: Received location that is 74 milliseconds old, 1713530416485 compared to 1713530416559 with source fused
04-19 08:40:16.562 25206 19957 D ServerConnectionInfo: localUrl is: true, usesInternalSsid is: false, usesWifi is: false
04-19 08:40:16.566 25206 17886 D ServerConnectionInfo: localUrl is: true, usesInternalSsid is: false, usesWifi is: false
04-19 08:40:16.610 25206 19960 D LocBroadcastReceiver: High accuracy mode enabled, because defined ([74:6F:F7:A8:8F:2C, BC:30:7E:95:CD:F5, E6:11:55:F8:8C:CB, 4E:AB:5F:B0:FF:0A]) bluetooth device(s) connected (Connected devices: [BluetoothDevice(address=BC:30:7E:95:CD:F5, name=Q7 car, paired=true, connected=false), BluetoothDevice(address=4E:AB:5F:B0:FF:0A, name=AAWireless-CYPgcmWj, paired=true, connected=false), BluetoothDevice(address=00:1D:A5:22:B5:20, name=OBDII, paired=true, connected=false), BluetoothDevice(address=CC:98:8B:1B:75:FD, name=LE_WH-1000XM3, paired=true, connected=false), BluetoothDevice(address=CC:F8:26:75:AD:83, name=Galaxy Watch6 Classic (90QP), paired=true, connected=true), BluetoothDevice(address=E6:11:55:F8:8C:CB, name=AndroidAuto-AAW255e50a0, paired=true, connected=true), BluetoothDevice(address=88:C9:E8:F9:92:F1, name=WF-1000XM4, paired=true, connected=false), BluetoothDevice(address=0C:A6:94:BB:63:AD, name=HK Onyx Studio, paired=true, connected=false), BluetoothDevice(address=74:6F:F7:A8:8F:2C, name=Audi MMI 1015, paired=true, connected=true), BluetoothDevice(address=61:50:DA:97:C2:C9, name=Smart Tag2, paired=true, connected=true), BluetoothDevice(address=6D:BB:62:D5:62:D1, name=6D:BB:62:D5:62:D1, paired=false, connected=true)])
04-19 08:40:16.610 25206 19960 D LocBroadcastReceiver: High accuracy mode enabled, because in zone [1_zone.the_block, 1_zone.home]
04-19 08:40:16.687 25206 19960 D LocBroadcastReceiver: Event sent to Home Assistant

1 bt device disconnected but still connectd to an expected one

04-19 08:40:19.800 25206 25206 D SensorReceiver: Received intent: android.bluetooth.device.action.ACL_DISCONNECTED
04-19 08:40:19.802 25206 25206 D LastUpdate: Last update is android.bluetooth.device.action.ACL_DISCONNECTED
04-19 08:40:19.812 25206 17886 D ServerConnectionInfo: localUrl is: true, usesInternalSsid is: false, usesWifi is: false
04-19 08:40:19.813 25206 17886 D ActivitySM: Unregistering for activity updates.
04-19 08:40:19.813 25206 17886 D ActivitySM: Registering for activity updates.
04-19 08:40:19.835 25206 19960 D ServerConnectionInfo: localUrl is: true, usesInternalSsid is: false, usesWifi is: false
04-19 08:40:19.841 25206 25268 I WM-WorkerWrapper: Worker result SUCCESS for Work [ id=644125e7-fb8c-4253-be5a-4bd6a58ada2a, tags={ io.homeassistant.companion.android.websocket.WebsocketManager } ]
04-19 08:40:19.981 25206 17886 D SensorManager: registerListener :: 51, TMD4907 Light Ambient Light Sensor Non-wakeup, 200000, 0, 
04-19 08:40:19.981 25206 17886 D LightSensor: Light sensor listener registered
04-19 08:40:20.016 25206 19960 D LocBroadcastReceiver: High accuracy mode enabled, because defined ([74:6F:F7:A8:8F:2C, BC:30:7E:95:CD:F5, E6:11:55:F8:8C:CB, 4E:AB:5F:B0:FF:0A]) bluetooth device(s) connected (Connected devices: [BluetoothDevice(address=BC:30:7E:95:CD:F5, name=Q7 car, paired=true, connected=false), BluetoothDevice(address=4E:AB:5F:B0:FF:0A, name=AAWireless-CYPgcmWj, paired=true, connected=false), BluetoothDevice(address=00:1D:A5:22:B5:20, name=OBDII, paired=true, connected=false), BluetoothDevice(address=CC:98:8B:1B:75:FD, name=LE_WH-1000XM3, paired=true, connected=false), BluetoothDevice(address=CC:F8:26:75:AD:83, name=Galaxy Watch6 Classic (90QP), paired=true, connected=true), BluetoothDevice(address=E6:11:55:F8:8C:CB, name=AndroidAuto-AAW255e50a0, paired=true, connected=true), BluetoothDevice(address=88:C9:E8:F9:92:F1, name=WF-1000XM4, paired=true, connected=false), BluetoothDevice(address=0C:A6:94:BB:63:AD, name=HK Onyx Studio, paired=true, connected=false), BluetoothDevice(address=74:6F:F7:A8:8F:2C, name=Audi MMI 1015, paired=true, connected=true), BluetoothDevice(address=61:50:DA:97:C2:C9, name=Smart Tag2, paired=true, connected=true)])
04-19 08:40:20.016 25206 19960 D LocBroadcastReceiver: High accuracy mode enabled, because in zone [1_zone.the_block, 1_zone.home]

another geofence update and still in zone

04-19 08:41:29.521 25206 25206 D LocBroadcastReceiver: Received geofence update.
04-19 08:41:29.525 25206 19960 D LocBroadcastReceiver: Last Location: 
04-19 08:41:29.525 25206 19960 D LocBroadcastReceiver: Coords:(lat458461, -long843415)
04-19 08:41:29.525 25206 19960 D LocBroadcastReceiver: Accuracy: 20.0
04-19 08:41:29.525 25206 19960 D LocBroadcastReceiver: Bearing: 268.0
04-19 08:41:29.527 25206 19957 D ServerConnectionInfo: localUrl is: true, usesInternalSsid is: false, usesWifi is: false
04-19 08:41:29.531 25206 19960 D LocBroadcastReceiver: Begin evaluating if location update should be skipped
04-19 08:41:29.531 25206 19960 D LocBroadcastReceiver: Received location that is 45 milliseconds old, 1713530489486 compared to 1713530489531 with source fused
04-19 08:41:29.536 25206 19960 D ServerConnectionInfo: localUrl is: true, usesInternalSsid is: false, usesWifi is: false
04-19 08:41:29.536 25206 25206 D LocBroadcastReceiver: Received location update.
04-19 08:41:29.540 25206 25206 D ForegrndServiceLauncher: Check if service HighAccuracyLocationService is running. Service running = true
04-19 08:41:29.540 25206 25206 I NotificationManager: io.homeassistant.companion.android: notify(-561227077, null, Notification(channel=High accuracy location shortcut=null contentView=null vibrate=null sound=null defaults=0x0 flags=0xa color=0xff888888 category=service actions=1 vis=SECRET semFlags=0x0 semPriority=0 semMissedCount=0)) as user
04-19 08:41:29.543 25206 19960 D LocBroadcastReceiver: Last Location: 
04-19 08:41:29.543 25206 19960 D LocBroadcastReceiver: Coords:(lat458461, -long843415)
04-19 08:41:29.543 25206 19960 D LocBroadcastReceiver: Accuracy: 20.0
04-19 08:41:29.543 25206 19960 D LocBroadcastReceiver: Bearing: 268.0
04-19 08:41:29.545 25206 19960 D LocBroadcastReceiver: Begin evaluating if location update should be skipped
04-19 08:41:29.545 25206 19960 D LocBroadcastReceiver: Skipping old location update since time is before the last one we sent, received: 1713530489486 last sent: {1=1713530489531}
04-19 08:41:29.582 25206 19474 D LocBroadcastReceiver: High accuracy mode enabled, because defined ([74:6F:F7:A8:8F:2C, BC:30:7E:95:CD:F5, E6:11:55:F8:8C:CB, 4E:AB:5F:B0:FF:0A]) bluetooth device(s) connected (Connected devices: [BluetoothDevice(address=BC:30:7E:95:CD:F5, name=Q7 car, paired=true, connected=false), BluetoothDevice(address=4E:AB:5F:B0:FF:0A, name=AAWireless-CYPgcmWj, paired=true, connected=false), BluetoothDevice(address=00:1D:A5:22:B5:20, name=OBDII, paired=true, connected=false), BluetoothDevice(address=CC:98:8B:1B:75:FD, name=LE_WH-1000XM3, paired=true, connected=false), BluetoothDevice(address=CC:F8:26:75:AD:83, name=Galaxy Watch6 Classic (90QP), paired=true, connected=true), BluetoothDevice(address=E6:11:55:F8:8C:CB, name=AndroidAuto-AAW255e50a0, paired=true, connected=true), BluetoothDevice(address=88:C9:E8:F9:92:F1, name=WF-1000XM4, paired=true, connected=false), BluetoothDevice(address=0C:A6:94:BB:63:AD, name=HK Onyx Studio, paired=true, connected=false), BluetoothDevice(address=74:6F:F7:A8:8F:2C, name=Audi MMI 1015, paired=true, connected=true), BluetoothDevice(address=61:50:DA:97:C2:C9, name=Smart Tag2, paired=true, connected=true)])
04-19 08:41:29.582 25206 19474 D LocBroadcastReceiver: High accuracy mode enabled, because in zone [1_zone.the_block, 1_zone.home]
04-19 08:41:29.778 25206 19474 D LocBroadcastReceiver: Event sent to Home Assistant

after this no more geofence reports received from Google which means we wont be able to turn off high accuracy mode as a result

I am not sure what we can do here, we are dependent on geofence updates from Google. Can you try adjusting teh zone size/radius? Maybe also try without a overlapping zone?

angrycatmeowmeow commented 1 month ago

I will shrink the_block as it is only used for this purpose, and move it so it no longer overlaps with home

angrycatmeowmeow commented 1 month ago

If I created a zone just outside of my neighborhood, would my phone simply passing through this zone be enough of a "wake up" to make the Google geofence update and make the app realize I'm no longer in the expected zones? Like if the companion app sees me pass through zone.area_x it would have to realize I'm no longer in home or the_block. Seems like kind of a hacky workaround, though, for something that isn't really troublesome as my phone is always charging in the car anyway...

dshokouhi commented 1 month ago

no that wont work because we listen to the geofence event and follow the zone we attached to it so we can have proper enter/exit events

https://github.com/home-assistant/android/blob/master/app/src/full/java/io/homeassistant/companion/android/sensors/LocationSensorManager.kt#L763-L775