Screen Lock (>15min) - Notification commands not working

Hello everyone,

I was trying to enable/disable the high accuracy mode with the Notification Commands. What have I tried or what instruction did I follow, Setup and Troubleshoot.
I discovered that it is working as long as I am on the home screen (Phone is unlocked), do I lock the screen per button or waiting a period of time the phone does it by itself. I can turn on/off the high accuracy mode within 1 min but after I think of 15 min the phone is locked I can’t either turn on or turn off high accuracy mode. I did check it with other commands like command_screen_on also not working.
When I am sending the high accuracy command to turn on and I unlock the phone it takes 2 sec and high accurcy mode gets turned on.
The phone I use is an Samsung Galaxy S20 FE, I did turn off battery optimization as data saver like mentioned in Troubleshoot.

Log from App (there is much more Data, I tried to pick the important)

06-22 10:54:16.897 19471 19471 D LocBroadcastReceiver: Forcing of high accuracy mode enabled
06-22 10:54:16.913 19471 28464 D LocBroadcastReceiver: Forcing of high accuracy mode disabled, because high accuracy mode had to be enabled anyway.
06-22 10:54:16.919 19471 28464 D LocBroadcastReceiver: High accuracy mode parameters changed. Enable high accuracy mode.
06-22 10:54:16.919 19471 28464 D LocBroadcastReceiver: Removing background location requests.
06-22 10:54:16.928 19471 28464 D HighAccLocService: Try starting high accuracy location service (Interval: 60s)...
06-22 10:54:16.934 19471 19471 D SensorReceiver: Received intent: io.homeassistant.companion.android.UPDATE_SENSORS
06-22 10:54:16.935 19471  2130 D ServerConnectionInfo: localUrl is: false, usesInternalSsid is: false, usesWifi is: true
06-22 10:54:16.938 19471 28464 D ForegrndServiceLauncher: Start service HighAccuracyLocationService
06-22 10:54:16.980 19471 19471 D ForegrndServiceLauncher: Service HighAccuracyLocationService was created. Start service
06-22 10:54:16.980 19471 19471 D HighAccLocService: High accuracy location service created -> onCreate
06-22 10:54:16.989 19471 19471 D HighAccLocService: High accuracy location service (Interval: 60s) started -> onStartCommand
06-22 10:54:17.010 19471 19471 D LocBroadcastReceiver: Received location update.
06-22 10:54:17.017 19471 19471 D ForegrndServiceLauncher: Check if service HighAccuracyLocationService is running. Service running = true
06-22 10:54:17.019 19471 28464 D LocBroadcastReceiver: Last Location: 
06-22 10:54:17.019 19471 28464 D LocBroadcastReceiver: Coords:(<Data>, <Data>)
06-22 10:54:17.019 19471 28464 D LocBroadcastReceiver: Accuracy: 21.048
06-22 10:54:17.019 19471 28464 D LocBroadcastReceiver: Bearing: 0.0
06-22 10:54:17.020 19471 28464 D LocBroadcastReceiver: Begin evaluating if location update should be skipped
06-22 10:54:17.020 19471 28464 D LocBroadcastReceiver: Received location that is 81 milliseconds old, 1687424056939 compared to 1687424057020 with source fused
06-22 10:54:17.020 19471 28464 D LocBroadcastReceiver: Duplicate location received, not sending to HA

06-22 10:54:45.037 19471 19471 D LocBroadcastReceiver: Forcing of high accuracy mode disabled
06-22 10:54:45.047 19471  5043 D LocBroadcastReceiver: High accuracy mode parameters changed. Disable high accuracy mode.
06-22 10:54:45.054 19471  5043 D HighAccLocService: Try stopping high accuracy location service...
06-22 10:54:45.055 19471 19471 D SensorReceiver: Received intent: io.homeassistant.companion.android.UPDATE_SENSORS
06-22 10:54:45.057 19471  5044 D ServerConnectionInfo: localUrl is: false, usesInternalSsid is: false, usesWifi is: true
06-22 10:54:45.059 19471  5043 D ForegrndServiceLauncher: Stop service HighAccuracyLocationService
06-22 10:54:45.060 19471  5043 D LocBroadcastReceiver: Registering for location updates.
06-22 10:54:45.061 19471 19471 D ForegrndServiceLauncher: Service HighAccuracyLocationService was destroyed. Stop service
06-22 10:54:45.063 19471 19471 D HighAccLocService: High accuracy location service stopped -> onDestroy
06-22 10:54:45.105 19471 19471 D LocBroadcastReceiver: Received location update.
06-22 10:54:45.115 19471 19471 D ForegrndServiceLauncher: Check if service HighAccuracyLocationService is running. Service running = false
06-22 10:54:45.115 19471  5043 D LocBroadcastReceiver: Last Location: 
06-22 10:54:45.115 19471  5043 D LocBroadcastReceiver: Coords:(<Data>, <Data>)
06-22 10:54:45.115 19471  5043 D LocBroadcastReceiver: Accuracy: 31.948
06-22 10:54:45.115 19471  5043 D LocBroadcastReceiver: Bearing: 90.24634
06-22 10:54:45.122 19471  5043 D LocBroadcastReceiver: Begin evaluating if location update should be skipped
06-22 10:54:45.122 19471  5043 D LocBroadcastReceiver: Received location that is 13600 milliseconds old, 1687424071521 compared to 1687424085121 with source fused
06-22 10:54:45.125 19471  5043 D ServerConnectionInfo: localUrl is: false, usesInternalSsid is: false, usesWifi is: true
06-22 10:54:45.157 19471  5043 D LocBroadcastReceiver: Location update sent successfully for 2 as exact

What do I miss? Is this android related because of “deep sleep” or something similar?
Thx for the input :wink:

can you share an example of the notification you are sending? Its possible you did not follow the critical format which is still suspect to doze if not used.

Example Code I have tried within the Developer Tools with yaml mode

service: notify.mobile_app_<your_device_id_here>
data:
  message: "command_high_accuracy_mode"
  data:
    command: "turn_on"
service: notify.mobile_app_<your_device_id_here>
data:
  message: "command_high_accuracy_mode"
  data:
    command: "turn_off"

Following your linked docs, the notifications should look like this right?

service: notify.mobile_app_<your_device_id_here>
data:
  message: "command_high_accuracy_mode"  
  data:
    ttl: 0
    priority: high
    command: "turn_on"
service: notify.mobile_app_<your_device_id_here>
data:
  message: "command_high_accuracy_mode"  
  data:
    ttl: 0
    priority: high
    command: "turn_off"

So I was struggling with Notification Commands for a while. Today discovered you need to enable special permission in the companion app.

Also, you should keep open HA app on your first try. This way app can direct you to the corresponding Android permission page if it needs any other permission.

1 Like