From 1d6c309d4dee54671739dfb974161aaf99801ca7 Mon Sep 17 00:00:00 2001 From: cdce8p <30130371+cdce8p@users.noreply.github.com> Date: Sat, 18 Nov 2017 00:11:39 +0100 Subject: [PATCH] * Added "Trigger State Object" section (#3863) --- source/_docs/automation/templating.markdown | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/_docs/automation/templating.markdown b/source/_docs/automation/templating.markdown index a53912dc46c..7f721876bd9 100644 --- a/source/_docs/automation/templating.markdown +++ b/source/_docs/automation/templating.markdown @@ -51,6 +51,14 @@ There are a few very important rules to remember when writing automation templat Remembering these simple rules will help save you from many headaches and endless hours of frustration when using automation templates. +## {% linkable_title Trigger State Object %} + +Knowing how to access the [state object](/docs/configuration/state_object/) of a trigger entity could be one of the more common questions. Here are a few ways for the [`state`](#state), [`numeric_state`](#numeric_state) and [`template`](#template) triggers: + +* `trigger.from_state` will return the **previous** [state object](/docs/configuration/state_object/) of the entity. +* `trigger.to_state` will return the **new** [state object](/docs/configuration/state_object/) that triggered trigger. +* `states[trigger.to_state.domain][trigger.to_state.object_id]` will return the **current** [state object](/docs/configuration/state_object/) of the entity. + ## {% linkable_title Available Trigger Data %} The following tables show the available trigger data per platform.