I know we have Developer Tools in HA that offer a lot of stuff however I wonder if there is a way to “test” (at least the syntax) successfully an Automation? Right now I am not sure that the following condition would work:
When you create or edit an automation in the UI you don’t need to restart HA for the changes to take effect. The automation will automatically reload and become active when it gets saved.
you can test the automation by going to the dev tools->services page and select automation.trigger in the drop down. then select the automation you want to trigger.
if you want to actually test the conditions then turn off the “skip conditions” switch in the UI. otherwise just the actions will run.
the condition as you have it won’t work because you are using the wrong type of bracket notation.
the {% type of brackets denote a process portion of the template (calculation, comparison, etc). The {{ brackets denote the actual returned value of the template
Lastly please don’t post screenshots of code. post actual text and use ``` to make sure it’s properly formatted.
it allows us to just copy/paste text instead of needing to write the whole thing out again (like I had to do above to correct your error). And we can see errors in syntax if it’s properly formatted.
You may want to add that automation.trigger never tests the automation’s triggers. Plus it cannot be used for testing if the automation employs the trigger (or this) variables.
When you use the Automation Editor, it checks the automation’s syntax the moment you click the Save button.
What the Save button won’t report are logic errors (i.e. the automation’s operation fails to meet your requirements; it doesn’t behave as expected). To properly test an automation, you should trigger it via its triggers. To expedite an entity’s state-change, you can force an entity’s state to a desired value in Developer Tools > States.
I must say thanks to all of you. Learned something new today! The way I was testing automation was by turning on devices and setting the values as they should for the automation to work properly.
I went to Developer Tools > State and set the temperature to 70 and triggered the automation from Developer Tools > Services and no matter what I get a green checkmark. Should I get something different there?
The check mark just means that the service call to trigger the automation was successful.
it has nothing to do with saying that the actions actually ran or ran correctly. that’s up to you to decide.
and just because you set the state to 70 doesn’t mean it actually stayed at 70 during the test. those states will get updated to the actual values at the next update cycle, which could be just a few seconds.
That is actually the best way to test them because you then know for sure that the trigger and everything else works.