10-09-2023 10:05 AM
Hello all,
I am attempting to create an automation in the script editor that reminds my wife and I if the vacuum has not run in three days or more. It looks like my starter is failing, but I cannot use device.state.Dock for: 72hours as a condition since "for:" is not allowed as a condition. I also tried a scheduled time as the starter and device.state.Dock as a condition with the "greaterthanorequalto: 72hours" as a condition, however it said 72hours was an invalid format. Does anyone have any ideas on how to fix this? I have pasted my code below.
metadata:
name: Vacuum Reminder # Choose a short name that summarizes important starters and actions, like “Sunset lights”.
description: Reminder to run the vacuum every three days. # Write a detailed description that includes everything the automation does, like “At sunset, on weekdays, close blinds, turn on lights to 50%, and play the sunset playlist on certain speakers.”
automations:
# “starters” and “actions” are required; “conditions” are optional.
# Use Ctrl + Space to see autocomplete suggestions.
# ---- STARTERS ---- #
# Starters describe events that will start the automation.
# To add more than one starter, duplicate the "- type" section under "starters".
# If you add multiple starter events, any one of them happening will start the automation.
starters:
- type: device.state.Dock
state: isDocked
# [available operators: is, isNot]
is: true
for: 72hour
device: Roborock Q7 Max - Living Room
# ---- CONDITIONS ---- #
# Conditions are optional. Delete this section if it’s empty.
# Conditions will prevent an automation from starting if the conditions aren’t met.
# See g.co/home/script-editor-docs for documentation about how to use logical operators like “and”, “or”, and “not”.
condition:
type: and
# "AND" together two or more conditionals
conditions:
- type: home.state.HomePresence
state: homePresenceMode
# [available operators: is, isNot]
is: HOME
- type: time.between
# Optional. Accepts either clock time (10:00:00 AM, with seconds optional, or in a 24 hour format), or 'sunrise' or 'sunset', with an optional offset ('sunrise+10m', for instance)
before: 19:00 # HH:MM (24 hours format). Adjust time as needed
# Optional. Accepts either clock time (10:00:00 AM, with seconds optional, or in a 24 hour format), or 'sunrise' or 'sunset', with an optional offset ('sunrise+10m', for instance)
after: 11:00 # HH:MM (24 hours format). Adjust time as needed
# Optional. Days of the week to apply condition on.
weekdays:
- MON
- TUE
- WED
- THU
- FRI
- SAT
- SUN
# ---- ACTIONS ---- #
# Actions will start when a starter event takes place and all conditions are met.
# Actions will start in the order they appear in the script and with any delay specified.
# To add more than one action, duplicate the "- type" section under "actions".
actions:
- type: home.command.Notification
title: Vacuum
body: It has been 3 days since the vacuum has run.
members:
- #
- #
12-12-2023 12:14 PM
I have a similar problem with my vacuum and I now assume the state.Dock is not recognized/triggering.
If I remove the condition, replace it with other conditions, the script is working...
Does your script work if you remove the for.. ?
starters:
- type: time.schedule
at: 20:15
# ---- CONDITIONS ---- #
condition:
type: device.state.Dock
is: false
state: isDocked
device: Rosie
# ---- ACTIONS ---- #
actions:
- type: assistant.command.Broadcast
message: Vergeet Rosie niet schoon te maken en op te laden
devices: Speaker
- type: time.delay
for: 6sec
- type: device.command.StartStop
start: true
devices: Rosie
- type: time.delay
for: 9sec
- type: device.command.StartStop
start: false
devices: Rosie