Last Notification sensor w/ consecutive notifications on Android

… I need to be very diligent about dismissing each notification as it comes in…

Regarding the above statement: I’ve experienced the same issue but I don’t believe the issue source is because you didn’t dismiss a notification. i.e. I’ve had this issue where I got the com.dd.doordash response with not text but then another notification comes in and it displays just fine. Please note I haven’t dismissed or even read any notifications on my phone.

I haven’t been successful in tracking this issue down. Things I’ve noticed:

  1. The missing data message shows fine on the phone.
  2. For me, when this occurred the space between previous and next messages are in “minutes”. No insta-double notification.
  3. Only started happening “recently” for me. Unfortunately i don’t know what revision of HA it was working properly versus not.
  4. I have not had this issue with UberEats…yet.

what about the rest of attributes? That notification may use a different API for showing the text in the title or elsewhere.

please keep in mind that Doordash app updates can also impact the data the sensor gets, best to look at all attributes to see what data is coming into the app.

Where do I find the attributes historically? Unless it’s the current state it only keeps the big.Text attribute.

you would have to template it to see them historically

For me, it is only the second notification that is messed up.
The first comes in fine.
The second comes in as com.dd.doordash.
And the third and subsequent ones are fine.

So, if I always dismiss the first one after it comes in, everything works.

If I forget to dismiss, then the second one is bad, but if I continue to forget to dismiss, then it works fine again when the third (and later) ones come in, … until I dismiss them all again.

Does that match your experience?

Ok found what’s happening: So I was able to see in the Trace for my trigger that it changes state to the below. You’ll notice it’s missing a bunch of android.xxx attributes. I’m grabbing state, even though I know there are things like big text, sub text, etc. but this event for some reason is missing all informational attributes? This particular notification shows in the app fine.

to_state:
    entity_id: sensor.myphone_last_notification
    state: com.dd.doordash
    attributes:
      android.appInfo: ApplicationInfo{13b0cf7 com.dd.doordash}
      android.reduced.images: true
      category: 'null'
      channel_id: delivery_status_channel_id
      group_id: ranker_group
      is_clearable: true
      is_ongoing: false
      package: com.dd.doordash
      post_time: 1710360401282
      icon: mdi:bell-ring
      friendly_name: My Phone Last notification
    last_changed: '2024-03-13T20:06:42.089295+00:00'
    last_updated: '2024-03-13T20:06:42.089295+00:00'

thats because its a grouped notification which was the last item to post to the devices status bar. Thats how the sensor works it listens to updates to when things are added to the status bar and sends those updates. When a notification becomes grouped it has different data. The active notification sensor should contain data for all notifications posted to the status bar including all grouped items. It has a lot of attributes and are therefore not stored in the db.

So what then is the recommendation? If I’m following, you’re saying the grouped notification doesn’t log the attributes but ARE there and rather read from the state I should just try to read from Bigtext for example? FYI that makes debugging difficult with inconsistencies like that.

every app is going to have different data when it posts a notification, we cant account for all of the differences. What we can do is provide all of the data we get so users can decide what is best for their situation.

Right I understand that, but can you confirm what I stated? The attributes are there you just don’t log in a grouped text scenario?

I ask as the notification that is triggered here does display on the phone correctly, so the data has to be somewhere.

no they are not there, otherwise we would have them. Remember there is a difference between the grouped notification and the individual notification items. The group is always the last item to post.

Help me understand the difference here between the grouped notifications and individual notifications relevant to the original problem statement?

i.e. there is a notification that shows on the phone with the correct text, but that same notification is captured as a “group notification” with no data. So where did the data go? I feel like I’m missing something obvious here :wink:

so your phone already has 1 notification which the sensor sent, when it gets a second one it may create a grouped notification. The sensor itself only reports whats posted to the status, so upon receiving the second notification it may group the notifications which results in an additional item being posted to the status bar. Different devices and apps do different things. A pixel device will group the notifications if not already grouped by the app after a set amount of notifications (4).

you can also group the HA notifications you send to your device: https://companion.home-assistant.io/docs/notifications/notifications-basic/#grouping

the active notification sensor that I mentioned a few posts up, that sensor contains data for all notifications currently visible on the status bar.

I don’t see an " active notification sensor" available my mobile device. I have “active notification count” but the only relevant sensor is “last notification” which is what I’m currently using.

thats the same thing

not sure i follow…both sensors will contain the data you are looking for…last notification only contains the data of the last posted notification.

I never enabled “active notification count” as I assumed it’s literally just telling me the number of active notifications, which I wouldn’t find useful.

not sure i follow…both sensors will contain the data you are looking for…last notification only contains the data of the last posted notification.

I know what last notification does, that’s the sensor I’m currently using in my automations but that’s where, per my previous posts, I’m getting the notification with a state of “com.dd.doordash” rather than the expected text which is shown on the phone.

all details on the sensor can be found in the docs: https://companion.home-assistant.io/docs/core/sensors#active-notification-count

yes that is because teh notification does not contain that data.

https://github.com/home-assistant/android/blob/2373127fb0ff1be447e4138ae1f2c85aad2645c8/app/src/main/java/io/homeassistant/companion/android/sensors/NotificationSensorManager.kt#L157

The logic for the state of the sensor is as follows: if text is not present go for notification title, if title is not present then use the package name because every notification has a package name

Ok so let me see if I’m following correctly. Based on what you just described, in context to the original problem statement:

The last notification sensor doesn’t contain the updated text I’m expecting because the specific notification that came through is an update to a grouped notification?

But that extra data I’m expecting does exist in the “active notification count” sensor (which is NOT an intuitive name by the way :slight_smile: ) however I’d now have to build logic to parse through that now as well?

not sure if its an update, its just another item posted to the status bar that the app gets notified about

if you need the data then yes you need to parse it. The name itself was taken by the API used for the state and attributes

https://developer.android.com/reference/android/app/NotificationManager#getActiveNotifications()

Oh for last notification I’m using the allow list. I only allow UberEats and Doordash. I also just read that the active notification count doesn’t have an allow list :wink: