I have a number of (similar) automations that will trigger if a certain energy level is detected, the difference between these automations is mainly the detected energy level and the smartplugs that will be activated.
I would like to add a condition that avoids an automation from running if another automation (from lets say a list of 9 automations) has been triggered within the last 30 seconds. I tried to create a helper with a 30 second timer that activates once the automations runs and added the condition to the automation but I didn’t manage to get this to work.
This sounds like a situation where the 9 similar automations can be consolidated into a single automation. That would eliminate the need to create a condition that checks if some other automation was triggered.
To determine if it’s feasible, post all or some of the other automations.
NOTE
It’s preferable to use State Triggers, State Conditions, and standard actions instead of the Device Triggers/Conditions/Actions in your example. The resulting YAML is not only more concise, it provides more flexibility (especially if the goal is to consolidate multiple automations).
Thanks for your help. I am eager to learn how to do this the right way. Below some additional explanation to the automations.
The triggers are all very similar (min and max sensor power). The power is related to power availability at a given moment.
The conditions:
first condition (is_power) will check if measured remaining power availability is above 0
second condition (numeric_state) is checking if boiler charge status is above or below 95% => I have some extra duplicate automations base on both above and below 95… so this could be simplified also I hope?
The actions are enabling a combination of smartplugs, which are always the same list but enable/disabled in different combinations.
Here is a single automation that combines your four automations.
It has four Numeric State Triggers, each one monitors the same power sensor (sensor.your_power_sensor_1) but with unique thresholds.
Each Numeric State Trigger has a unique identifier (id). It will be used by the choose in the actions section.
There are two Numeric State Conditions, one monitors a power sensor (sensor.your_power_sensor_2) and the other an Input Number (input_number.boiler).
The actions section contains a choose that uses the trigger’s id to determine which actions it should perform.
The actions consist of turning on/off five switches. Which switches are turned off, and which are turned on, is governed by which Numeric State Trigger fired.
Your examples use Device Triggers/Conditions/Actions which identify entities using a long alphanumeric string (entity_id: 26fda7c22bea942358af1e19942fbd5a).
The example I posted uses traditional State Triggers/Conditions and actions which identify entities using a human-readable string (entity_id: switch.foo).
You will need to replace all of the fictitious entity_ids in my example (sensor.your_power_sensor_1) with the actual, human-readable entity_ids that are used in your system.
Here is a more sophisticated, but far more concise, way to do the same thing. It does not require a choose statement.
Each trigger contains two trigger_variables, sw_off and sw_on, that list which switches should be turned off/on. The two actions use the trigger_variables to determine which switches to turn off/on.
Thank you very much, I will in first instance rework my automations and come back with a new version. If you could then advice me on how to integrate the 30 second ‘inactivity’ before possibly retriggering the automation, I would be very gratefull.
I suggest you consider using the Numeric State Trigger’s for option.
In the following example, the trigger will fire when the sensor’s value increases above 900 and remains above 900 for at least 30 seconds. In other words, it doesn’t fire instantly when the value crosses the threshold of 900. It fires when the value has crossed the threshold and remained above it for at least 30 seconds. This prevents triggering if the value rises above the threshold but then quickly falls below it.