I will show you how to create an actionable notification in Home Assistant, that ask if Roomba should run, when I have left the house.
For me, this is not a problem on normal workdays, but in holiday periods or periods where I work from home, I always forget to start the robot vacuum cleaner when I leave the house. This automation using the actionable notification feature in Home Assistant, will give a reminder on my phone, and a very easy way to start the robot vacuum cleaner directly from the notification on the phone.
Requirements:
– You have installed the Home Assistant companion app on your phone.
– You have network connection to your Home Assistant when you are out of the house.
Quick overview of the automation used:
The first condition checks if anyone is home. See this article about making better presence detection.
The 2. condition checks when the automation was last run, and is only true if the automation haven’t run the last 10 minutes. I use this condition when I have multiple triggers, and don’t want to be spammed with notifications. See how to create it here.
Now lets see how the magic works under actions.
Service: Notifications: Send a notification via mobile_app_sm_a546b (Change it to your phone)
title: Start Roomba?
data:
push:
sound:
name: default
critical: 1
volume: 1
actions:
- action: StartRoomba
title: "Yes"
- action: "No"
title: "No"
This will send a notification to your phone with the title “Start Roomba?”, and you can choose “yes” or “no” on the notification.
At the same time our automation went to the next step, which is to wait for a response from the user.
When it receives a response, it will move on. If no response is given, it will stop the automation after 1 hour.
The last step is catching the answer, and taking action based on the answer.
I only made a single option, so if the answer is “no”, there is no match, and the automation ends.
I hope this have given you a good idea on how to setup and use actionable notifications in Home Assistant, it definitely made my life a little easier, and my house a little cleaner. 🙂
Another example could be to close the garage port when its been open for more than 10 min, or when you have left home, but that of course requires that you can control the garage port from Home Assistant.
This automation was made and tested on Home Assistant version 2023.12.4.
The full YAML configuration:
alias: Roomba when I am not home
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.residents_presence
to: "off"
from: "on"
for:
hours: 0
minutes: 5
seconds: 0
condition:
- condition: state
state: "off"
entity_id: binary_sensor.residents_presence
- condition: template
value_template: |-
{% set nw = now() %}
{% set last = state_attr('automation.roomba_notification_when_out', 'last_triggered') %}
{{ 00 <= nw.hour < 24 and
(last is none or (nw - last).total_seconds() > 60 * 6) }}
enabled: true
- condition: state
entity_id: vacuum.roomba
state: docked
action:
- service: notify.mobile_app_sm_a546b
data:
title: Start Roomba?
message: ""
data:
push:
sound:
name: default
critical: 1
volume: 1
actions:
- action: StartRoomba
title: "Yes"
- action: "No"
title: "No"
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: StartRoomba
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "No"
continue_on_timeout: false
timeout: "1:00"
- choose:
- conditions:
- condition: template
value_template: "{{ wait.trigger.event.data.action == \"StartRoomba\" }}"
sequence:
- device_id: da5fe7ff38406de9824f354ec319c130
domain: vacuum
entity_id: 89733010534ff859cfcedd920f9b6b35
type: clean
mode: single