No need from yaml Thanks to the blueprints you can do everything in the UI: Just install (Import) my blueprint (Configuration -> Blueprint) and then based on it create a automation (there is a screenshot of the UI on how my blueprint get’s rendered in my initial post)
i’ve set it up. it looks like this: https://paste.ubuntu.com/p/x8v5MsD5fP/
after looking at the blueprint i understood how it works. my basic understanding is that the blueprint is linked to the automation. and i noticed that the trigger for the blueprint, hence automation is the template you created, which is always modified by the automation itself using the ‘last triggered at’ field. that is nice indeed. i still got alot to read, and hopefully better understand templates. thanks for your help
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
Just saw the reply. That is how the blueprint exported the automation. Just imported the blueprint, filled it in and saved it. Then went to yaml mode and pasted it here. I have a basic understanding of how automations work, not familiar with sensors, states, and what HA can actually do, to the last bit. It’s quite some info, and the documentation is not really up to date. Thanks for taking you time to explain this much, it’s more than i discovered in the discord server.
the noob is back. any ideea why this error ?
Logger: homeassistant.components.automation
Source: components/automation/init.py:517
Integration: Automation (documentation, issues)
First occurred: 5:19:08 PM (1 occurrences)
Last logged: 5:19:08 PM
Blueprint Scheduled Timeslot generated invalid automation with inputs OrderedDict([(‘time_to’, ‘25:00:00’), (‘monday_enabled’, True), (‘tuesday_enabled’, True), (‘wednesday_enabled’, True), (‘thursday_enabled’, True), (‘friday_enabled’, True), (‘time_from’, ‘8:00:00’), (‘condition_sensor_01’, ‘person.xxx’), (‘condition_state_01’, ‘not_home’), (‘condition_sensor_03’, ‘vacuum.mimi’), (‘condition_state_03’, ‘docked’), (‘condition_sensor_02’, ‘person.xxx’), (‘condition_state_02’, ‘not_home’), (‘scheduled_action’, [OrderedDict([(‘service’, ‘vacuum.start’), (‘data’, OrderedDict()), (‘entity_id’, ‘vacuum.mimi’)])]), (‘last_triggered’, ‘input’)]): Invalid time specified: 25:00:00 for dictionary value @ data[‘condition’][1][‘before’]. Got None
25:00:00 o’Clock is not a valid time. HA used the 24h time format where midnight is defined as 00:00:00
That i pretty much know about 25:00:00 So how to avoid that? Since it says that the blueprint generated it, but I could not find anywhere time_to as a value. And the ~input_boolean.last cleanup~ returns a correct value as in corect time syntax
I’m sorry but I don’t understand your question… The blueprint did not generate that issue. Somewhere someone must have had defined the time_to
(in the ui labelled as “Timeslot to”) of the blueprint’s automation to be 25:00:00
. I’d suggest editing that automation manually. Search for the “time_to” in your automation’s yaml (or overall, in your automations.yaml) and change it to 00:00:00
Yes, my bad, sometimes i type one thing when I want to express something else. I also did not have all the information. My automation created with the blueprint is the one I placed higher in this discussion. Only time_to value is time_to: ‘15:00’ , were it’s a condition from what time to what time the automation should run. now that i think of it, in your blueprint you are using am-pm, i entered 15:00:00. but now* looking at your code, you have the same way of declaring it. here is my automation again: alias: Mimi Schedule
description: ‘’
use_blueprint:
path: pavax/scheduled_timeslot.yaml
input:
time_to: ‘15:00:00’
monday_enabled: true
tuesday_enabled: true
wednesday_enabled: true
thursday_enabled: true
friday_enabled: true
time_from: ‘8:00:00’
last_triggered: input_datetime.house_is_cleaned
condition_sensor_01: person.yy
condition_state_01: not_home
condition_sensor_02: person.xx
condition_state_02: not_home
scheduled_action:
- service: vacuum.start
data: {}
entity_id: vacuum.mimi
sunday_enabled: true
saturday_enabled: true
my question is actually were to look for that time_to
, except the automation, wich does seems to have a corect time.
mhhh… looking at the blueprint automation from above (please use the formatting next time) it has nothing to do with the error you pasted above. For example, in the error above the condition_sensor_03
is defined whereas in the automation that you pasted it’s not. My guess is, somewhere you have another automation based on my blueprint that is messed up.
Hava a look at your config/automation.yaml
file (where all the automations are stored) and search for the culprit by searching for all the occurenses of pavax/scheduled_timeslot.yaml
and spot the one where time_to: "25:00:00"
is defined
PS: I installed the addon “File editor” to edit files directly from within the web-ui
yes, you are right. there still is an automation in the automations.yaml. i deleted it from UI/automations but its still present in yaml. i did not found an other way of deleting automations, and it seems automation.yaml is not being edited by UI.
Usually, the ui does exactly that. It modifies the automation.yaml. My guess is, that there could be a bug though linked to blueprints. So just manually delete the invalid one from the automations.yaml file and make sure you either restart HA or reload the automations
Hint: press "c"
while in the web-ui to open the command suggestion dialog and enter “reload automation”
thanks again, and sorry for hijacking.
Hey
I really love this automation, but I have a question.
Is it possible to set a condition not as “not-home” but as everything else except “home”?
In the future I would like to use zones and I still want my vacuum to trigger when I’m at college and not just when I’m “not_home”.
Any Ideas how to implement that? It’s probably super easy with jinja, but ll my attempts failed
@Lennard Glad you like it. Sure that’s possible by using a template sensor and a little bit of jinja magic
Example: a template binary_sensor indicating when no one is at home:
template:
- binary_sensor:
- name: "None at Home"
state: "{{ not is_state('group.awesome_people', 'home') }}"
Hint: in my case the group.awesome_people
is a group of person entites / device_trackers
Show more
awesome_people:
name: Awesome People
entities:
- person.pavax
- person.guest
- person.some_one_else
Example a template binary_sensor sensor indicating when pavax is in the Zone 'Work’
template:
- binary_sensor:
- name: "Pavax at Work"
state: "{{ is_state('person.pavax', 'Work') }}"
… after that reload the template entities (press c
on your keyboard and type reload template entities
) or restart HA. Now you should have a nwe binary sensor: E.g. binary_sensor.none_at_home
that you can use in the blueprint as a condition entity and set the condition state to on
Hi @pavax,
I try to learn with your examples (many thanks!) and I think this last template show “Awesome at Wotk” not “Pavax at work”, is it correct?
Thank you,
thx @anarro for your feedback! you are right that was a copy and paste mistake. I edited the second example in my post to match the showcase of Pavax at Work
Hi all,
one question, how i can use available “last run input date time” insteat of input_datetime ?
I ask because my vacuum starts when no one is home + but also when my wife says please start.
I would like our vacuum to be activated only once, regardless of whether it is activated manually or when no one is at home.
Hi @Pavax,
Is it possible to add a notification (app) option when the vacuum has finished the cleanup?
Something like: Notification if Door or Window is left open