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.
In the example below we will create an example flow which uses Z-Wave scenes to trigger a shortcut.
Create a new flow
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.
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.
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.
Edit the IF statement by clicking on it.
Input a suitable name, select string as the datatype and input "1.0" for scene 1.
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.
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.
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.
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.
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
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.
Lastly we will need to join the flows from the IF statement to the Actions
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.
In the Flow overview we can now see the flow we created and some details about it.
We can see it has been Executed 0 times, now let´s try to push the button.
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:
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.
Kommentarer
0 kommentarer
Logg på hvis du vil legge inn en kommentar.