I have a number of automations I want to have re-trigger a second time. Is there any way to have multiple “for” trigger lines?
For example (psudocode) I have this setup, I would like to not just trigger at 12 hours but maybe like a couple times over at 12, 24, 72 hours in case I was busy and missed it…but not over and over on an interval because if I’m not home I don’t want excessive notifications?
This particular automation is nearly 100 entities when you get done with the several different ways they could trigger (some state=on, some state=off, a couple different numeric thresholds) so “just duplicate it with multiple for lines” is a rather poor solution, and I really want to use the entity name as the thing I get sent so I don’t have to code 100 separate messages.
Yeah, I was just really hoping to avoid that. Its not bad if its a few lines but when you have 4-6 different triggers with a dozen or more different entities in them and now have to keep track of ALL those (and if you replace/change one, updating all of them) gets to be kinda overwhelming.
So your problem appears that you do not want to list all the entities multiple times?
If that is the case, I would test if you could put the list of entities into a list under trigger_variables:
once, then refer to the list variable under - entity_id:
I am not certain that it would work but I think it would, and is worth trying.
Interesting…I don’t quite understand how that selects what things it will notify on and how to pick which type or threshold?
I have (due to different vendor implementations) some things that fail quickly around 30%, others still work for days after hitting 0%, and some that just have a binary sensor. The binary sensor ones, some have “Battery OK” binary sensor, others have “Battery LOW” binary sensor so I have to account for if on or off is “low”.
I only took a handful of the things in my automation to keep the post short but I also have triggers for other stuff like sensor age (stopped updating), propane gauge capacity (in both pounds and estimated days remaining), water pressure loss, etc. Basically one automation that sends me “you need to check ”
It looks like handles level and binary battery entities. For the entities that report a level you can set the threshold to alert at, but it doesn’t appear to handle per-device thresholds.
{% for state in states.sensor | selectattr('attributes.device_class', '==', 'battery') %}
{% if 0 <= state.state | int(-1) < threshold | int and not state.entity_id in exclude.entity_id %}
{% set result.sensors = result.sensors + [state.name ~ ' (' ~ state.state ~ ' %)'] %}
{% endif %}
{% endfor %}
{% for state in states.binary_sensor | selectattr('attributes.device_class', '==', 'battery') | selectattr('state', '==', 'on') %}
{% if not state.entity_id in exclude.entity_id %}
{% set result.sensors = result.sensors + [state.name] %}
{% endif %}
{% endfor %}
As you need reporting for other devices in the same automation it wont be suitable anyway