High accuracy mode notification commands don't work as expected

I’m currently working with location related automations and prefer the high accuracy feature because I set “Zone name only” in the background location sensor but the proximity integration requires exact location and I don’t want to expose the exact location. I enabled high accuracy mode with zone and bluetooth constraint and enabled the setting “High accuracy mode enabled only when in Zone and BT device connected”. High accuracy mode is activated when getting closer to the zone and deactivated when reaching the zone while the high accuracy mode setting itself stays enabled. According to the documentation high accuracy mode should also be activated when leaving zone.home and entering zone.home_extended (Location | Home Assistant Companion Docs). Compared to approaching the zone.home, leaving the zone.home isn’t recognized quickly. I had the idea to use an automation, which sends a notification command (force_on) that activates high accuracy mode when the app connects to my car’s bluetooth for recognozing the zone.home boundary more quickly and it gets deactiveated once leaving the zone.home_expanded automatically or after five minutes through notication command (force_off) in case I stay in zone.home. In the documentation is stated that after a force_on is sent high accuracy mode automatically gets deactivated if a force_off is sent or the constraint go from active to inactive. That means the high accuracy mode should be deactiveated at least on leaving the zone.home_expanded. But that’s not the case. Additionally I would expect that turn_on / turn_off, force_on / force_off would only activate/deactivate the mode while the setting stays enabled. Otherwise the mode is disabled forever and cannot be triggered again when entering the zone the next time until the mode is enabled again manually or by force_on. Or how to interprete the statement “In this case force_on will make high accuracy mode active until either force_off is sent, or the constraints go from active to inactive. Similarly, force_off will turn off high accuracy mode until either force_on is sent, or the constraints go from inactive to active”? Moreover turn_on will activate the high accuracy mode even if the constraints aren’t met. It seems that there’s currently not difference between turn_on / turn_off and force_on / force_off. Additionally both command types enable / disable the mode setting instead just activating/deativating the mode while leaving the setting untouched. I noticed a thread with similar findings (High accuracy mode notifications, where is "auto" mode?), but I didn’t want to dig out that old one again, thus, I started a new one.

TLDR:

  • High accuracy mode gets activated when sending a turn_on command even if constraints (zone and/or bluetooth) aren’t met.
  • High accuracy mode setting gets disabled instead of just turning off the high accuracy mode if turn_off or force_off is sent.
  • High accuracy mode doesn’t gets deactivated when activated by force_on and contraints later go from active to inactive like disconnecting bluetooth or leaving zone.home_expanded.

Currently I think the notication command feature isn’t working as intended / documentated. Can anyone confirm this behavior or did I get the documentation or understanding of the feature wrong? I first wanted to rule out I’m missing something in advance before I file an isue on github. In my opinion notification commands should trigger only the mode (represented by sensor “High accuracy mode”) and not the mode setting within the background location sensor.

By the way: I noticed it’s hard to troubleshoot high accuracy mode. Fake gps does work for gps coordinates and zone updates (home, not_home) but not for triggering high accuracy mode. I tried to move the home zone to simulate a move and restarted the app to recognize the zone changes while the coordinates of the app stay unchanged. This works for activation of high accuracy mode, but not for deactivating app when moving the home zone back to the coordinates of the app. A dummy device_tracker created by device_tracker.see Action does not work, because the high accuracy mode is a feature of the app, not the device_tracker. Does anyone have more ideas to troubleshoot high accuracy mode without moving the device physically?

Environment:

Hardware: Raspberry Pi 4
Core: 2024.9.3
Supervisor: 2024.09.1
Operating System: 13.1
Frontend: 20240909.01
Android: 14
Companion App: 2024.9.4-full

Sorry im trying to follow your post but its very hard to read and follow. I am not sure what you are asking.

Can you instead provide YAML examples of teh commands you tried and then give a brief description of what happened for each one?

There are 2 commands for high accuracy, one of which will force the override of turning on high accuracy regardless of constraints and the other will respect the constraints until the next time it is met. If that is too confusing for you. Then dont use it. Just use the simple on and off command without any configured constraints.

Sorry for writing such a novel. I’ll try to clarify what I’m trying to say, but it’s still hard to keep it short ;):

Scenario 1

  • Test setup
    • High accuracy mode (may drain battery fast): Enabled
    • High accuracy mode only when connected to BT devices: Car’s audio and bluetoth headset selected
    • High accuracy mode only when entering the zone: None selected
    • High accuracy mode trigger range for zone (meters): 500
    • High accuracy mode enabled only when in zone and bluetooth device connected: Disabled
  • No bluetooth devices connected > no constraints currently met.
  • High accuracy mode setting is enabled, but inactive.
  • Bluetooth headset connected > contraints met > sticky notification appears
  • Bluetooth headset disconnected > contraints not met > sticky notification disappears
  • Send notification command:
action: notify.mobile_app_sm_s911b
data:
  message: command_high_accuracy_mode
  data:
    ttl: 0
    priority: high
    command: turn_on
  • Sticky notification appears > contraints still not met > sticky notification appears
  • Bluetooth headset connected, disconnected > sticky notification disappears
  • Manually turn off and on the mode in the settings > notification keeps disabled as expected.
  • Conclusion: I would have expected, that turn_on notification doesn’t activate the sticky notification because the bluetooth constraints aren’t met.

Scenario 2

  • Test setup
    • High accuracy mode (may drain battery fast): Enabled
    • High accuracy mode only when connected to BT devices: Car’s audio and bluetoth headset selected
    • High accuracy mode only when entering the zone: Zone.home selected
    • High accuracy mode trigger range for zone (meters): 500
    • High accuracy mode enabled only when in zone and bluetooth device connected: Enabled
  • No bluetooth devices connected and in zone.home > no constraints currently met.
  • High accuracy mode setting is enabled, but inactive.
  • Bluetooth headset connected, disconnected, nothing happens
  • Send notification command:
action: notify.mobile_app_sm_s911b
data:
  message: command_high_accuracy_mode
  data:
    ttl: 0
    priority: high
    command: turn_on
  • Sticky notification appears > contraints still not met > sticky notification appears
  • Bluetooth heaset connected, disconnected, nothing happens > sticky notification still active.
  • Manually toggle the mode setting in the background location sensor to off > sticky notification disappears.
  • Manually enable the mode setting > sticky notification appears again
  • Send notification command:
action: notify.mobile_app_sm_s911b
data:
  message: command_high_accuracy_mode
  data:
    ttl: 0
    priority: high
    command: turn_off
  • Manually toggle the mode setting back to on > high accuracy mode sensor stays false, no sticky notification.
  • Conclusion: If blueooth and zone contraints configured, the “High accuracy mode enabled only when in zone and bluetooth device connected” setting is enabled and a turn_on notification is sent, the sticky notification will still be activated after manually turning the mode off and on again. Normal operation can only be restore by sending a turn_off command and manually enabling the setting.

I see several issues here:

  • Turn_on enables the sticky notification regardless of contraints. This is what the force_on seems to be for.
  • If zone and bluetooth constraints are configured and “High accuracy mode enabled only when in zone and bluetooth device connected” settings is enabled and a turn_on is sent, connecting and disconnecting the bluetooth device doesn’t disable the notification. After manually turning the mode off and on it gets activated again even if the contraints still aren’t met. Only after turn_off notification and manual turn on the notification keeps disabled.
  • It would be nice to be able activate the sticky notification, while leaving the settings in background location untouched but also fall back to normal operation when the Status of contraints change (e.g connect or disconnect of bluetooth device).

I cannot image that this is the way it was designed or intended, but if yes, then I cannot use it in my case. But activating/deactivating high accuracy mode with leaving the mode setting untouched would help me out. Maybe that’s what Hellis81 and Yoinx tried to explain in High accuracy mode notifications, where is "auto" mode?. If you confirm turn_on is currently working as expected, I can create an issue (activating/deactivating high accuracy mode by notification command while leaving mode setting untouched) and label it as feature request as you already suggested in the thread mentiod above.

Edit: I had to edit the test scenarios. There were some mistakes in it. It was late :woozy_face:.

One ask in your testing. Please check the companion app logs and look for the corresponding log line. We print the entire decision making process to the logs. That includes the constraints and everything. So you should be able to confirm what the app see’s and it will help pinpoint any issues found.

no turn_on may still apply but it wont STAY, the force option ensures it stays until the next command (force_off)

The force option was added at a later point in time and we kept the old logic (turn on/off) to ensure that users who had it working still had it working. Users who expected it to work as you do would then use the force option. The force option came about a year after the command was first introduced.

that is why the command exists so users can remove the in app constraints and use HA automations however they see fit.

if you believe you found an issue please provide the companion app logs as they will be required for location issues. It will be obvious with the amount of logs we have but if we need to add more we will. Making changes to location tracking needs to be careful as its vey easy to break stuff due to all the current logic.

I agree, that’s a complex topic. I realised that quickly.

The good news is (just for information): It works as stated in the location documentation if zone and bluetooth constraint set, bt/zone setting enabled, trigger range set to 500 and as long as no notification commands are involved.

Arriving home zone:

  • Entering zone.home_expanded → High accuracy mode enabled
  • Entering zone.home, therefore exiting zone.home_expanded → High accuracy mode disabled

Leaving home zone:

  • Exiting zone.home, therefore entering zone.home_expanded → High accuracy mode enabled
  • Exiting zone.home_expanded → High accuracy mode disabled

Today I went jogging while bt headset was connected all the time and this happened:

  • Leaving home
    • Connecting bluetooth headset within home zone > nothing happened
    • Leaving home zone and entering expanded zone > zone and bt constraint both met > high accuracy mode activated (1)
    • Leaving expanded zone while bt headset still connected > high accuracy mode deactivated (2)
  • Arriving home
    • Entering expanded zone > high accuracy mode activated (3)
    • Entering home zone > high accuracy mode deactivated (4)

What do you mean with “may still apply”? So, turn_on shouldn’t activate the notification if constraints are not met, should it? If I understand the documentation correctly then a sticky notification also shouldn’t stay when e.g. first a force_on command is sent and later a constraint goes from active to inactive (or do I get the documentation wrong?):

The difference between turn and force is only relevant if you have zone and/or bluetooth constraints set in the high accuracy mode settings. In this case force_on will make high accuracy mode active until either force_off is sent, or the constraints go from active to inactive. Similarly, force_off will turn off high accuracy mode until either force_on is sent, or the constraints go from inactive to active.

I also just found out (this is what I noticed, anyway, but I’m not sure if it’s intended), that turn_off disables the main high accurracy mode setting, while with a force_off the setting stays enabled. Until now I assumed that also a force_off will disabled the mode as the turn_off does. This might be a helpful information in the documentation. I currently even don’t know whether turn_on should activate the notification even if constraints aren’t met. Thus, it might be worth to better understand how things work before I go on testing. I noticed that you are one of the active developers for the companion app. Would you please explain more detailed how these commands are intended to be used and what they do exactly respectively how they work in detail (maybe with some examples)?

However, I owe you at least some log lines at this stage. I sent a turn_on at 23:01:00 and turn_off 23:02:00. The log is filtered by search pattern “high accuracy”. I’ve never posted logs here and upload of txt files is not allowed, hopefully i did it correctly (I had to omit some line due to the body limit):

10-05 23:01:00.515 27119 27119 D LocBroadcastReceiver: Forcing of high accuracy mode enabled
10-05 23:01:00.536 27119 27282 D LocBroadcastReceiver: High accuracy mode enabled, because command_high_accuracy_mode was used to turn it on
10-05 23:01:00.538 27119 27282 D LocBroadcastReceiver: High accuracy mode parameters changed. Enable high accuracy mode.
10-05 23:01:00.541 27119 27282 D HighAccLocService: Try starting high accuracy location service (Interval: 5s)...
10-05 23:01:00.548 27119 27119 D HighAccLocService: High accuracy location service created -> onCreate
10-05 23:01:00.549 27119 27119 D HighAccLocService: High accuracy location service (Interval: 5s) started -> onStartCommand
10-05 23:01:00.583 27119 27280 D LocBroadcastReceiver: High accuracy mode appears to have stopped, restarting high accuracy mode
10-05 23:01:00.586 27119 27280 D HighAccLocService: Try stopping high accuracy location service...
10-05 23:01:00.588 27119 27119 D HighAccLocService: High accuracy location service stopped -> onDestroy
10-05 23:01:00.608 27119 27280 D LocBroadcastReceiver: High accuracy mode enabled, because command_high_accuracy_mode was used to turn it on
10-05 23:01:00.611 27119 27280 D HighAccLocService: Try starting high accuracy location service (Interval: 5s)...
10-05 23:01:00.622 27119 27119 D HighAccLocService: High accuracy location service created -> onCreate
10-05 23:01:00.622 27119 27119 D HighAccLocService: High accuracy location service (Interval: 5s) started -> onStartCommand
10-05 23:01:00.661 27119 27219 D LocBroadcastReceiver: High accuracy mode appears to have stopped, restarting high accuracy mode
10-05 23:01:00.664 27119 27219 D HighAccLocService: Try stopping high accuracy location service...
10-05 23:01:00.672 27119 27119 D HighAccLocService: High accuracy location service stopped -> onDestroy
10-05 23:01:00.672 27119 31214 D LocBroadcastReceiver: High accuracy mode appears to have stopped, restarting high accuracy mode
10-05 23:01:00.675 27119 31214 D HighAccLocService: Try stopping high accuracy location service...
10-05 23:01:00.690 27119 27219 D LocBroadcastReceiver: High accuracy mode enabled, because command_high_accuracy_mode was used to turn it on
10-05 23:01:00.699 27119 27219 D HighAccLocService: Try starting high accuracy location service (Interval: 5s)...
10-05 23:01:00.702 27119 31214 D LocBroadcastReceiver: High accuracy mode enabled, because command_high_accuracy_mode was used to turn it on
10-05 23:01:00.702 27119 27119 D HighAccLocService: High accuracy location service created -> onCreate
10-05 23:01:00.702 27119 27119 D HighAccLocService: High accuracy location service (Interval: 5s) started -> onStartCommand
10-05 23:01:00.792 27119 27280 D LocBroadcastReceiver: High accuracy mode appears to have stopped, restarting high accuracy mode
10-05 23:01:00.796 27119 27280 D HighAccLocService: Try stopping high accuracy location service...
10-05 23:01:00.799 27119 31214 D LocBroadcastReceiver: High accuracy mode appears to have stopped, restarting high accuracy mode
10-05 23:01:00.803 27119 27119 D HighAccLocService: High accuracy location service stopped -> onDestroy
10-05 23:01:00.804 27119 31214 D HighAccLocService: Try stopping high accuracy location service...
10-05 23:01:00.833 27119 27280 D LocBroadcastReceiver: High accuracy mode enabled, because command_high_accuracy_mode was used to turn it on
10-05 23:01:00.834 27119 31214 D LocBroadcastReceiver: High accuracy mode enabled, because command_high_accuracy_mode was used to turn it on
10-05 23:01:00.844 27119 27280 D HighAccLocService: Try starting high accuracy location service (Interval: 5s)...
10-05 23:01:00.851 27119 27119 D HighAccLocService: High accuracy location service created -> onCreate
10-05 23:01:00.851 27119 27119 D HighAccLocService: High accuracy location service (Interval: 5s) started -> onStartCommand
10-05 23:01:00.876 27119 27282 D LocBroadcastReceiver: High accuracy mode appears to have stopped, restarting high accuracy mode
10-05 23:01:00.888 27119 27282 D HighAccLocService: Try stopping high accuracy location service...
10-05 23:01:00.894 27119 27119 D HighAccLocService: High accuracy location service stopped -> onDestroy
10-05 23:01:00.915 27119 27282 D LocBroadcastReceiver: High accuracy mode enabled, because command_high_accuracy_mode was used to turn it on
10-05 23:01:00.918 27119 27280 D LocBroadcastReceiver: High accuracy mode appears to have stopped, restarting high accuracy mode
10-05 23:01:06.041 27119 27119 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
10-05 23:01:10.050 27119 27119 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
10-05 23:01:13.435 27119 27119 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
10-05 23:01:19.061 27119 27119 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
10-05 23:01:24.040 27119 27119 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
10-05 23:01:29.050 27119 27119 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
10-05 23:01:34.051 27119 27119 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
10-05 23:01:39.049 27119 27119 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
10-05 23:01:44.047 27119 27119 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
10-05 23:01:49.855 27119 27119 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
10-05 23:01:50.053 27119 27119 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
10-05 23:01:54.045 27119 27119 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
10-05 23:02:00.049 27119 27119 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
10-05 23:02:00.709 27119 27119 D LocBroadcastReceiver: Forcing of high accuracy mode disabled
10-05 23:02:00.713 27119 31212 D LocBroadcastReceiver: High accuracy mode parameters changed. Disable high accuracy mode.
10-05 23:02:00.714 27119 31212 D HighAccLocService: Try stopping high accuracy location service...
10-05 23:02:00.720 27119 27119 D HighAccLocService: High accuracy location service stopped -> onDestroy
10-05 23:02:01.195 27119 27119 D MessagingService: Creating notification with following data: {webhook_id=44726931d0d1f4309d9dcb826f7a6f78fe4a92e9c7ab5e6818c8ba4493700bd0, message=High Accurcy Mode inaktiv, server_id=1}
10-05 23:02:45.474 27119 31491 D LocBroadcastReceiver: High accuracy mode disabled, because defined ([C0:86:B3:9A:C1:FD, 64:D4:BD:CE:BF:BD]) bluetooth device(s) not connected (Connected devices: [BluetoothDevice(address=70:BF:92:E0:D0:EC, name=Jabra Evolve2 85, paired=true, connected=false), BluetoothDevice(address=00:22:D0:01:03:A2, name=Polar iWL, paired=true, connected=false), BluetoothDevice(address=C0:86:B3:9A:C1:FD, name=OpenFit by Shokz, paired=true, connected=false), BluetoothDevice(address=64:D4:BD:CE:BF:BD, name=Golf VII, paired=true, connected=false)])
10-05 23:02:45.573 27119 31560 D LocBroadcastReceiver: High accuracy mode disabled, because defined ([C0:86:B3:9A:C1:FD, 64:D4:BD:CE:BF:BD]) bluetooth device(s) not connected (Connected devices: [BluetoothDevice(address=70:BF:92:E0:D0:EC, name=Jabra Evolve2 85, paired=true, connected=false), BluetoothDevice(address=00:22:D0:01:03:A2, name=Polar iWL, paired=true, connected=false), BluetoothDevice(address=C0:86:B3:9A:C1:FD, name=OpenFit by Shokz, paired=true, connected=false), BluetoothDevice(address=64:D4:BD:CE:BF:BD, name=Golf VII, paired=true, connected=false)])

I couldn’t find a line similar to this in the logs when sending the turn_on command:

10-05 22:38:23.489 27119 27263 D LocBroadcastReceiver: High accuracy mode disabled, because defined ([C0:86:B3:9A:C1:FD, 64:D4:BD:CE:BF:BD]) bluetooth device(s) not connected (Connected devices: [BluetoothDevice(address=70:BF:92:E0:D0:EC, name=Jabra Evolve2 85, paired=true, connected=false), BluetoothDevice(address=00:22:D0:01:03:A2, name=Polar iWL, paired=true, connected=false), BluetoothDevice(address=C0:86:B3:9A:C1:FD, name=OpenFit by Shokz, paired=true, connected=false), BluetoothDevice(address=64:D4:BD:CE:BF:BD, name=Golf VII, paired=true, connected=false)])'

It just says:

Forcing of high accuracy mode enabled

PS: While testing today and yesterday I sometimes noticed that the high accuracy mode sensor switched to true but no notification was shown and no high accuracy location updates were written to the location history. I had to open the background location sensor for example and suddenly the sticky notification appeared. In addition I had the situation that with only a zone and no bluetooth constraint configured but the notification appeared even though I was within the configured zone what should equal “constraint isn’t met”. After a reboot it went to normal again. However, I just wanted to mention it, but we can focus on that later if needed because I currently don’t want to mix up multiple issues, it’s already complex enough.

I’ve spent the last few days doing a bit of testing. Unfortunately, I am currently unable to make a concrete statement to prove that the notification commands are not behaving as I would expect. I still believe that the documentation does not match my observed behaviour, but I give up.