IF-THEN Command
UC100 supports configuring locally IF-THEN commands to do some actions automatically even without a network connection. One device can be added 16 commands at most.
1. Go to the Command page, and click Edit to add commands.

2. Set an IF condition based on the terminal device data or UC100 device status.

| Parameter | Description |
|---|---|
| Time(local time) | Set a time. |
|
Channel |
A Modbus channel reaches the threshold value. For coil/discrete type, the condition is False/True; For other types, the condition is Above/Within/Below/Change. Is continued for: the threshold value should last for some time, the condition is More than/Less than. Set lockout time: after the lockout time, UC100 will check if the value still reaches the threshold and matches the condition. 0 means this condition will only be detected once. Value change time interval: the change value should last for
some time.
Note: The Channel parameter will be
hidden if Two-way Pass-through feature is
enabled. |
| Received a command via the RS485 interface | Received a command from RS485
devices. Note: This parameter is only available
when Modbus RS485 bridge LoRaWAN® feature is
enabled. |
| Received a server message | Received a custom message from the
network server. Example: When the custom message is "test", the server should send 74657374 (ASCii to HEX). |
|
Received a Milesight D2D control command |
This only works with the Milesight D2D feature is
enabled. Designated state: After enabled, only the D2D control command with this designed state can trigger UC100. This only works with D2D controller devices which support sending on/off status. |
| The device restarts |
Device is rebooting. |
3. Set the THEN action and the delay time to execute this action. One command supports adding 3 actions at most.

|
Action |
Description |
|---|---|
|
Send a server message |
Send a custom message to the network server. |
|
Send a Milesight D2D control command |
The command should be a 2-byte hexadecimal number. This only works when the Milesight D2D feature is enabled. |
| Send a command via the RS485 interface | Send a command to the RS485 device. |
| Upload data packet | Upload the data packet to network server. |
|
Upload alarm packet |
Upload an alarm packet to network server. |
|
Restart the Device |
Reboot the device. |
The THEN actions that can be added to the IF condition are as follows:
| Time | Channel | Received a command via the RS485 interface | Received a server message | Received a Milesight D2D control command | The device restarts | |
| Send a server message | √ | √ | √ | √ | √ | √ |
| Send a Milesight D2D control command | √ | √ | √ | √ | √ | √ |
| Send a command via the RS485 interface | √ | √ | √ | √ | √ | √ |
| Upload data packet | √ | √ | √ | √ | √ | |
| Upload alarm packet | √ | |||||
| Restart the Device | √ | √ | √ | √ | √ |