Automating Porch Lights with Notifications: A Success Story

Hey everyone, I wanted to share a fun and useful automation I recently set up using the Active Notification Count sensor from the Android companion app. The goal was to have my porch lights turn on automatically when I receive a notification from DoorDash indicating that my delivery person is nearby. While the idea seemed straightforward, the execution was a bit of a puzzle, but I managed to crack it!

The Setup

I started by exploring the Active Notification Count sensor, which tracks notifications on my phone. The key was figuring out how to detect specific notifications, like the DoorDash ones, and trigger an action. I discovered that each notification has unique attributes, such as Android.title followed by the app package name and a PID. This was both exciting and a bit overwhelming, as the PID changes with each app restart.

Challenges and Solutions

One major challenge was determining how to consistently identify the DoorDash notification without relying on the PID. I realized that while the PID changes, the app package name (com.delivery.door) remains constant. This led me to focus on filtering notifications based on the app package rather than the PID. I also needed to handle the text within the notification, which includes the delivery person’s name, making exact matches impractical. Instead, I opted for a contains substring approach to check for phrases like “is nearby.”

The Automation Flow

Here’s a simplified version of what I did:

  1. Notification Detection: Monitor the Active Notification Count sensor for new notifications from the DoorDash app.
  2. Text Matching: Use a condition to check if the notification text contains the substring “is nearby.”
  3. Porch Light Activation: If the condition is met, turn on the porch lights and send a notification to my phone confirming the action.
  4. Auto-Turn Off: Set a timer to turn off the lights after 15 minutes to avoid leaving them on unnecessarily.

Lessons Learned

  • Attributes are Your Friend: Dive into the attributes of your sensors to find unique identifiers for notifications or other events.
  • Wildcard Usage: While not directly supported, focusing on consistent parts of attribute names (like app package names) can help bypass the need for wildcards.
  • Substring Matching: When exact matches aren’t feasible, substring checks can provide the flexibility needed for dynamic data.

Community Thanks

I’d like to extend a huge thank you to everyone in the community who shared their knowledge and examples. Without your insights, I might still be stuck trying to figure this out. If anyone has similar ideas or needs help setting something up, feel free to reach out—I’d be happy to share more details!

This project has been a fantastic way to enhance my home automation setup and gives me peace of mind knowing my porch lights will always be ready to greet my deliveries. Happy automating everyone! :rocket: