Files
openhab/scripts/jsr223_demo.py

29 lines
913 B
Python
Raw Permalink Normal View History

2018-07-01 21:49:41 +02:00
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()
])