The script checks if there is moisture.
If there is no moisture it waits until my robot vacuum gots a certain amount of battery.
To ensure that there is no moisture while loading I did insert the condition to check again.
This random condition is in there, and you gave 2 ifâs at the same level, I really cannot tell. Maybe someone else wants to take a shot. If you had this built as a choose I would probably be able to tell. As it stands, I would be surprised if this passes YAML config test. Did you perhaps run this thru an AI to help you?
yeah, that conditional right in the middle is a good point from @Sir_Goodenough
if you put a test condition in the sequence like that, the condition will be tested, and if it fails, the sequence will stop.
ie, since this is not wrapped in an âifâ, ⌠then if:
- condition: state
entity_id: binary_sensor.wassersensor_pflanzenbecken_feuchtigkeit
state: "off"
fails (the sensor is not âoffâ) then i believe it stops there and the rest of the code will not get executed.
if you have 2 conditions in an âifâ, then i believe both conditions must be true for the if to be true. (unless you explicitly wrap the two 'ifâs in with an âorâ
hmm
I did a testing script. Therefore I added 3 helper switches:
AACondition, AATasksAfterIFThenExecuted and AATasksWithinIfThenExuted.
Should be obvious what they are doing.
To simulate my robot vacuum script I created following:
Starting the script with all three helpers being false.
Obviously the if then block gets skipped and AATasksAfterIffThenExuted gets true while AATasksWithinIfThenExuted stays false.
Interesting thing here is starting the script with âAAConditionâ being true and setting it to false within the 5 second delay time.
In this case âAATasksAfterIFThenExecutedâ goes true, while âAATasksWithinIfThenExutedâ stays false.
For me this means my robot script should work as expected.
If the moisture sensor is dry it will start the if block.
If neccesarry the script will wait for my robot to recharge the battery and check again if the moisture sensor did get wet in the meantime.
If not (still dry) script resums - if it got wet the then block will get skipped and the script will keep running (so my robot cleans the âdryâ rooms.