Package org.openhab.core.automation
Interface RuleManager
@NonNullByDefault
public interface RuleManager
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 RuleStatus
Utility method which getsRuleStatus
of the specifiedRule
.@Nullable RuleStatusInfo
getStatusInfo
(String ruleUID) This method getsRuleStatusInfo
of the specifiedRule
.@Nullable Boolean
This method gets enabledRuleStatus
for aRule
.The method skips the triggers and the conditions and directly executes the actions of the rule.Same asrunNow(String)
with the additional option to enable/disable evaluation of conditions defined in the target rule.void
setEnabled
(String uid, boolean isEnabled) This method is used for changing enabled state of theRule
.simulateRuleExecutions
(ZonedDateTime from, ZonedDateTime until) Simulates the execution of all rules with tag 'Schedule' for the given time interval.
-
Method Details
-
isEnabled
This method gets enabledRuleStatus
for aRule
. The enabled rule statuses areRuleStatus.UNINITIALIZED
,RuleStatus.IDLE
andRuleStatus.RUNNING
. The disabled rule status isRuleStatus.UNINITIALIZED
withRuleStatusDetail.DISABLED
.- Parameters:
ruleUID
- UID of theRule
- Returns:
true
when theRuleStatus
is one of theRuleStatus.UNINITIALIZED
with any otherRuleStatusDetail
thanRuleStatusDetail.DISABLED
,RuleStatus.IDLE
andRuleStatus.RUNNING
,false
when it isRuleStatus.UNINITIALIZED
withRuleStatusDetail.DISABLED
andnull
when it is not available.
-
setEnabled
This method is used for changing enabled state of theRule
. The enabled rule statuses areRuleStatus.UNINITIALIZED
,RuleStatus.IDLE
andRuleStatus.RUNNING
. The disabled rule status isRuleStatus.UNINITIALIZED
withRuleStatusDetail.DISABLED
. -
getStatusInfo
This method getsRuleStatusInfo
of the specifiedRule
.- Parameters:
ruleUID
- UID of theRule
- Returns:
RuleStatusInfo
object containing status of the lookingRule
or null when a rule with specified UID does not exist.
-
getStatus
Utility method which getsRuleStatus
of the specifiedRule
.- Parameters:
ruleUID
- UID of theRule
- Returns:
RuleStatus
object containing status of the lookingRule
or 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.- Returns:
- a copy of the rule context, including possible return values
-
runNow
Map<String,Object> runNow(String uid, boolean considerConditions, @Nullable Map<String, Object> context) 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
- iftrue
the 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
-
simulateRuleExecutions
Simulates the execution of all rules with tag 'Schedule' for the given time interval. The result is sorted ascending by execution time.- Parameters:
from
-ZonedDateTime
earliest time to be contained in the rule simulation.until
-ZonedDateTime
latest time to be contained in the rule simulation.- Returns:
- A
Stream
with all expectedRuleExecution
.
-