I’m trying to create an automation which turns off my lights in the bathroom after 5 minutes if there hasn’t been any motion and the humidity is below 55 %. Right now it doesn’t turn off the lights and I suspect it is because the humidity isn’t below 55 after the 5 minutes.
Thanks for coming here and asking a question.
Would you be so kind as to adjusting the format of your code so that we can read it properly & check the YAML spacing, etc. Editing your original is the preferred way. It is very hard for us to tell what is what when the text formatter jumbles everything like that.
You can use the </> button like this… How to format your code in forum posts
OR… Here is an example of how to fix it from the site FAQ Page. How to help us help you - or How to ask a good question.
Without delving too deep in hour code: if both humidity and motion need to be in the right state for things to happen, then you need triggers for both motion and humidity changing to a desired state. Then in the conditions, check for both. That way you cover all the situation for which actions need to occur. You now have only half of that, meaning it does not cover all the situations.
For now, a single template trigger will act as both a trigger and condition, because the template only evaluates true when all conditions in it are met.
Do you have automation traces? If you do not have any, the trigger wasn’t there, if you have, you’ll see what condition failed path the automation took. Combining both the start and end automation in one makes the automation complex, and device triggers and conditions are also hard to follow.
You get to see a graph of all parts of the automation. Colors show what got executed and what not. Click on a node to see what happened in that node. If a condition failed you’ll see why. You’ll see why the automation chose a path to perform or skip an action.