TP Flow - Futurehome rules engine

  • Oppdatert

This guide will show you the basics of the Futurehome developer rules engine.

In order to use TP flow you need to install Thingsplex and TPFlow from the Futurehome app store. Follow this guide to set it up.

Warning: The rules engine is a very powerful tool. You should use it with care as it can potentially stall your system if used wrongly with loops or similar.

mceclip0.png

 

In the example below we will create an example flow which uses Z-Wave scenes to trigger a shortcut.

Create a new flow

mceclip1.png

Input a suitable name and description. If you want the flow to be a part of a special group of flows then add a suitable name for the category or use an existing group name.

mceclip2.png

In the image above you can see the start of a new flow. There is an empty trigger flow card present, click on it to edit it.

mceclip3.png

Select the room the device is placed in, select the device and then select the scene_ctrl service and the evt.scene.report .

The device we are using as an example is a Heatit Push button 2. It has two scenes, Scene 1 for button 1 and Scene 2 for button 2. We want to create 1 flow which can do something based on both buttons.

Next step is to create an IF statement.
Ideaboard_-_2019-10-08T104351.415.jpg

Edit the IF statement by clicking on it.

mceclip4.png

Input a suitable name, select string as the datatype and input "1.0" for scene 1.

Ideaboard_-_2019-10-08T104813.805.jpg

If you are unsure about the device and the format of the scene number then you can trigger the scene by pressing on the button physically. Then check the Thingsplex Message stream and you can see the format of the message.Ideaboard_-_2019-10-08T105158.754.jpg

The reason we cloned the first Scene IF statement was because we want to set up what the second button should do as well. On the second button we change the label name and input scene 2.0 which is for button 2.

mceclip6.png

Then join the flows together by joining the Green dot which is the output on to the Blue dot which is the input on the IF statement flow. Also join a line from the Yellow dot on the IF statement. This is the flow route it should take if the IF statement is not met, join it with the input of the next IF statement which is Scene 2.0.

mceclip7.png

 

In the next step we will be creating the action of what should actually happen based on the Scene type sent. In the example we will have Scene 1 trigger a shortcut and we will have Scene 2 set a mode.

First we will add the first action which is a "modes & shortcut action.

Ideaboard_-_2019-10-08T110223.309.jpg

We select the Action, input a name, select shortcut and then select the shortcut we would like to run when Scene 1.0 is sent. Lastly we will will duplicate the action to set up the action for Scene 2.0

Ideaboard_-_2019-10-08T110626.645.jpg

For the action for scene 2.0 we want to set sleep mode. Select the action to trigger mode, set a name for the label and then close.

Ideaboard_-_2019-10-08T111154.343.jpg

Lastly we will need to join the flows from the IF statement to the Actions

Ideaboard_-_2019-10-08T111612.325.jpg

That is it, now we have a flow which will either trigger a shortcut or a set a mode depending on which Scene is triggered on a Heatit Push button wireless remote.

Ideaboard_-_2019-10-08T111804.303.jpg

In the Flow overview we can now see the flow we created and some details about it.

mceclip8.png

We can see it has been Executed 0 times, now let´s try to push the button.

mceclip9.png

As we can see after pressing hte button the flow has been executed 1 times.

Here is the flow we made as a flow you can import in your Thingsplex Flow editor import function.

{
"Id": "NuCRKTdH7y4aX6x",
"ClassId": "NuCRKTdH7y4aX6x",
"Author": "",
"Version": 0,
"CreatedAt": "2019-10-08T10:15:52.465761518+02:00",
"UpdatedAt": "2019-10-08T10:15:52.465761518+02:00",
"Name": "Shortcut button",
"Group": "",
"Description": "Shortcut - scene trigger",
"Nodes": [
{
"Id": "1",
"Type": "trigger",
"Label": "Heatit push button scene",
"SuccessTransition": "2",
"TimeoutTransition": "",
"ErrorTransition": "",
"Address": "pt:j1/mt:evt/rt:dev/rn:zw/ad:1/sv:scene_ctrl/ad:155_0",
"Service": "scene_ctrl",
"ServiceInterface": "evt.scene.report",
"Config": {
"InputVariableType": "",
"IsValueFilterEnabled": false,
"LookupServiceNameAndLocation": false,
"RegisterAsVirtualService": false,
"Timeout": 0,
"ValueFilter": {
"Value": null,
"ValueType": "string"
},
"ValueJPath": "",
"ValueJPathResultType": "",
"VirtualServiceGroup": "",
"VirtualServiceProps": null
},
"Ui": {
"nodeType": "",
"x": 70,
"y": 170
}
},
{
"Id": "2",
"Type": "if",
"Label": "Scene 1.0",
"SuccessTransition": "",
"TimeoutTransition": "",
"ErrorTransition": "",
"Address": "",
"Service": "",
"ServiceInterface": "",
"Config": {
"Expression": [
{
"BooleanOperator": "",
"LeftVariableIsGlobal": false,
"LeftVariableName": "",
"Operand": "eq",
"RightVariable": {
"Value": "1.0",
"ValueType": "string"
}
}
],
"FalseTransition": "3",
"TrueTransition": "4"
},
"Ui": {
"nodeType": "",
"x": 48,
"y": 343
}
},
{
"Id": "3",
"Type": "if",
"Label": "Scene 2.0",
"SuccessTransition": "",
"TimeoutTransition": "",
"ErrorTransition": "",
"Address": "",
"Service": "",
"ServiceInterface": "",
"Config": {
"Expression": [
{
"BooleanOperator": "",
"LeftVariableIsGlobal": false,
"LeftVariableName": "",
"Operand": "eq",
"RightVariable": {
"Value": "2.0",
"ValueType": "string"
}
}
],
"FalseTransition": "",
"TrueTransition": "5"
},
"Ui": {
"nodeType": "",
"x": 259,
"y": 341
}
},
{
"Id": "4",
"Type": "action",
"Label": "Trigger kveldskos",
"SuccessTransition": "",
"TimeoutTransition": "",
"ErrorTransition": "",
"Address": "pt:j1/mt:cmd/rt:app/rn:vinculum/ad:1",
"Service": "vinculum",
"ServiceInterface": "cmd.pd7.request",
"Config": {
"DefaultValue": {
"Value": {
"cmd": "set",
"component": "shortcut",
"id": 5,
"param": {},
"requestId": 1
},
"ValueType": "object"
},
"IsVariableGlobal": false,
"Props": {},
"RegisterAsVirtualService": false,
"ResponseToTopic": "pt:j1/mt:rsp/rt:app/rn:tpflow/ad:1",
"VariableName": "",
"VirtualServiceGroup": "",
"VirtualServiceProps": {}
},
"Ui": {
"nodeType": "vinc_action",
"x": 99,
"y": 533
}
},
{
"Id": "5",
"Type": "action",
"Label": "Set sleep mode",
"SuccessTransition": "",
"TimeoutTransition": "",
"ErrorTransition": "",
"Address": "pt:j1/mt:cmd/rt:app/rn:vinculum/ad:1",
"Service": "vinculum",
"ServiceInterface": "cmd.pd7.request",
"Config": {
"DefaultValue": {
"Value": {
"cmd": "set",
"component": "mode",
"id": "sleep",
"param": {},
"requestId": 1
},
"ValueType": "object"
},
"IsVariableGlobal": false,
"Props": {},
"RegisterAsVirtualService": false,
"ResponseToTopic": "pt:j1/mt:rsp/rt:app/rn:tpflow/ad:1",
"VariableName": "",
"VirtualServiceGroup": "",
"VirtualServiceProps": {}
},
"Ui": {
"nodeType": "vinc_action",
"x": 329,
"y": 533
}
}
]
}


To import it just do the following:

Ideaboard_-_2019-10-08T112906.921.jpg

The Thingsplex flow engine is a powerful rules engine with many many possibilities. The documentation will continue to evolve by time, in the meantime we encourage all developers and tinkerers to start playing around and get to know more about the Flow engine.

 

Var denne artikkelen nyttig?

3 av 4 syntes dette var nyttig

Har du flere spørsmål? Send oss en henvendelse

Kommentarer

0 kommentarer

Logg på hvis du vil legge inn en kommentar.