Input Trigger
Description
Input Trigger is a tool that allows the user to trigger a Zene flow with five (5) different methods MQTT
, HTTP
, Websocket
, Modbus Read
and Trigger Button
. The flow will stop once it reaches the trigger tool and wait for the trigger to be activated. Once the trigger is activated, the flow will continue to execute. All the trigger methods are enabled, and the tool will listen to all the trigger methods.
Image payload
All the trigger methods apart from Trigger Button
and Modbus Read
will allow the user to send an image to the flow. Once the image is received, the flow will continue to execute using the received image. The image must be in base64
format and must not contain any metadata, such as data:image/jpeg;base64,
.
Example of a valid base64
image payload:
2wCEAAkGBxMTEhUTExMWFhUXGBgYGBgYGBgYGBgYGBgYGBgYGBgYHSggGBolHRgXITEhJSkrLi4uGB8zODMsNygtLisBC
Example of an invalid base64
image payload:
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxMTEhUTExMWFhUXGBgYGBgYGBgYGBgYGBgYGBgYGBgYHSggGBolHRgXITEhJSkrLi4uGB8zODMsNygtLisBC
Parent Tools
Settings
Dashboard Button Trigger
See Trigger Button Area for more information on how to use the trigger button.
MQTT Trigger
Topic
See With MQTT subscription for more information on how to subscribe to a MQTT topic for the trigger tool.
Payload
MQTT payload to trigger the tool. There are three (3) fields in the payload:
set_trigger
:
Set totrue
to trigger the tool.id
:
The ID of the trigger tool. This is used to identify which trigger tool to trigger.image_base64
:
The image inbase64
format, see Image payload. This is optional.
Below are two (2) examples of the payload:
For this example, the id
of the trigger tool is 1
and the base64 image is image_base64
.
- Without image
{
"set_trigger": true,
"id": 1
}
- With image
{
"set_trigger": true,
"id": 1,
"image_base64": "image_base64"
}
In Zene UI, the user can copy the payload with the id
field automatically filled in.
HTTP Trigger
URL
This is the Zene HTTP server URL that the user will send a POST
request to trigger the tool.
http://{ZENE_HOST_ADDRESS}:{ZENE_HTTP_PORT}/flow/trigger
ZENE_HOST_ADDRESS
: The IP address of the machine running the Zene Server.ZENE_HTTP_PORT
: The HTTP port of the Zene Server (HTTP Port).
For example, if the user's {ZENE_HOST_ADDRESS}
is 123.456.789.0
and {ZENE_HTTP_PORT}
is 19011
, then the URL will be:
http://123.456.789.0:19011/flow/trigger
Method
The HTTP method to use when sending the request must be POST
.
Content-Type
The Content-Type
header must be application/json
.
Body
The body of the request must be a JSON object with three (3) fields:
set_trigger
:
Set totrue
to trigger the tool.id
:
The ID of the trigger tool. This is used to identify which trigger tool to trigger.image_base64
:
The image inbase64
format, see Image payload. This is optional.
Below are two (2) examples of the payload:
For this example, the id
of the trigger tool is 1
and the base64 image is image_base64
.
- Without image
{
"set_trigger": true,
"id": 1
}
- With image
{
"set_trigger": true,
"id": 1,
"image_base64": "image_base64"
}
In Zene UI, the user can copy the payload with the id
field automatically filled in.
Websocket Trigger
URL
This is the Zene Websocket server URL that the user will send a message to trigger the tool.
ws://{ZENE_HOST_ADDRESS}:{ZENE_WEBSOCKET_PORT}?username={ZENE_USERNAME}&password={ZENE_PASSWORD}
ZENE_HOST_ADDRESS
: The IP address of the machine running the Zene Server.ZENE_WEBSOCKET_PORT
: The Websocket port (Server Port) of the Zene Server.ZENE_USERNAME
: The username of the Zene Server.ZENE_PASSWORD
: The password of the Zene Server.
Message
The message to send to the Zene Websocket server must be a JSON object with five (5) fields:
type
:
The type of the message. This must beflow/trigger
.data
: The data of the message. This must be a JSON object with three (3) fields:set_trigger
:
Set totrue
to trigger the tool.id
:
The ID of the trigger tool. This is used to identify which trigger tool to trigger.image_base64
:
The image inbase64
format, see Image payload. This is optional.
Below are two (2) examples of the payload:
For this example, the id
of the trigger tool is 1
and the base64 image is image_base64
.
- Without image
{
"type": "flow/trigger",
"data": {
"set_trigger": true,
"id": 1
}
}
- With image
{
"type": "flow/trigger",
"data": {
"set_trigger": true,
"id": 1,
"image_base64": "image_base64"
}
}
In Zene UI, the user can copy the payload with the id
field automatically filled in.
Modbus Read Trigger
This trigger method will trigger the tool when the Modbus server has new data. The tool will read the data from the Modbus server and use the data to trigger the tool.
The data within the specified address must be larger than 0
to trigger the tool.
If the Modbus Read Trigger is enabled, it could take a long time (usually 1 seconds but can take longer) to read the data from the Modbus server. This depends on the Modbus server and the network connection. This could cause the flow to run slower.
With Modbus read
Enable Modbus read for triggering. Default to false
.
Setup Tool
Reference to the Modbus Config tool.
The Modbus Config tool must be configured before using this tool.
Function code
Function code to read from the server.
The available function codes are:
Function Code | Hex | Description |
---|---|---|
1 | 0x01 | Read Coils |
2 | 0x02 | Read Discrete Inputs |
3 | 0x03 | Read Holding Registers |
4 | 0x04 | Read Input Registers |
Starting Address
The starting address to read from the server.
Number of read attempts
Number of reading attempts to the server. Default to 2
.
The higher the number of read attempts, the longer the tool could take to run.
Ignore errors
Whether to ignore errors when reading from the server. Default to false
.