This blueprint will automatically reload Automations when there is a change in the blueprints folder. This can be useful if you are creating Blueprints, since automations needs to be reloaded after every modification in the blueprint file.
Add the path of your blueprints folder to the configuration.yaml:
folder_watcher: - folder: /config/blueprints
Add it to the allowlist: homeassistant: allowlist_external_dirs: - "/config/blueprints"
Restart Home Assistant.
Blueprint
Click the badge to import this Blueprint: (needs Home Assistant Core 2021.3 or higher)
Or you can import this Blueprint by using the forum topic URL:
blueprint:
name: Reload automations on file change
description: >
When you modify a blueprint, automations need to be reloaded to pick up the latest changes.
This blueprint automates the reloading when your file changes.
It is required to setup the folder_watcher integration with /config/blueprints directory for this to work.
https://www.home-assistant.io/integrations/folder_watcher/
domain: automation
trigger:
- platform: event
event_type: 'folder_watcher'
condition:
- condition: template
value_template: "{{ 'blueprints' in trigger.event.data.folder }}"
action:
- service: automation.reload
Notes:
If you create an automation from this blueprint, and there is no Save button, try changing the name of the automation and the Save button will appear.
Have you considered adding a homeassistant.check_config call before going to automation.reload? If you have a typo while you’re making config adjustments it looks like you get an error that “the following integrations could not be set up: automation”. I’m not sure if that breaks something or just fails to reload.
Instead you could do a homeassistant.check_config call and then proceed to the automation.reload only if persistent_notification.homeassistant_check_config did not exist (since that notification gets created if the config check fails). This seems like it would be nicer since then the logs would tell you exactly what was wrong with your config instead of just telling you that automations couldn’t be loaded.
That’s a clever idea! Thanks for sharing.
My problem is that I frequently press save, and the homeassistant.check_config can take a lot of time.
But I realized that this Blueprint has a bug, I should change the Run Mode from the default single to something else, like restart.