ActionsActions can be edited using the Domotcl explorer. This includes the action code, as well as which events trigger the action. Events will only trigger an action if the action is enabled. Actions can be enabled and disabled manually and via commands in action code. The code of an action consist of comments, commands, and conditions.TriggersAn action can have zero or more triggers. The action code is executed when any of the triggers fires. In other words, there is a logical OR relation between the triggers for an action. Actions that have no triggers will only run when called from other actions.Triggers are always related to an event. A simple trigger only specifies a device and the name of an event defined for that device. The associated action runs every time the event fires. For events that have a value (i.e. properties), this means every time the value changes. For triggers based on a property, additional constraints can be specified. This will cause the trigger to fire only when the condition is satisfied. The available conditional operators depend on the type of property. String based propertiesString based properties contain either a string or an object path. The following conditional operators are available for these type of properties:
Numerical propertiesNumerical properties are all properties that have a boolean, integer, or double type. For these type of properties, the following conditional operators are available:
CommentsComments in actions are solely intended for the benefit of the human user. They have no effect on the execution of the action. Comments can be placed in both command- and condition blocks and may freely be copied from one to the other.Commands and conditions may be converted to comment to temporarily skip them in an action. These comments can easily be converted back to the original command or condition. If a commented-out command or condition is edited, it is no longer possible to convert it back into a command or condition. CommandsCommands perform a task. Each command is on a line by itself. There are two types of commands:
ConditionsConditions are used within an if/then/else statement to alter the call flow. Each condition is on a line by itself.An if/then/else statement has the following format:
if {
condition(s)
} then {
command(s)
} else {
command(s)
}
Each condition compares the value of a property or the return value of a
function against a fixed value, or another property or function. The result
of this comparison is either 'true' or 'false'.
When there is more than one condition in an if-block, the conditions are joined together with 'or' or 'and' operators. Such a construction is called a compound condition. The operators specify the logic used in evaluating the conditions. Conditions joined by 'and' must all be true in order for the compound condition to be true. If the conditions are joined by 'or', only one must be true in order for the compound condition to be true. When 'or' and 'and' conditions are combined, the 'and' operator has higher precedence than the 'or' operator. When the conditions in the if-block evaluate to true, the commands in the then-block are executed. If the conditions evaluate to false the commands in the optional else-block are executed. Example:
if {
[/time after "08:00:00"] == 1
or [/time special "weekday"] == 1
and [/time after "07:00:00"] == 1
} then {
# Do something
}
The code will be executed on weekdays after 7 AM and on weekends after 8 AM.
ArgumentsCommands and functions can have arguments. The values for these arguments can be provided as fixed values, or taken from properties or functions. Each argument has a specific type. The command dialog will only allow the user to select values, properties, or functions with a compatible type. |