Hey, maybe I’m just crazy, but I’ve been having issues with multiple lights that may be turned on/off at exactly the same time not re-triggering this blueprint.
See error below from Trace Timeline:
Stopped because only a single execution is allowed at July 19, 2021, 10:06:20 PM (runtime: 0.00 seconds)
I looked really hard, but couldn’t find any documentation regarding how HA handles automation modes within blueprints.
On this page of the documentation, an automation mode appears to be written into the blueprint YAML, so I tried adding one to this blueprint in the same manner to see if it would solve my problem of the blueprint only allowing a single run at a time and ignoring concurrent re-triggers.
Here is how I added it in (right before triggers):
Interesting, I haven’t thought about that as a use case scenario. Most of my lights are just user controlled by my family so pretty low probability of that ocurring. If someone can confirm this is the appropriate solution I’m happy to add this into the parent post!
Ok, I have finally found in the documentation what I feel confident is confirmation that this is the appropriate way to add modes into an automation.
In the Blueprint Schema documentation, it says, “. . . in the case of creating a blueprint for an automation, the full schema for an automation applies.”
Thanks @davearneson ! I’ve added it to the original post
@Eldudemeister this was covered above. in short, HA looks for the first code block to import. this won’t work for this post (and other posts as well) so you’ll need to manually create the blueprint. The other configurations for the replay sensors and recorder would need to be manually coded into your configuration as well.
Great Idea!
I also tried to play with it once on one specific light but did not move further to generalizing through blueprints.
Thanks for this Blueprint that makes it easier to maintain
One thing I am thinking of a way to make it even more simple not needing specify which lights to apply to and have to make an automation for each 10 lights.
But this will require the ability to loop/iterate through all light entities. Is that possible at all?
If possible, then no risk on looping through all lights and will only work on those where recording is enabled/configured. But not necessarily all switches may be includes. Therefor we will need to indicate which ones to apply to and can do that adding the entity names to some kind of a list.
If this is possible the only thing users need to do:
Enable recording for entities
Add selected switches on a list
Then In fact, there will be no need for a blue print but one generic Automation that handles the whole work without hardcoding any entity names.
What do you think?
Any body have experience with looping on a set of entities?
It’s a good idea, but I’m not sure of there’s a straight forward way to interact with the home assistant database directly from an automation without the use of more sensors. Would love to see others implementation of the idea if possible!
You can change the statistical sensor specifying another amount of time to go back and match.as in the following example :
##########
# Sensors
##########
sensor:
# Replay Sensor - Make a new one for each light to monitor
# All sensors will have naming convention "sensor.replay_xxxxx"
- platform: history_stats
name: "replay_office_lamp"
entity_id: light.office_lamp
state: "on"
type: count
start: >
{{ as_timestamp(now()) - (7*24*60*60) }}
duration: 00:00:30
The figures 7*24*60*60 means 60 second x 60 minutes x 24 hours x 7 days
You can change it to be 3 hours like this 3*60*60 or 2 days like this 2*24*60*60 and so on,
Hope this makes sense otherwise let me know and I’ll try to explain further.
I’d like to control more than 10 devices. Twelve is what I have in mind. Is controlling such a number possible simply by adding code to the Blueprint to include;
Is this the correct approach or is there another way to add two additional device?
Update: problem solved. I added the code and sensors mentioned above, which resulted in exactly what I wanted. The updated blueprint works wonderfully.
I am unable to import this blueprint, and instead get the error message: No valid blueprint found in the topic. Blueprint syntax blocks need to be marked as YAML or no syntax.
Why did adding blueprints from the forum stop working? Do they now need to be on GitHub? Quite unhandy to manually add a blueprint using the smartphone… this is not working as intended, right?
The error message I got suggests a problem with this particular page, and how the yaml file is named. I just tried another blueprint, and it imported fine.
This is exactly what I’ve been looking for. I just have a few questions:
do I have to set the entity record time manually to 7 days in my config.yaml?
once I’ve completed the all the steps, should I see an automation called Vacation Mode in on the automation page. currently I can see the code added to automation.yaml, but nothing new is showing up on the automations page.
its a bit difficult to work out if this automation is actually running and working.