I am currently in the process of cleaning up and optimizing my automations.
Since I have taken a lot from the forum and I’m not exactly the professional for templates, I try to solve existing templates with the on-board means of Home Assistant or rearrange.
For this I need help to understand but times, just what the waiting templates I once found.
Is this the same
- wait_for_trigger:
- platform: state
entity_id:
- vacuum.roborock_s7
attribute: battery_level
to: "100"
And is it possible to change such a template with HA conditions?
trigger:
- platform: state
entity_id:
- sensor.roborock_s7_total_clean_area
condition:
- condition: template
value_template: >-
{{ trigger.from_state is not none and trigger.to_state is not none and
trigger.from_state.state not in ["unavailable"] and trigger.to_state.state
| float(0) > trigger.from_state.state | float(0) }}
Work with translator, so apologies if not everything is correct.
Following your example, the key difference is what happens when the battery level is at 100 when the wait action starts.
With a Wait for Template, if the battery level is at 100% when the the automation gets to this action, the wait will complete and the automation will continue…
With a Wait for Trigger if the battery level is at 100%, the wait for trigger will not allow the automation to continue until the battery level changes to some other value then back to 100.
If the battery level is not 100 when the wait action starts, they will both act exactly the same and will wait until the value changes to 100.
Are you asking if a Wait template can be replaced by a Condition? If that is your question, the answer is “no”. They are not the same. Conditions are checked immediately they do not wait. If they are not true in that instant, the automation stops.
Thank you for your reply. I suspected the difference between wait templates and wait triggers. I’ll just test if it works.
To my second question.
This is not a wait template but conditions or do I see it wrong? I wanted to know if you can solve this in HA with conditions, not as now with a value template.
You can reduce the templating required by changing the trigger, but there is no way to perform a mathematical comparison of the “to state” and “from state” without a template.
The desire to organize my automation arose because I simply despaired of a waiting template that I wanted to create, I couldn’t get it to work.
We have a PV system and I have tried to control our dishwasher so that it only starts with the program start when we have a surplus of PV power of 1500 watts.