The yaml (https://paste.ubuntu.com/p/x8v5MsD5fP/) looks fine - except I’m not so sure about the lines: #23-24
For the sake of a complete example here is also mine:
alias: '[Schedule] Vacuum Kitchen'
description: ''
use_blueprint:
path: pavax/scheduled_timeslot.yaml
input:
time_from: '13:00:00'
time_to: '14:00:00'
monday_enabled: true
wednesday_enabled: true
friday_enabled: true
tuesday_enabled: true
thursday_enabled: true
saturday_enabled: true
last_triggered: input_datetime.vacuum_kueche_last_schedule_triggered
condition_sensor_01: binary_sensor.presence_kitchen
condition_state_01: 'off'
condition_sensor_02: binary_sensor.presence_living_room
condition_state_02: 'off'
condition_sensor_03: vacuum.xiaomi_vacuum_cleaner
condition_state_03: docked
scheduled_action:
- service: script.vacuum_dispatch
data:
room_name: Kueche
A blueprint defines an “off-the-shelf” automation - Thus it’s as powerful as an automation - It’s a scaffolding to allow you to define an automation without the need to copy-paste them but re-use them.
To understand what a blueprint does/is, I recommend you start learning what automations are and how they work. After you mastered that corner, you’ll understand the blueprints as they are an “abstraction” layer higher. Thus a blueprint’s automation is often more complex than you’d rather just write the automation by yourself - But you’d need to define it - the automation - multiple times. In my case I have up to 10 scheduled automations based on that blueprints. I still have 10 automations at the end, but if find a bug in the way on how the automation is defined, I’d only need to fix it in my blueprint (once).
More detailed explanation / knowhow :
The requirement that you have: start the vacuum when personX and personY are not home BUT only in a timeslot, could be defined like to following automation:
Example-A
alias: my-scheduler
description: ''
mode: single
trigger:
- platform: state
entity_id: person.x
to: not_home
- platform: state
entity_id: person.y
to: not_home
condition:
- condition: time
after: '08:00'
before: '15:00'
weekday:
- mon
- tue
- wed
- thu
- fri
- condition: state
entity_id: input_boolean.mimi_cleaned_once
state: 'off'
action:
- service: vacuum.start
data: {}
entity_id: vacuum.xiaomi_vacuum_cleaner
- service: input_boolean.turn_on
data: {}
entity_id: input_boolean.mimi_cleaned_once
This automation (A) now triggers as soon as any personX or personY changes their state to “not_home” (Hint: triggers are evaluated as OR) - Kinda annoying to start a vacuuming if only one of the two left the house To only run the vacuum when the last person has left the house, (among the other conditons such as time) you’d need to add these again as another condition (Hint: conditions are evaluated as AND) as shown in the next example B:
Example-B
alias: my-scheduler
description: ''
mode: single
trigger:
- platform: state
entity_id: person.y
to: not_home
- platform: state
entity_id: person.y
to: not_home
condition:
- condition: time
after: '08:00'
before: '15:00'
weekday:
- mon
- tue
- wed
- thu
- fri
- condition: state
entity_id: input_boolean.mimi_cleaned_once
state: 'off'
- condition: state
entity_id: person.x
state: not_home
- condition: state
entity_id: person.y
state: not_home
action:
- service: vacuum.start
data: {}
entity_id: vacuum.xiaomi_vacuum_cleaner
- service: input_boolean.turn_on
data: {}
entity_id: input_boolean.mimi_cleaned_once
Now, imagine if you have more complex criteria’s: Such as I have in my case: only vacuum in the given timeslot when:
- conditon-1: motion sensor is not ON AND
- conditon-2: tv is not playing AND
- condition-3: person is home
- etc…
It gets quite cumbersome to repeat that always as a trigger and as a condition. And of course, you’d still need to have to reset the input_boolean.mimi_cleaned_once
at midnight (or use the mode: single but add a delay action of x hours). Now imagine doing all that for every scheduled automation having conditions (as in my case for different rooms having their separate set of conditions) … it gets quite difficult to maintain.
Limitations of current blueprint
The fact, that it’s not yet so easy to define more complex triggers with optional inputs in blueprints led me to define it with a simple minute-based time trigger. The automation is triggered on every minute and thus checks its conditions on every minute BUT it won’t execute on every minute (triggering != executing).
Example-C
alias: my-scheduler
description: ''
mode: single
trigger:
- platform: time_pattern
minutes: "*"
condition:
- condition: time
after: '08:00'
before: '15:00'
weekday:
- mon
- tue
- wed
- thu
- fri
- condition: state
entity_id: input_boolean.mimi_cleaned_once
state: 'off'
- condition: state
entity_id: person.x
state: not_home
- condition: state
entity_id: person.y
state: not_home
action:
- service: vacuum.start
data: {}
entity_id: vacuum.xiaomi_vacuum_cleaner
- service: input_boolean.turn_on
data: {}
entity_id: input_boolean.mimi_cleaned_once
Summa summarum: Therefore, I created this blueprint to avoid pitfalls (for beginners) and lower maintenance for managing multiple scheduled automations that rely on conditions