From 7bea0d9681546f0668bde77bc573aeffa27f4fa8 Mon Sep 17 00:00:00 2001 From: akasma74 Date: Wed, 21 Aug 2019 22:19:47 +0100 Subject: [PATCH] added Testing section (#9767) * added Testing section I saw no such thing in docs and it constantly causes topics like this - https://community.home-assistant.io/t/condition-problems/124222. Hope this addition is useful. * make it more readable * moving Testing section to this better place as discussed here https://github.com/home-assistant/home-assistant.io/pull/9767#issuecomment-511128560 * moving Testing bit to Troubleshooting as discussed here https://github.com/home-assistant/home-assistant.io/pull/9767#issuecomment-511128560 * :pencil2: Tweak * :ambulance: Removing linkable_title --- .../_docs/automation/troubleshooting.markdown | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/source/_docs/automation/troubleshooting.markdown b/source/_docs/automation/troubleshooting.markdown index 9dcc2f662b6..cbd02e978b6 100644 --- a/source/_docs/automation/troubleshooting.markdown +++ b/source/_docs/automation/troubleshooting.markdown @@ -18,3 +18,21 @@ The Logbook integration will show a line entry when an automation is triggered. ![Logbook example](/images/components/automation/logbook.png) [template]: /topics/templating/ + +### Testing your automation + +It is generally a difficult task to test an automation, especially if it includes several triggers and some conditions. + +Please note that if you click on **Trigger** of an automation in the frontend, **only the `action` part will be executed** by Home Assistant. That means you **can't** test your trigger or condition part that way. It also means that if your automation uses some data from triggers, it won't work properly as well just because `trigger` is not defined in this scenario. + +All this makes that Trigger feature pretty limited and nearly useless for debugging purposes so you need to find another way. +Make sure you check and adapt to your circumstances appropriate examples from Automation Trigger, Conditions and Actions. + +It is also useful to go to **Configuration** -> **Server Control** and click on **Check Config** button in Configuration validation section to make sure there are no syntax errors before restarting Home Assistant. + +If your automation uses templates in any part, you can do the following to make sure it works as expected: + +1. Go to **Developer tools** -> **Template** tab. +2. Create all variables (sources) required for your template as described at the end of [this](https://www.home-assistant.io/docs/configuration/templating/#processing-incoming-data) paragraph. +3. Copy your template code and paste it in Template editor straight after your variables. +4. If necessary, change your sources' value and check if the template works as you want and does not generate any errors.