Hi,
if there is an action in an automation, which uses the implicit ‘trigger’ variable in some template, testing isn’t that easy. With ‘Execute actions’ from the menue, no trigger is fired and so the object ‘trigger’ isn’t populated, which makes testing meaningless.
My idea:
At the menue of an trigger, there could be a entry like ‘Simulate trigger’. Now the trigger is fired, the ‘trigger’ object is populated and the templates somewhere in the action part of the automation didn’t throw errors.
I am a newbee and maybe there is a way to test such an automation. If so, please let me know.
For state triggers, you can set a test value in the entity in the developer tools. For other triggers, as there are many, I am afraid that wat you ask is hard or impossible to implement. Besides that, if you trigger something that isn’t true, corresponding conditions will fail. For instance, how would you trigger a calendar event without the calendar entry. So it will be hard to impossible to make, and less useful then you’d hope.
I have a trigger checking the battery level. If its too low, send an eMail, but use the name of the device in the message. This can be done with a template.
I raised the level to 90% and hoped that sensors with less than 90% fired their triggers, but nothing happens.
I made a test button and triggered the automation with this button, now I get a mail containing the name of my testbutton. Fine.
How can I test for the correct names of my battery-driven sensors?
Triggers only trigger when they cross the threshold value.
In your case, the battery needs to go from above 90% to below 90%.
Just set the automation value to 1% less than the current device value, then do something that drains the battery on your device if you want to test it properly.
Your trigger will fire as soon as your device sends the next update.
…or set it to above what is in the trigger in developer tools, and after that set it to below. The trigger should then fire.
But had you put a condition in that it should not do anything before sunset, then how would you expect to test it after sunset? You can trigger all you like, but you cannot easily fake that condition. There is no quick fix that lets you test everything, even if you could fake any trigger.
So setting states in the developer tools and pressing the test button on conditions is as good as it gets. The rest is tested IRL, with the help of traces to see what happened.
I gave you the means to do quite a lot: most triggers actually used are based on state. If there are no conditions, just running the actions will go a long way.
If the actions rely on a lot of information about the trigger (excluding the state I already told you how to do) it is way to complicated to fake the trigger with all the data that is in the trigger variables. So what you are asking for is very unlikely to ever happen. It has been asked many times over here. What was possible was made already, the rest is more trouble than it is worth.
Either the automation is simple enough it does not add much to fake a trigger (other than run the automation without a trigger, which you can), or the automation is complicated, which also makes creating the right circumstances to test it difficult.
Just take a look at this page about all data needed to fully populate a trigger. Where should al that data come from if the trigger did not happen? And this is just the tip of the iceberg:
In Developer Tools → States you can change the value of your sensor so that it triggers the automation. This will revert the next time the sensor updates.
Hi tom_I,
tried it, but nothing happens. But today in the morning, I found an eMail sent by HA telling me, that the state of one battery is low … I was just lucky and one sensors battery fell by 1%.
Now I know that it is working, will try to set the sensors value as you told me, will see, whats happen …
Oh my god: With all that playing around, I used the wrong numbers, so my inputs never crossed the thrshold, sorry, works fine.