Turning on the porch lights for my DoorDasher (Using the "Active Notification Count" Android Sensor)

I was looking at the “Active Notification Count” sensor available via the android companion app, and I was inspired to try and use it to turn on my front porch light when I get the notification on my phone from doordash that says my dasher is nearby.

I feel like all of the pieces are there to make this possible, but after a few hours of searching, and trial-and-error, I do not feel like I am getting any closer to my goal. An example would really help, I think, but I cannot seem to find any examples of automations like this. Anyone have one?

I can see all the info about my notifications in the attributes of the sensor, (including the app that sent them and the text), and the sensor seems to update pretty quickly (usually).

But there are some aspects of this that I cannot seem to figure out.

  • (Since I do not have a doordash notification available right now, I’ll use a youtube notification as an example)… There is an attribute called “Android.title com.google.android.youtube 99”. The “Android.title” part of it seems obvious enough… and the “com.google.android.youtube” part is the app that sent the notification… so far so good. But where is that “99” coming from? Is that the PID of the executable running in android? If so, wouldn’t that mean it changes every time I reboot, or force-close and reopen an app? This is my biggest problem.

  • Is there any way to do a wildcard for the attribute name? E.g., “Android.title com.google.android.youtube *”? That feels odd… so probably not.

  • Even if I could guess the attribute name of the notification I care about, what happens if you make a trigger (or condition) that references an attribute that does not (yet) exist? Is that well behaved?

  • And lastly, I do not recall for certain, but I think the text of the notification changes each time (I.e., I think it includes the dasher’s name), so I don’t think I can just directly compare the attribute value. I’d need a “contains substring” type thing, to find “is nearby”, for example. Is that a thing?

Anyway… long story short… it seemed like a neat, and useful automation to have, but I am having trouble finding any sort of similar examples to work from.

Any ideas?

I think this should work:

{{ "is nearby" in state_attr('sensor.your_phone_notification_sensor', 'your_sensor_attibute') }}

for example…

the notification sensor is - sensor.mobile_app_notification

the attribute is - last_notification

it would be:

{{ "is nearby" in state_attr('sensor.mobile_app_notification', 'last_notification') }}

use that in your automation trigger

Thanks, but for some reason it isn’t working for me.

In particular, the Last Notification sensor does not seem to want to work for me.
It is Enabled on my phone, and I have disabled the allow list, (which I think means all app notifications should be included?), and I have granted the permissions for the app, but it never actually contains any values. In HA, it shows the last update was 20hrs ago (when I re-enabled the sensor to test it again), but it does not actually have a value. It’s just always blank.

That’s why I was leaning towards the Active Notification Count sensor instead. Because it does include all the data, but I am just not skilled enough to make use of it in HA.

What is this sensor entity_id?

And what is the attribute called that contains the information you want?

The entity id is sensor.pixel_6_pro_active_notification_count

And the attribute seems to be more complicated, including the name of the app, and a number.
My example above was “Android.title com.google.android.youtube 99

No, I mean what is the name of the attribute?

you gave me the data contained in the attribute but not the attribute name.

post a screenshot of the sensor showing it’s attributes.

edit out any sensitive information.

No, really… “Android.title com.google.android.youtube 99” IS the name of the attribute. That’s my problem. The data contained in the attribute is the text that is the title of the notification. E.g., in the screenshot below, the Android.title com.google.android.youtube 99 notification has “Pitch Meeting” for its data.

Here you go:

you need to go to the dev tools->states tab and take a screenshot of the sensor there.

The one you posted is a screenshot of the more-info pop-up (I think).

it should look something like this:

Okay, here it is from the other page:

It looks pretty much the same as in the other page except that the spaces are changed to underscores, and it feels a little harder to read (to me).

And since this sensor has 141 separate attributes (right now… it changes depending on what notifications are on the phone), here it is scrolled down a little, to some of the Android.text and Android.title ones, which contain the information I am looking for:

everything is lowercase, that’s important.

If you’re trying to search for an attribute, you’d have to iterate the attributes.

{% for attribute, value in states.sensor.xxx_active_notification_count.attributes.items() %}
  {% set notification, app, id = attribute.split('_') %}
  {% if notification == 'android.title' and app =='com.google.android.youtube' %}
    {{ value }}
  {% endif %}
{% endfor %}

It’s working well now.