-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCronRule.java
More file actions
32 lines (23 loc) · 933 Bytes
/
CronRule.java
File metadata and controls
32 lines (23 loc) · 933 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.util.Map;
import org.openhab.automation.javascripting.annotations.CronTrigger;
import org.openhab.automation.javascripting.annotations.Rule;
import org.openhab.automation.javascripting.scriptsupport.Script;
import org.openhab.core.automation.Action;
import org.openhab.core.automation.module.script.rulesupport.shared.simple.SimpleRule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CronRule extends Script {
private Logger logger = LoggerFactory.getLogger("org.openhab.automation.javascripting.cronrule");
private int counter = 1;
@Rule(name = "CronRule")
@CronTrigger(id = "CronTrigger", cronExpression = "0 * * * * ?")
public Object execute(Map<String, ?> inputs) {
logger.info("Java cronrule execute {}", counter++);
return "";
}
@Override
protected Object onLoad() {
logger.info("Java onLoad()");
return null;
};
}