Skip to content

Rules

Methods

Rules.AddRule

CONFIGURE-RULES

Add a rule. You can describe rules by one or many EventDesciptors and a StateEvaluator. Note that only one of either eventDescriptor or eventDescriptorList may be passed at a time. A rule can be created but left disabled, meaning it won't actually be executed until set to enabled. If not given, enabled defaults to true. A rule can have a list of actions and exitActions. It must have at least one Action. For state based rules, actions will be executed when the system enters a state matching the stateDescriptor. The exitActions will be executed when the system leaves the described state again. For event based rules, actions will be executed when a matching event happens and if the stateEvaluator matches the system's state. ExitActions for such rules will be executed when a matching event happens and the stateEvaluator is not matching the system's state. A rule marked as executable can be executed via the API using Rules.ExecuteRule, that means, its actions will be executed regardless of the eventDescriptor and stateEvaluators.

Parameters:

Field Type Notes
actions RuleAction[]
name String
enabled Bool optional
eventDescriptors EventDescriptor[] optional
executable Bool optional
exitActions RuleAction[] optional
stateEvaluator StateEvaluator optional
timeDescriptor TimeDescriptor optional

Returns:

Field Type Notes
ruleId Uuid optional
ruleError RuleError

Rules.DisableRule

CONFIGURE-RULES

Disable a rule. The rule won't be triggered by it's events or state changes while it is disabled. If successful, the notification "Rule.RuleConfigurationChanged" will be emitted.

Parameters:

Field Type Notes
ruleId Uuid

Returns:

Field Type Notes
ruleError RuleError

Rules.EditRule

CONFIGURE-RULES

Edit the parameters of a rule. The configuration of the rule with the given ruleId will be replaced with the new given configuration. In ordert to enable or disable a Rule, please use the methods "Rules.EnableRule" and "Rules.DisableRule". If successful, the notification "Rule.RuleConfigurationChanged" will be emitted.

Parameters:

Field Type Notes
actions RuleAction[]
name String
enabled Bool optional
eventDescriptors EventDescriptor[] optional
executable Bool optional
exitActions RuleAction[] optional
stateEvaluator StateEvaluator optional
timeDescriptor TimeDescriptor optional
ruleId Uuid

Returns:

Field Type Notes
rule Rule optional
ruleError RuleError

Rules.EnableRule

CONFIGURE-RULES

Enabled a rule that has previously been disabled.If successful, the notification "Rule.RuleConfigurationChanged" will be emitted.

Parameters:

Field Type Notes
ruleId Uuid

Returns:

Field Type Notes
ruleError RuleError

Rules.ExecuteActions

EXECUTE

Execute the action list of the rule with the given ruleId.

Parameters:

Field Type Notes
ruleId Uuid

Returns:

Field Type Notes
ruleError RuleError

Rules.ExecuteExitActions

EXECUTE

Execute the exit action list of the rule with the given ruleId.

Parameters:

Field Type Notes
ruleId Uuid

Returns:

Field Type Notes
ruleError RuleError

Rules.FindRules

EXECUTE

Find a list of rules containing any of the given parameters.

Parameters:

Field Type Notes
thingId Uuid

Returns:

Field Type Notes
ruleIds Uuid[]

Rules.GetRuleDetails

EXECUTE

Get details for the rule identified by ruleId

Parameters:

Field Type Notes
ruleId Uuid

Returns:

Field Type Notes
rule Rule optional
ruleError RuleError

Rules.GetRules

EXECUTE

Get the descriptions of all configured rules. If you need more information about a specific rule use the method Rules.GetRuleDetails.

Parameters:

No parameters.

Returns:

Field Type Notes
ruleDescriptions RuleDescription[]

Rules.RemoveRule

CONFIGURE-RULES

Remove a rule

Parameters:

Field Type Notes
ruleId Uuid

Returns:

Field Type Notes
ruleError RuleError

Notifications

Rules.RuleActiveChanged

Emitted whenever the active state of a Rule changed.

Parameters:

Field Type Notes
active Bool
ruleId Uuid

Rules.RuleAdded

Emitted whenever a Rule was added.

Parameters:

Field Type Notes
rule Rule

Rules.RuleConfigurationChanged

Emitted whenever the configuration of a Rule changed.

Parameters:

Field Type Notes
rule Rule

Rules.RuleRemoved

Emitted whenever a Rule was removed.

Parameters:

Field Type Notes
ruleId Uuid