Mastering Advanced Notifications: Building Dynamic, Actionable, and Multimedia Alerts in Home Assistant
NGC 224
DIY Smart Home Creator
The Challenge with Basic Notifications
Generic 'motion detected' alerts often lack context and interaction, leaving users needing more to respond effectively. Imagine receiving a doorbell notification that not only shows you who's there but also lets you unlock the door or dismiss the alert with a single tap. Many Home Assistant users struggle with notification overload or missing critical information. This guide will transform your smart home's communication by building sophisticated, context-aware notification strategies using Home Assistant's powerful services, enabling dynamic content, actionable buttons, and rich multimedia.
Step-by-Step Setup: Essential Notification Services
The Home Assistant Companion App for iOS or Android is foundational for advanced notifications due to its deep integration. Install it and log in; it automatically creates a service like notify.mobile_app_your_device_name.
To find your specific service name, navigate to Developer Tools > Services, filter by notify, and locate your device's mobile_app_ service.
A basic notification automation:
automation:
- alias: "Send Test Mobile Notification"
trigger:
- platform: state
entity_id: binary_sensor.front_door
to: "on"
action:
- service: notify.mobile_app_your_device_name
data:
message: "Front door opened!"
For redundancy, consider services like Telegram or Pushover. Integrate them by following their respective documentation pages for configuration.yaml setup.
Step-by-Step Setup: Actionable Notifications
Actionable notifications enable direct interaction from the notification itself, primarily via the Home Assistant Companion App. This requires two main parts: defining the actions and sending/handling them.
1. Define Actions in configuration.yaml
Define global actions in your configuration.yaml under the mobile_app section (or a dedicated package file). The identifier is crucial for matching the action later.
mobile_app:
ios:
actions:
- name: "UNLOCK_FRONT_DOOR"
description: "Unlock Front Door"
icon: "sfsymbols:lock.open"
identifier: "unlock_front_door_action"
authentication_required: true # Recommended for sensitive actions
android:
actions:
- name: "UNLOCK_FRONT_DOOR"
description: "Unlock Front Door"
icon: "mdi:lock-open-variant"
identifier: "unlock_front_door_action"
authentication_required: true
Restart Home Assistant after modifying configuration.yaml for actions to register with your app.
2. Send & Respond to Actionable Notifications
Modify an automation to include defined actions. Home Assistant fires a mobile_app_notification_action event when an action is tapped.
automation:
- alias: "Front Doorbell Actionable Notification"
trigger:
- platform: state
entity_id: binary_sensor.doorbell_button
to: "on"
action:
- service: notify.mobile_app_your_device_name
data:
message: "Someone is at the front door!"
data:
actions:
- action: "unlock_front_door_action"
title: "Unlock Door"
- action: "ignore_doorbell_action"
title: "Ignore"
- alias: "Handle Front Door Unlock Action"
trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "unlock_front_door_action"
action:
- service: lock.unlock
target:
entity_id: lock.front_door_lock
- service: notify.mobile_app_your_device_name
data:
message: "Front door unlocked by {{ trigger.event.data.source }}!"
Step-by-Step Setup: Multimedia Notifications
Integrate images or video clips into your notifications, especially useful for security cameras or visual confirmations.
Camera Snapshot Notification
This powerful feature sends a snapshot from your camera when an event occurs. The image needs to be accessible via a URL.
automation:
- alias: "Send Camera Snapshot on Motion"
trigger:
- platform: state
entity_id: binary_sensor.backyard_motion
to: "on"
action:
# Take snapshot and save to www/tmp, accessible via /local/tmp/
- service: camera.snapshot
data:
entity_id: camera.backyard_camera
filename: "/config/www/tmp/backyard_motion.jpg"
- delay: "00:00:01" # Give the camera a moment to save
- service: notify.mobile_app_your_device_name
data:
message: "Motion detected in the backyard!"
data:
image: "https://your_home_assistant_url/local/tmp/backyard_motion.jpg?cachebuster={{ now().timestamp() }}"
# The cachebuster ensures the latest image is fetched
Ensure /config/www/ exists for storing images. The https://your_home_assistant_url must be externally accessible, or use your internal IP if the device is on your local network (e.g., http://192.168.1.100:8123/local/...).
Troubleshooting Common Notification Issues
- Notifications Not Received: Verify Companion App notification permissions, device ID in automation (
notify.mobile_app_your_device_name), and Home Assistant's external/internal URL accessibility from your phone. Check the app's internal notification history for clues. - Actionable Buttons Not Appearing/Working: Restart Home Assistant after defining actions in
configuration.yaml. Ensure theactionidentifier in the notification service call precisely matches theidentifierin yourmobile_appconfig. Verify theevent_datain your action-handling automation also matches. - Multimedia Not Loading: Confirm the
imageURL is directly accessible by your mobile device. For local files, ensure they are in<config_dir>/www/and referenced with/local/. Use thecachebustertrick for dynamic images.
Advanced Configuration and Optimization
1. Dynamic Content with Templates
Use Jinja2 templates for context-rich messages, icons, and URLs based on sensor states or event data.
action:
- service: notify.mobile_app_your_device_name
data:
message: >
It's {{ states('sensor.outdoor_temperature') | round(1) }}°C.
Window is {% if is_state('binary_sensor.kitchen_window', 'on') %}open{% else %}closed{% endif %}.
data:
color: "{% if states('sensor.outdoor_temperature') | float > 25 %}red{% else %}green{% endif %}"
2. Persistent Notifications for Critical Alerts
For alerts requiring explicit acknowledgment or long-term visibility within Home Assistant's UI, use persistent_notification.create. Dismiss them with persistent_notification.dismiss and the same notification_id.
action:
- service: persistent_notification.create
data:
title: "Critical Alert!"
message: "Server offline for 5 minutes."
notification_id: "server_offline"
3. Notification Groups
Combine multiple notification services into a single group to simplify sending alerts to various devices/platforms simultaneously.
# configuration.yaml
notify:
- name: "family_alerts"
platform: group
services:
- service: mobile_app_johns_phone
- service: mobile_app_janes_phone
- service: telegram_notifications
Now use notify.family_alerts in automations.
4. Rate Limiting and Cooldowns
Prevent notification spam using `mode: single` and `delay` in automations, or more advanced conditions involving input_boolean for longer cooldowns.
automation:
- alias: "Backyard Motion Notification with Cooldown"
trigger: ...
condition:
- condition: template
value_template: "{{ (now() - state_attr('automation.backyard_motion_notification_with_cooldown', 'last_triggered')).total_seconds() | int > 300 }}" # 5 mins
action:
- service: notify.mobile_app_your_device_name
data:
message: "Motion detected!"
mode: single
Real-World Example: Enhanced Smart Doorbell
Here's a combined automation for a smart doorbell, taking a snapshot, sending it with actionable buttons, and securely handling the response.
# automation.yaml (assuming mobile_app actions are defined in configuration.yaml)
- alias: "Doorbell Press: Snapshot, Notify, Actions"
trigger:
- platform: state
entity_id: binary_sensor.front_doorbell_button
to: "on"
variables:
snapshot_path: "/config/www/doorbell_snapshots/doorbell_{{ now().strftime('%Y%m%d_%H%M%S') }}.jpg"
snapshot_url: "https://your_home_assistant_url/local/doorbell_snapshots/doorbell_{{ now().strftime('%Y%m%d_%H%M%S') }}.jpg"
action:
- service: camera.snapshot
data:
entity_id: camera.front_door_camera
filename: "{{ snapshot_path }}"
- delay: "00:00:01"
- service: notify.family_alerts # Using a notification group
data:
message: "Someone is at the front door!"
title: "Doorbell Ring"
data:
image: "{{ snapshot_url }}"
tag: "doorbell_alert" # Group related notifications on Android/iOS
actions:
- action: "unlock_front_door_action"
title: "Unlock Door"
- action: "ignore_doorbell_action"
title: "Dismiss"
- alias: "Handle Doorbell Action Responses"
trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "unlock_front_door_action"
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "ignore_doorbell_action"
action:
- choose:
- conditions: "{{ trigger.event.data.action == 'unlock_front_door_action' }}"
sequence:
- service: lock.unlock
target:
entity_id: lock.front_door_lock
- service: notify.family_alerts
data:
message: "Front door unlocked!"
- conditions: "{{ trigger.event.data.action == 'ignore_doorbell_action' }}"
sequence:
- service: notify.family_alerts
data:
message: "Doorbell alert dismissed."
Best Practices and Wrap-up
Crafting effective Home Assistant notifications is key to a responsive smart home:
- Security First: Always use
authentication_required: truefor sensitive actionable notifications (e.g., unlocking doors, disarming alarms) to leverage device biometrics. - Maintainability: Organize complex notification setups using Home Assistant packages to keep related configurations in separate YAML files.
- Reliability: For critical alerts, employ notification groups to send messages to multiple services or devices, providing redundancy.
- User Experience: Avoid notification fatigue. Implement rate limits and cooldowns. Use dynamic content and multimedia to provide rich context without overwhelming the user.
- Testing: Regularly test all notification paths and actionable responses, especially after updates or configuration changes. Use Developer Tools > Services for manual triggers.
By applying these advanced techniques, your Home Assistant notifications will evolve from simple alerts into a powerful, interactive communication system, enhancing the intelligence, security, and overall usability of your smart home.
NGC 224
Author bio: DIY Smart Home Creator
