From 5b249a4139965f2d04a04cb4ed117309ebe648a1 Mon Sep 17 00:00:00 2001 From: Jason <37859597+zachowj@users.noreply.github.com> Date: Fri, 16 Aug 2024 02:52:13 -0700 Subject: [PATCH] docs: Update first automation to use action node --- docs/guide/first-automation.md | 57 +++++++++------------- docs/guide/images/first-automation_02.png | Bin 11537 -> 9280 bytes docs/guide/images/first-automation_04.png | Bin 3744 -> 5196 bytes docs/guide/mustache-templates.md | 25 +++++----- 4 files changed, 34 insertions(+), 48 deletions(-) diff --git a/docs/guide/first-automation.md b/docs/guide/first-automation.md index 9070ae79cb..8b43977b12 100644 --- a/docs/guide/first-automation.md +++ b/docs/guide/first-automation.md @@ -1,67 +1,56 @@ # First Automation -For your first automation, we'll start simple and set up an automation to turn on and off a -light when the sun comes up and goes down. +For your first automation, let's keep it simple by setting up a light to turn on when the sun sets and off when it rises. -This example will use the state, `below_horizon`/`above_horizon`, of the `sun.sun` entity from -Home Assistant to trigger the light. +This example uses the `sun.sun` entity in Home Assistant, which has states `below_horizon` and `above_horizon`, to trigger the light. -## Events: state +## Events: State Node -Place an Events: state node onto the workspace and double click on it to edit. +1. Drag an **Events: state** node onto the workspace and double-click it to edit. ![screenshot](./images/first-automation_01.png) -## Entity ID +## Entity ID Configuration -We'll add `sun.sun` to the **Entity ID** field and leave the entity id filter type -to `Exact` as we only want to match one entity. +2. In the **Entity ID** field, enter `sun.sun`. This is the entity that will trigger the automation. -## If State +## If State Condition -**If State** is a conditional that will be checked against the state of the entity -when it triggers the node. If the condition is found to be `true` the message -will be sent out the top output and if found to be `false` it will be sent out -the bottom output. If no conditional value is set there will only be one output -and all messages will flow through it. +3. The **If State** condition checks the entity's state when the node is triggered. If the condition is `true`, the message will be sent through the top output; if `false`, it will be sent through the bottom output. If no condition is set, all messages will pass through a single output. -For this example we will set the **If State** to `above_horizon`. + For this example, set the **If State** to `above_horizon`. ![screenshot](./images/first-automation_02.png) -## Call Service +## Action Node -Now that the trigger is set up it's time to set up the action. Most communication -done with Home Assistant will come in the forms of services calls using the Call -Service Node. +4. Now, let's set up the actions that will be triggered. Most Home Assistant interactions are done through action calls, which we'll handle with the **Action** node. -Drag two Call Service nodes onto the workspace and connect them to each of the -outputs from the Events: state node. +5. Drag two **Action** nodes onto the workspace and connect them to the outputs of the **Events: state** node. ![screenshot](./images/first-automation_03.png) -Since we made the conditional in the Events: state node _if state is equal to -above_horizon_ the top output will be the action to turn off the light and the bottom output will be the action to turn on the light. +- Since we set the **If State** to `above_horizon`, the top output will turn off the light, and the bottom output will turn it on. -The three fields that are relevant for this example are: Domain, Service, and -Entity Id. **Domain** is going to be `light`, **Service** is going to be -`turn_off`, and **Entity Id** is going to be `light.front_porch`. The Second -Call Service node will be the same except the **Service** is going to be `turn_on`. +6. Configure the **Action** nodes: + - **Action**: `light.turn_off` (for the top output) and `light.turn_on` (for the bottom output) + - **Entity**: `light.front_porch` ![screenshot](./images/first-automation_04.png) ## Complete Automation -At this point, you can deploy and should have your first working automation in -Node-RED. +7. Once you've configured everything, deploy your flow. You now have your first working automation in Node-RED! ![screenshot](./images/first-automation_05.png) @[code](@examples/guides/first-automation/complete-automation.json) -**Also see:** +--- + +**Related Resources:** - [Importing and Exporting Flows](https://nodered.org/docs/user-guide/editor/workspace/import-export) -- [Call Service Node](/node/call-service.md) -- [Events: state Node](/node/events-state.md) -- [Conditionals](./conditionals.md) +- [Call Service Node Documentation](/node/call-service.md) +- [Events: State Node Documentation](/node/events-state.md) +- [Conditionals in Node-RED](./conditionals.md) diff --git a/docs/guide/images/first-automation_02.png b/docs/guide/images/first-automation_02.png index 88189148d6665eb00e97bf444ec49b89375854c4..8e5f1542ce6e67ea190d758371e6c952e09db293 100644 GIT binary patch literal 9280 zcmd6Nc~Dc?wtk>R1zJ#%K@m~AMQLPe1zJXjMr{UBW(b2JDnk-LLjZw*14AnU+M=R> zG$>O-284vk1R8{>C;=gZ34=&OAP@pV0!c`C2m9W4@4NM0)vbE<>i7F21?QZ-_gZJ~ zwZ8A$YoA+Z&z#z%wnGgB0&V)`^v|9kkP;X8X>ME(+)-mhZvy@(Aw5qW2jP2mP5~F| z!jHKh1A%Ju)K?%Xz_n`Z=>Q}Mq|veVQ=-LGT>yc;WBl^-G4I3>!H}G=%UQlUFB}
$Uk
zaozoqzC;QV_9s-<*&vIDVBx$Z$KQTQ2 ZQfLSp-g
zBBHf@B5sp|lmB=Y)&kDI<+@e65Qb)$w@N~%E^Ej`YSiGS1+eo3p^!3vIAtB9zFQPE
zHLa0&D<7uC(7vT@R$)?F;zJ?l(2uK?`6~C@3UfE5yqp|qR^n|Ert`-Mqo}R2EY_&G
z+KHGDn%z`s%7hqQgf$pqyJn9P(Qf}il{^^0RyGXK>~@|md<0+GUjOm-;-K%yxlOli
zQOt6Pz~I~>L)>NI_@`|VMXVws7^KyJlpDF3NmY>V=UV$SMOc~ZPY>;ntS>rGEwue}M92DU#r$=0b#zoq()5v1%k@qx9KdHAa{*g1B}CU+
z-6^GK*{>PUM$12En`0Jubk@ZHz_^_n_nQqG-YxM0jv0rx*lbi0f{h(zQTfO#E6elE
z9w&w)YI(crl9y(s(i7XIDX&>SD8KV6kSms23DGSAGQV|IE-WLL_$-R%X@&&x%tx5327E0q^p&2B=vjjs4Bb4CP0WS~JU44j;
zm*2k0O}zwDzvI%F7!|wn89LCj-i!>IvWy=rfqq=TeW#yiw1ZZ$7c#elF*O)J7+M(_
zx-Z^rwK=1m$b|9feQ{?Z?Tq4w@$tb(