-
Notifications
You must be signed in to change notification settings - Fork 590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android iBeacon transmission stops shortly after started #3159
Comments
These logs do not indicate that the transmitter stopped or crashed. Are you certain its stopping? Can you run a quick test using the beacon monitor sensor to see if you see the same issue there please? Most of these issues usually come down to some configuration issue either in the sensor settings or on the other end like ESPresence. I am unable to reproduce as I have several devices that transmit and get picked up properly via the beacon monitor sensor. |
Here is another screenshot with the transmitter's state alongside the results from ESPresense. It does not appear the transmitter has stopped, but is it possible that some sort of Android battery management (or similar) disabled BLE even though the transmitter is still enabled? I do not know enough about the inner workings of Android to troubleshoot further in that direction. As far as ESPresense, my configuration is pretty much default. Unfortunately I do not have another Android device to test with, but the beaconing from my phone is working. As soon as I toggle the transmitter state off/on it will send a few packets (I'm watching them come in directly on MQTT) and then stop. Will only start again after toggling the transmitter again. |
There would be an error if the transmitter stopped, or BLE got disabled.
More than likely default configuration may not work. I suggest looking on the forums for what others have done. We won't be able to really troubleshoot how other integrations pick up the transmitter as there is too much to look at. The beacon monitor sensor uses the same library and is a great indicator if the transmission actually stopped. What I can tell you is that there are users out there who have this working and I think some do use ESPresence. |
I too am experiencing what would appear to be the same issue with a different phone. It transmits for a few minutes then stops (almost as if its being battery managed, but it has unrestricted battery use) and the rest of HA background continues to work correctly. If I wake the device and open the HA app, it will start working again for a while. I don't seem to be able to get any logs relating to the BLE, as reopening the app seems to clear the log. I have a couple of other iBeacons and these are both correctly reporting status from ESPresence and into MQTT If you have any suggestions on how I can provide logs etc, gratefully receive them |
@TwoWheelDev Your description matches my exact issue, including the note about opening the HA app and the transmission starting up again. @dshokouhi I have done some additional troubleshooting on the ESPresense end, with my phone, and the app. So far, I've not found any solutions that work, but several that end up exhibiting the same issue. Are there any additional indicators on the HA App/Android side that I can use to help pinpoint the root cause? |
your symptoms sound like the app is being killed in the background, depending on the device there may be more battery optimization settings you need to adjust.
the best test to see if the transmitter is still transmitting is to have 2 android devices with one using the beacon monitor and the other using the transmitter, if you see the monitor showing the transmitter then you know its still transmitting and the issue lies in setup of the other monitor. This test is important because both the transmitter and monitor use the same library and this will tell us if its actually working. |
So I've played around with some of the settings a bit more and so far it seems to be stable. What seems to have made a difference is changing the Transmitter Power from the default of ultra-low to low. The device has now been correctly detected in HA for over 3 hours |
Im having this same issue. Ive been experimenting with the settings, transmitter power on high definately seems to work the best but its only picking up if im sitting near a beacon for extended periods of time. Once connected it will hold but im still getting too much "not home" status mixed throughout the day compared to other devices like my phone running the HA app. for the last few days ive been making sure my phone and watch are always in the same room and in the same vicinity. there is quite a large difference in how they are reporting. both are on High transmitter power and low latency any help would be appreciated so i can rely more on the watch app. happy to provide logs or test as needed |
I have the same issue. If I make a change in the configuration, eg change the transmit power, my Pixel 6 pro running Android 13 will typically send 2 or 3 BLE messages, then stop. There are no errors, and the status still says "transmitting." I am verifying by using MQTT Explorer. The Home Assistant app is exempt from battery control and has all of the permissions it requested, including fine location all of the time. I can't find any settings that work consistently. Killing the app and restarting it doesn't restart the transmission. Rebooting the phone doesn't restart it either. The only thing that works is changing something in the configuration. |
Same here. And it is definitely related to HA application for Android. |
Here is the log from the companion app Nothing regarding BLE and it's the same with two android phones. |
Has there been any progress on this matter? I noticed this morning the Android companion app added functionality to limit BLE transmission to Home WiFi.. I tried again to test out the BLE beacon with my properly configured ESPresence. Looks like it still isn't working. |
I also have this issue that the transmitter stop shortly after starting |
For those facing this issue can you do me a favor? Now this test may lead to more drain however the library that we use had mentioned the foreground service used in the beacon monitor should also correct this.
So please enable the beacon monitor sensor so the foreground service can start and see if that corrects the issue for you. If it does then the appropriate fix would be to have both sensors enabled. So again enable both the transmitter and the beacon monitor. |
I enabled the beacon sensor and toggled the BLE transmitter sensor a couple times. So far, no luck. I confirmed my espresense nodes are correctly working as well. I began charging a battery powered Chipolo device that I have and my nodes immediately picked it up. |
@isewise try changing Advertise Mode to Low Latency and maybe adjust Measured Power to |
Changed both settings and no detection by my nodes unfortunately. |
that is actually not the same issue as the one you are commenting on. The issue here is that it starts advertising and then stops. Your issue is that its never detected period which suggests you still need to make adjustments either in the companion app or in whatever detection method you are using. Not sure what changes are needed. If you see the beacon showing up in the beacon monitor sensor attributes then the transmission is working as expected. if using the ibeacon integration make sure to whitelist the UUID so it can be processed there. |
I definitely think something is wrong with HA companion app. I just created a test BLE iBeacon using this app, went through the procedure of adding a sensor via ESPresense (YAML config, editing a node via its GUI, restart the node & restarted HA) and HA picked it up right away. So I dont think how my detection is being configured is the issue.
What other settings need to be changed in the companion app?
As I stated above, I don't my detection method is improperly configured. As you'll see from the YAML screenshot below, the configuration is identical except for the actual iBeacon UUID. |
the best way to verify that is to get 2 android devices. 1 with the beacon monitor enabled and the other with BLE transmitter enabled. If you dont see the beacon monitor picking up the transmitter then yes something is wrong. If you do see it but you dont see it elsewhere then the issue relies with the configuration. please search github issues for past issues you will see many users with different beacons getting things working with various settings. The docs also outline those settings as well. either way your issue is unrelated to this issue so please file a new issue so we can keep this issue focused on the actual original reported issue. edit: here is an example of a user having success https://community.home-assistant.io/t/espresense-android-ha-companion-app/531843/7?u=dshokouhi and another https://community.home-assistant.io/t/espresense-wear-os-and-tips-tricks/518970 |
I connected my ESP M5 atom to my PC to read the logs of the node as it detects devices. The node is a beacon monitor after all. I turned off BLE transmitter sensor in the companion app, brought my phone near the node, then turned on BLE transmitter sensor. It popped up in the logs as "New", then "Close" then "Left" within 1 second. See the yellow highlighted logs. This is the exact behavior described in the issue: "Android iBeacon transmission stops shortly after started" I didn't move my phone away from the node, I didnt turn off the BLE transmitter sensor and subsequent attempts of me bringing my phone near the node to attempt to have it register as "Close" again, as it should, did not work. I appreciate you sharing some tips, but I do think this is related. I've had this presence detection enabled and working for quite some time using the HA companion app until, I, as the other people who have commented in this thread noticed it was no longer working. |
do you see that same behavior with my recommendation from earlier of keeping both sensors (Beacon Monitor and BLE Transmitter) enabled and transmitting/monitoring? The beacon monitor sensor once enabled will post a persistent notification on your device to keep things alive, thats whats important for my actual ask. Did you see that notification show up once the monitor is enabled? you mentioned earlier in your comment |
I think at some point the companion app must have changed the UUID. I went through everything and discovered that some of the middle digits and letters had changed but the ending, minor & major, had remained the same. I overlooked it because I was only paying attention to the last pattern of major and minor at the end of the iBeacon string. But in reviewing all the settings more closely I discovered the discrepancy. I know I didn't change it, I never had any reason to do so. Others might want to check the beacon string if they are having issues as well. I'm pretty ashamed that it was such a simple issue 😞 I apologize. As for the beacon monitoring sensor, I've been testing without it enabled and so far it's been working well. I would imagine other phones and devices might have different results. My current settings: |
This only happens when app database was lost like if you factory reset, changed devices. Or even if you got logged out of the only added server in your device. It is a random UUID the first time the sensor is enabled, once created it stays static unless the data is lost.
yes they are hardcoded
Good to know the feature is working for you, if you see it stop after some time like 10 minutes then you are impacted by this issue. For the others who are actually experiencing this issue please see my comments from yesterday about the debug APK testing to see if we can solve this issue. |
Hi, I have the same issue and have tried the debug build. Both versions have the same issue, a beacon is received immediately when I turn on the transmitter, then no more beacons are received. Turning the transmitter off and on again I receive a new beacon in both versions of the app. With the debug build, I get the notification, but it does not seem to change anything. |
@umglurf you need to add the UUID to the ibeacon integration whitelist as mentioned earlier. You wont see the UUIDs without it as not all devices send a name. |
Hi, I added the UUID for both apps in order to get them to appear in the iBeacon integration. |
can you please share screenshots and more data to go by? you also do not need to turn the transmitter on and off like that, it takes some time for the 10 tries to get picked up. Also did you make sure to grant the app background access? If on a samsung device you have more than 1 setting to turn off. |
This is without the debug build: With the debug build:
Yes, it was a quick way to get the debug app correlated.
Yes, background access is granted. The device is a Faiphone 3 |
any reason why you changed measured power to 81? try the default of -59 what about the device tracker? is that showing away? your screenshots dont show the device disconnected as the state will be unavailable then. also adjust transmit power to be high and advertise mode to be low latency |
I changed it to match the measured power 1 meter away, but have set it to -59 now
non debug build, low latency, high power, -59db: debug build, same parameters: |
so the detection is on and off? also can you please confirm you dont have additional background settings? some manufacturers add multiple settings to turn off with different names like power save, data save etc... you will need to dig deep into phone settings for this as every device is different. |
Yes, whenever I toggle the transmitter in the app, I seem to get 1 beacon, and then it stops
As far as I've been able to dig, there is no additional background settings restricting the app |
can you check for errors in the companion app maybe something is there.
when this happens do you see other things stopping in the background like sensor or location updates? |
In the debug build I got this
No, location update works correctly |
ah that would explain it. in the meantime can you enable the beacon monitor sensor and just grant permissions there....it should avoid that error will work on getting that fixed in the PR. You can disable the sensor after granting whatever permission it requests |
Great
I didn't get asked for any permissions, but the logs changed afterwards
|
yea some permissions are silently granted once requested others require end user confirmation. Now that the permission error is gone did that improve the situation? For myself I started another test on my Pixel 8 pro using the production version and more than 1 hour later I am still transmitting so the foreground service should work as long as the app has proper background access. Unfortunately fairphone is not listed in dontkillmyapp.com however that site does offer good pointers to avoid the background work from stopping |
No, it's the same as before. |
ok appreciate you checking. Updated debug APK with permission fix is here: https://github.com/home-assistant/android/actions/runs/8742056238 are there any HA core errors at the time the issue happens (maybe even debug logs for the integration)? Also are you using bluetooth proxies for detection? Theres a lot of variables at play here, increasingly difficult if we cannot replicate the issue either. Do you have another android device to test with by chance? I think its time we start looking at common denominators in this issue. I would still like for some others with the issue to test with the proposed fix still too. |
I'll give it a test tomorrow
No errors in the HA log. I'm using an esp32 bluetooth proxy
Yes, I should be able to test that tomorrow
|
I tested the new build, it seems to have the same issue. Attaching more logs, I will also make sure to turn it on on the way home this afternoon and see how it behaves then homeassistant_companion_log_3-19-2024_6-38-6.txt
|
thanks for testing again looks like there was an error Error
should be fixed in but I dont think this will fix the scenario for you. https://github.com/home-assistant/android/actions/runs/8755457666 your companion app logs are about 2 minutes long. At what point does it get connected and disconnected? your screenshots also do not show that as the sensor is left as connected. We may need to see logs when the issue occurs. your HA core logs do show the beacon being detected so not sure whats wrong there |
Thanks, installed this now
I've let it run longer now, attaching logs. Whenever the transmitter toggle is changed from off to on, I immediately receive a beacon and then it takes minutes before the next beacon. homeassistant_companion_log_3-19-2024_18-33-49.txt
|
Looks like an unrelated error from the Beacon Monitor sensor, if you enabled it for this test you can turn it off now that the foreground service is part of the transmitter
Also noticed this
did you stop the transmitter here or did it stop on its own? It does not look like the action was stopped but good to confirm we can see somethings seemingly being killed
|
Thats strange, it is turned off according to the GUI
Yes, this was when I stopped the transmitter and then collected the logs |
im still not following the issue here because the device tracker shows it disconnected after you turned off teh transmitter which feels expected here. are you expecting things to be faster than they may actually be? |
That might be the case. When the app says 1Hz, 3Hz or 10Hz for the diffent modes, I would expect there to be beacons every second, 3 every second or 10 every second. Even is this is not true, I thought there should be at least several beacons per minute, not that there is many minutes between beacons. |
not easy digging through our library to see where the values. As far as I can tell we are setting the advertise mode per what Android expects as far as I can tell these values are being added and accepted by the OS |
Ok, thanks. Since the app does send beacons, but they have long intervals between them, then it looks like it's not quite the same issue as originally reported and that it is most likely an issue outside of the home assistant app for me. |
Home Assistant Android version: 2022.11.0-full
Android version: 10
Phone model: LG V40
Home Assistant version: 2022.16
Last working Home Assistant release (if known): N/A
Description of problem:
As far as I can tell, the companion app stops transmitting iBeacon BLE messages shortly after the transmitter is enabled. I have all appropriate permissions (location, battery exclusion) enabled and the transmitter does work shortly after being re-enabled, but will stop working after a few minutes (seems to occur in ~3 minute chunks). Seems to be similar to #1764 and #1855, but those had been resolved some time ago and I am not seeing the same errors.
Traceback
Screenshot of problem:
Note that, with one exception*, each of the increments where my phone is transmitting for ~3 minutes. *The single longer segment is double that of the smaller time-frames.
Additional information:
I am using ESPresense sensors around my home for presence detection. In devices where bluetooth beaconing is built-in (Apple devices, primarily) these sensors have worked very well, so I am confident the sensors are not the problem.
I am also using an automation to turn on/off my transmitter when my phone disconnects from my home Wi-Fi, but this automation is working properly and actually helped me narrow down this issue in the first place. As the screenshots show, there are brief periods where my phone is transmitting and does get detected by my sensors, but the transmission quickly stops despite the transmitter still being enabled and within range.
I have tried many combinations of Advertise mode and Transmitter power, as well as various distances from the sensors.
The text was updated successfully, but these errors were encountered: