I am trying to get a phone notification automation working to run my vacuum if it hasn’t been ran for a few days.
I have an automatic automation working so when everyone leaves the house, the vacuum runs and stores the date it ran.
Now I am having trouble with getting the phone notification running.
Here is what I have after researching for quite a while.
- id: '1677698617602'
alias: Vacuum Run Notification
description: ''
trigger:
- platform: time
at: 09:00:00
condition:
- condition: template
value_template: '{{ now() - state_attr(''input_datetime.vacuum_last_ran'', ''last_triggered'')
> timedelta( days=3 ) }}'
action:
- service: notify.mobile_app_jason_pixel_6_pro
data:
title: Run The Vacuum?
message: It has been 3 days since the vacuum has ran, do you want to run it
now?
data:
actions:
- action: URI
title: Run Vacuum
uri: /lovelace-mobile/vacuum
mode: single
Set the date for several days after the vacuum run. Your helper would then not be “when the vacuum last ran” but rather “when the vacuum should run next time”.
Now you can use this helper in an automation to fire the vacuum up as soon as it meets the condition.
This is probably the best type of automation decision ever. It’s dumb to vacuum on a schedule if you have even a three-workday nine-to-five, since you will leave your home at some point, so it’s ideal to vacuum when you are not there and the noise doesn’t matter.
In node red I have a flow that fires the vacuum if the vacuum is docked and I left home and a date time helper is on, and when the vacuum ceases to vacuum (it changes state to docked) I push the date time helper to the next day. That’s really all.