This user has been inactive for some time, the blueprint below is still available, but please be advised it may no longer work.
Original Post
This blueprint is part of the Awesome HA Blueprints project.
Read more about it on the related Community Forum topic.
Updates will be published on the projectās GitHub repository.
Get Started
Option 1: My Home Assistant
Click the badge to import this Blueprint (needs Home Assistant Core 2021.3 or higher)
Option 2: Direct Link
Copy this link if you want to import the blueprint in your installation.
Description
This blueprint provides a simple on-off schedule, with the addition of state persistence across server reboots, powercuts, or other disruptive events which could potentially alter the expected state of the targeted entities. The automation makes sure the target is always in the expected state, even in these situations, but always leaving the freedom to manually toggle the target state as desired. It can be used on critical targets which require a simple on-off schedule during every single day.
One common scenario where this could be useful is in the case of a server reboot or shutdown. For example, letās assume youāve an automation A set to turn on light L at 12:00. If for whatever reason Home Assistant goes offline at 11:59 and turns back on at 12:01, automation A scheduled for 12:00 is not executed, with the result of L not being in the state youād expect to be, after 12:00.
Using this blueprint in the above example would have guaranteed the expected behaviour, with the automation A being run at Home Assistant startup, and setting the L state as described by the schedule.
Examples of disruptive scenarios could include server reboots, network outages or powercuts. Since every installation could be influenced by many different events and check for them in many different ways, the blueprints includes the flexibility to optionally supply a custom event type which the automation will listen to. When such event is fired, the automation is run.
The blueprint already implements the support for listening to Home Assistant startup events, but this functionality can be disabled as desired by the user.
Internally, the blueprint calculates time ranges based on the provided On-Off times, bound to the target expected state. Whenever one of the specified times is reached or a disruptive event occurs, the automation retrieves the expected state from the calculated ranges, and enforces it on the target.
Full Documentation
Full documentation regarding requirements, inputs and more is available here.
Docs provide all the information you need to properly configure this blueprint on your instance.
Changelog
Updated list of changes and improvements is available here.
Happy automating to everyone!