I’ve been reading and testing through the Notification Commands for some time, but haven’t found an elegant way to force update my app sensors, while my phone is asleep.
The only way I got it working reliably is with command_webview, which does wake up the app, but then the app is opened on the screen, which is rather annoying.
Is there a more elegant way? Or can a command, similar to request_location_update be implemented to update other sensors as well or just wake up the app in the background?
Background:
Xiaomi is very restrictive with background apps, so sensor updates often take several minutes. Based on an automation I need to check my WiFi BSSID. Since I have several access points in the house the app doesn’t catch if I’m just for a short period near one of them.
Are you sure the phone actually connects to the other access point?
I don’t generally recommend relying on router data, but in this case, perhaps the router has the information?
Keeping the phone awake just to get this information seems like a way to drain the battery.
Yes it does and as soon as I open the HA app it updates.
Router integration doesn’t have the information so I have to rely on the app.
The update should be triggered by an automation that will run 5x/week on average, so I think battery shouldn’t be an issue.
This means the app does not have proper permission to run the background. Double check device settings and make sure it does and that all power saving settings are disabled for the app.
bluetooth and wifi use intents just like the phone being plugged in. This is an intent issue. What device is this on? Is it a custom ROM? Can you look at the device logs when you perform the above actions to see if the app is even getting the intent?
Did a fresh start - didn’t help. Also tried tons of other things, it won’t work.
Thanks a lot for trying to help me, I really appreciate it.
Looking forward to get the PR on my phone, I bet there are also use cases for a lot of other people.
SInce I’m having other issues as well, I’ll probably flash it with a custom ROM.
Can you do me a favor and check that the following Developer Option on your phone is enabled? It may help here. Its called “Mobile data always active” see if that helps when you enable it (assuming its disabled)