Package org.openhab.core.automation
Interface ModuleHandlerCallback
- All Known Subinterfaces:
SimpleTriggerHandlerCallback,TriggerHandlerCallback
@NonNullByDefault
public interface ModuleHandlerCallback
This class is responsible to provide a
RegistryChangeListener logic. An instance of it is added to
RuleRegistry service, to listen for changes when a single Rule has been added, updated, enabled,
disabled or removed and to involve Rule Engine to process these changes. Also to send a run command
for a single Rule to the Rule Engine.- Author:
- Kai Kreuzer - Initial contribution
-
Method Summary
Modifier and TypeMethodDescription@Nullable RuleStatusUtility method which getsRuleStatusof the specifiedRule.@Nullable RuleStatusInfogetStatusInfo(String ruleUID) This method getsRuleStatusInfoof the specifiedRule.@Nullable BooleanThis method gets enabledRuleStatusfor aRule.The method skips triggers and conditions and executes the actions of the rule asynchronously.runAsync(String ruleUID, boolean considerConditions, @Nullable Map<String, @Nullable Object> context) Same asrunAsync(String)with the additional option to enable/disable evaluation of conditions defined in the target rule.voidThe method skips the triggers and the conditions and directly executes the actions of the rule.voidSame asrunNow(String)with the additional option to enable/disable evaluation of conditions defined in the target rule.voidsetEnabled(String uid, boolean isEnabled) This method is used for changing enabled state of theRule.
-
Method Details
-
isEnabled
This method gets enabledRuleStatusfor aRule. The enabled rule statuses areRuleStatus.UNINITIALIZED,RuleStatus.IDLEandRuleStatus.RUNNING. The disabled rule status isRuleStatusDetail.DISABLED.- Parameters:
ruleUID- UID of theRule- Returns:
truewhen theRuleStatusis one of theRuleStatus.UNINITIALIZED,RuleStatus.IDLEandRuleStatus.RUNNING,falsewhen it isRuleStatusDetail.DISABLEDandnullwhen it is not available.
-
setEnabled
This method is used for changing enabled state of theRule. The enabled rule statuses areRuleStatus.UNINITIALIZED,RuleStatus.IDLEandRuleStatus.RUNNING. The disabled rule status isRuleStatusDetail.DISABLED. -
getStatusInfo
This method getsRuleStatusInfoof the specifiedRule.- Parameters:
ruleUID- UID of theRule- Returns:
RuleStatusInfoobject containing status of the lookingRuleor null when a rule with specified UID does not exist.
-
getStatus
Utility method which getsRuleStatusof the specifiedRule.- Parameters:
ruleUID- UID of theRule- Returns:
RuleStatusobject containing status of the lookingRuleor null when a rule with specified UID does not exist.
-
runNow
The method skips the triggers and the conditions and directly executes the actions of the rule. This should always be possible unless an action has a mandatory input that is linked to a trigger. In that case the action is skipped and the rule engine continues execution of rest actions.- Parameters:
uid- id of the rule whose actions have to be executed.
-
runNow
Same asrunNow(String)with the additional option to enable/disable evaluation of conditions defined in the target rule. The context can be set here, too, but also might benull.- Parameters:
uid- id of the rule whose actions have to be executed.considerConditions- iftruethe conditions of the rule will be checked.context- the context that is passed to the conditions and the actions of the rule.
-
runAsync
The method skips triggers and conditions and executes the actions of the rule asynchronously. This should always be possible unless an action has a mandatory input that is linked to a trigger. In that case the action is skipped and the rule engine continues execution of remaining actions.Note: Unlike
runNow(String), this method will return immediately. To wait for the execution to be completed, callFuture.get()on the returnedFuture.- Parameters:
ruleUID- uid of the rule whose actions should be executed.- Returns:
- A
Futurecontaining the copy of the rule context after completion, including possible return values. - Throws:
UnsupportedOperationException- If asynchronous execution isn't supported by theRuleManagerimplementation.- Implementation note:
- The default implementation simply calls
runAsync(String, boolean, Map).
-
runAsync
default Future<Map<String,@Nullable Object>> runAsync(String ruleUID, boolean considerConditions, @Nullable Map<String, @Nullable Object> context) Same asrunAsync(String)with the additional option to enable/disable evaluation of conditions defined in the target rule. The context can be set here, too, but might also benull.Note: Unlike
runNow(String, boolean, Map), this method will return immediately. To wait for the execution to be completed, callFuture.get()on the returnedFuture.- Parameters:
ruleUID- uid of the rule whose actions should be executed.considerConditions- iftruethe conditions of the rule will be checked.context- the context that is passed to the conditions and the actions of the rule.- Returns:
- a copy of the rule context, including possible return values
- Throws:
UnsupportedOperationException- If asynchronous execution isn't supported by theRuleManagerimplementation.- Implementation note:
- The default implementation throws an
UnsupportedOperationException.
-