I have a script which reads data from a .ini file to set the maximum time of all lights beeing on:
log = logging.getLogger("org.eclipse.smarthome.model.script.Rules.lights.py")
@rule("Die Lichter automatisiert wieder ausschalten")
@when("Item gLights received command ON")
def lichterAutomatisertAusschalten(event):
global lightTimer
#falls der Timer abgelaufen ist
if lightTimer is None or str(lightTimer.getState()) == "TERMINATED": #lightTimer is None or
#auslesen der Werte der config
myConfig=open("/etc/openhab2/system/runtime/environment.ini","r")
if myConfig.mode == "r":
configuration=myConfig.readlines()
#log.info(""+configuration)
#myConfig=configuration.readlines()
#jede Zeile durch iteraten
for x in configuration:
log.info(" "+ x)
#finden der richtigen Zeile
if x.startswith("LichterMinuten"):
x=x.replace("LichterMinuten=","")
lightTimer(int(x), lambda: events.sendCommand("gLights","OFF")) #line 38
lightTimer.start()
log.info("Timer fuer alle Lichter erstellt. (Laufzeit: "+str(x)+")")
myConfig.close()
else:
log.info("Kann nicht auf die Datei zugreifen!")
elif lightTimer is not None and str(lightTimer.getState()) == "TIMED_WAITING":
lightTimer.stop()
I get the right output but I can’t create the timer with the logs saying:
I’m really new to Jython so any help is appreciated