android: clear_notification command not working when several notifications are shown
Home Assistant Android version: 2021.3.1-full
Android version: 11
Phone model: Oppo Find X2 Pro (ColorOS 11) Xiaomi Mi 9 (MIUI 12.0.4)
Home Assistant version: core-2021.3.2 Python 3.9 virtual env
Last working Home Assistant release (if known): None
Description of problem: I’m using an automation that notify user’s mobile apps that some windows are opened. When the window is closed, the notification is cleared on all the mobile apps. It works perfectly when a single window is opened and closed. But when two windows are opened, it creates two notifications, and when the windows are closed, only one notification is cleared, the second one remains on the phones until manually dismissed.
I made the automation below to reproduce the issue. One notification is created, and cleared after 5 seconds, then a second notification is created with a different tag, and then cleared after 5 seconds. Then the first notification is created again ; 5 seconds later the second notification is created ; 5 seconds later the first notification is successfully cleared, but 5 seconds later the second notification is not cleared as expected .
`alias: Notifications Test description: Creates and clear one or multiple notifications on mobile app trigger: [] condition: [] action:
- service: notify.notify data: title: Test notification message: Create notification 1 data: ttl: 0 priority: high tag: tag_one color: yellow
- delay: hours: 0 minutes: 0 seconds: 5 milliseconds: 0
- service: notify.notify data: title: Test notification message: clear_notification data: ttl: 0 priority: high tag: tag_one color: yellow
- delay: hours: 0 minutes: 0 seconds: 5 milliseconds: 0
- service: notify.notify data: title: Test notification message: Create notification 2 data: ttl: 0 priority: high tag: tag_two color: green
- delay: hours: 0 minutes: 0 seconds: 5 milliseconds: 0
- service: notify.notify data: title: Test notification message: clear_notification data: ttl: 0 priority: high tag: tag_two color: green
- delay: hours: 0 minutes: 0 seconds: 5 milliseconds: 0
- service: notify.notify data: title: Test notification message: Create notification 1 data: ttl: 0 priority: high tag: tag_one color: yellow
- delay: hours: 0 minutes: 0 seconds: 5 milliseconds: 0
- service: notify.notify data: title: Test notification message: Create notification 2 data: ttl: 0 priority: high tag: tag_two color: green
- delay: hours: 0 minutes: 0 seconds: 5 milliseconds: 0
- service: notify.notify data: title: Test notification message: clear_notification data: ttl: 0 priority: high tag: tag_one color: yellow
- delay: hours: 0 minutes: 0 seconds: 5 milliseconds: 0
- service: notify.notify data: title: Test notification message: clear_notification data: ttl: 0 priority: high tag: tag_two color: green mode: parallel max: 10 `
Traceback (if applicable, to get the logs you may refer to: https://companion.home-assistant.io/docs/troubleshooting/faqs/#android-crash-logs):
[logcat_03-16-2021_09-04-02.txt](https://github.com/home-assistant/android/files/6147050/logcat_03-16-2021_09-04-02.txt)
Screenshot of problem:
Additional information:
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 22 (15 by maintainers)
I could reproduce this issue and fixed it in the PR #1452
Thanks @ScratMan for the logs and testing 👍
Hi, here is a new log with the beta. I could reproduce the issue the same way. [ logcat_03-24-2021_21-16-40.txt ](url)
I installed the beta app on my Pixel C tablet running LineageOS 17.1, and the notifications are cleared correctly. So the issue really seems to be system related.
logcat_03-24-2021_22-01-05.txt
@chriss158 so one thing that I noticed is that it seems when the call to cancel the notification is made successfully we see the following logcat from Android
In the attached logs you see this all the time except for the last one. I wonder if we need to add some debug logs to our overriding of the cancel operation to see if there is some unexpected data. Maybe some variable is coming in with unexpected data which causes us to skip the operation for some reason?
I looked in the Android’s history. I just checked in the app, and the notifications and clear commands are there.