import scripts

This commit is contained in:
root
2018-07-01 21:49:41 +02:00
parent 913e87820e
commit 9def430b16
2 changed files with 33 additions and 0 deletions

5
scripts/README Normal file
View File

@@ -0,0 +1,5 @@
Put any file containing script definitions here. They will be activated automatically.
Note: Script definition files must have the extension '*.script'
Demo-files can be obtained from the archive 'distribution-demo-*.zip'.

28
scripts/jsr223_demo.py Normal file
View File

@@ -0,0 +1,28 @@
class TestRule(Rule):
def __init__(self):
self.logger = oh.getLogger("TestRule")
def getEventTrigger(self):
return [
StartupTrigger(),
ChangedEventTrigger("Heating_FF_Child", None, None),
TimerTrigger("0/50 * * * * ?")
]
def execute(self, event):
self.logger.debug("event received {}", event)
oh.logInfo("TestRule", str(ItemRegistry.getItem("Heating_GF_Corridor")))
action = oh.getActions()
oh.logInfo("TestRule", "available actions: " + str(action.keySet()))
ping = oh.getAction("Ping")
oh.logInfo("TestRule", "internet reachable: " + ("yes" if ping.checkVitality("google.com", 80, 100) else "no"))
def whoop():
print "yeah"
oh.createTimer(DateTime.now().plusSeconds(10), whoop)
def getRules():
return RuleSet([
TestRule()
])