# Rules ## Méthodes ### 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. **Paramètres :** | Champ | Type | Notes | | --- | --- | --- | | `actions` | [RuleAction](../types.md#ruleaction)[] | | | `name` | `String` | | | `enabled` | `Bool` | optionnel | | `eventDescriptors` | [EventDescriptor](../types.md#eventdescriptor)[] | optionnel | | `executable` | `Bool` | optionnel | | `exitActions` | [RuleAction](../types.md#ruleaction)[] | optionnel | | `stateEvaluator` | [StateEvaluator](../types.md#stateevaluator) | optionnel | | `timeDescriptor` | [TimeDescriptor](../types.md#timedescriptor) | optionnel | **Retour :** | Champ | Type | Notes | | --- | --- | --- | | `ruleId` | `Uuid` | optionnel | | `ruleError` | [RuleError](../types.md#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. **Paramètres :** | Champ | Type | Notes | | --- | --- | --- | | `ruleId` | `Uuid` | | **Retour :** | Champ | Type | Notes | | --- | --- | --- | | `ruleError` | [RuleError](../types.md#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. **Paramètres :** | Champ | Type | Notes | | --- | --- | --- | | `actions` | [RuleAction](../types.md#ruleaction)[] | | | `name` | `String` | | | `enabled` | `Bool` | optionnel | | `eventDescriptors` | [EventDescriptor](../types.md#eventdescriptor)[] | optionnel | | `executable` | `Bool` | optionnel | | `exitActions` | [RuleAction](../types.md#ruleaction)[] | optionnel | | `stateEvaluator` | [StateEvaluator](../types.md#stateevaluator) | optionnel | | `timeDescriptor` | [TimeDescriptor](../types.md#timedescriptor) | optionnel | | `ruleId` | `Uuid` | | **Retour :** | Champ | Type | Notes | | --- | --- | --- | | `rule` | [Rule](../types.md#rule) | optionnel | | `ruleError` | [RuleError](../types.md#ruleerror) | | --- ### Rules.EnableRule CONFIGURE-RULES Enabled a rule that has previously been disabled.If successful, the notification "Rule.RuleConfigurationChanged" will be emitted. **Paramètres :** | Champ | Type | Notes | | --- | --- | --- | | `ruleId` | `Uuid` | | **Retour :** | Champ | Type | Notes | | --- | --- | --- | | `ruleError` | [RuleError](../types.md#ruleerror) | | --- ### Rules.ExecuteActions EXECUTE Execute the action list of the rule with the given ruleId. **Paramètres :** | Champ | Type | Notes | | --- | --- | --- | | `ruleId` | `Uuid` | | **Retour :** | Champ | Type | Notes | | --- | --- | --- | | `ruleError` | [RuleError](../types.md#ruleerror) | | --- ### Rules.ExecuteExitActions EXECUTE Execute the exit action list of the rule with the given ruleId. **Paramètres :** | Champ | Type | Notes | | --- | --- | --- | | `ruleId` | `Uuid` | | **Retour :** | Champ | Type | Notes | | --- | --- | --- | | `ruleError` | [RuleError](../types.md#ruleerror) | | --- ### Rules.FindRules EXECUTE Find a list of rules containing any of the given parameters. **Paramètres :** | Champ | Type | Notes | | --- | --- | --- | | `thingId` | `Uuid` | | **Retour :** | Champ | Type | Notes | | --- | --- | --- | | `ruleIds` | `Uuid`[] | | --- ### Rules.GetRuleDetails EXECUTE Get details for the rule identified by ruleId **Paramètres :** | Champ | Type | Notes | | --- | --- | --- | | `ruleId` | `Uuid` | | **Retour :** | Champ | Type | Notes | | --- | --- | --- | | `rule` | [Rule](../types.md#rule) | optionnel | | `ruleError` | [RuleError](../types.md#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. **Paramètres :** _Aucun paramètre._ **Retour :** | Champ | Type | Notes | | --- | --- | --- | | `ruleDescriptions` | [RuleDescription](../types.md#ruledescription)[] | | --- ### Rules.RemoveRule CONFIGURE-RULES Remove a rule **Paramètres :** | Champ | Type | Notes | | --- | --- | --- | | `ruleId` | `Uuid` | | **Retour :** | Champ | Type | Notes | | --- | --- | --- | | `ruleError` | [RuleError](../types.md#ruleerror) | | --- ## Notifications ### Rules.RuleActiveChanged Emitted whenever the active state of a Rule changed. **Paramètres :** | Champ | Type | Notes | | --- | --- | --- | | `active` | `Bool` | | | `ruleId` | `Uuid` | | --- ### Rules.RuleAdded Emitted whenever a Rule was added. **Paramètres :** | Champ | Type | Notes | | --- | --- | --- | | `rule` | [Rule](../types.md#rule) | | --- ### Rules.RuleConfigurationChanged Emitted whenever the configuration of a Rule changed. **Paramètres :** | Champ | Type | Notes | | --- | --- | --- | | `rule` | [Rule](../types.md#rule) | | --- ### Rules.RuleRemoved Emitted whenever a Rule was removed. **Paramètres :** | Champ | Type | Notes | | --- | --- | --- | | `ruleId` | `Uuid` | | ---