From ed3d0e8a11bd71fe9c5646835e2b7afcf00c58cb Mon Sep 17 00:00:00 2001 From: Christoph Weitkamp Date: Wed, 19 Dec 2018 07:43:25 +0100 Subject: [PATCH] Added description of 'receivedEvent' variable for channel-based triggers (#830) - Added description of 'receivedEvent' variable for channel-based triggers Signed-off-by: Christoph Weitkamp --- configuration/rules-dsl.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/configuration/rules-dsl.md b/configuration/rules-dsl.md index ff08c0ae4..4d1061835 100644 --- a/configuration/rules-dsl.md +++ b/configuration/rules-dsl.md @@ -244,6 +244,7 @@ Channel "" triggered [] When a binding provides such channels, you can find the needed information in the corresponding binding documentation. There is no generic list of possible values for `triggerEvent`, The `triggerEvent`(s) available depend upon the specific implementation details of the binding. +If the Rule needs to know what the received event was, use the [implicit variable]({{base}}/configuration/rules-dsl.html#implicit-variables-inside-the-execution-block) `receivedEvent` to acces the information. Example: @@ -680,6 +681,7 @@ Besides the implicitly available variables for items and commands/states, rules - `receivedCommand` - will be implicitly available in every rule that has at least one command event trigger. - `previousState` - will be implicitly available in every rule that has at least one status change event trigger. - `triggeringItem` - will be implicitly available in every rule that has at least one command, status update, or status change event trigger. +- `receivedEvent` - will be implicitly available in every rule that has a channel-based trigger. {: #return} ### Early returns @@ -840,6 +842,17 @@ then if(receivedCommand == ON) Light.sendCommand(ON) else Light.sendCommand(OFF) end + +rule "Start wake up light on sunrise" +when + Channel "astro:sun:home:rise#event" triggered +then + switch(receivedEvent.getEvent()) { + case "START": { + Light.sendCommand(ON) + } + } +end ``` ## Further Examples