I’m currently trying to get a simple python script working on OH3.
(Design Pattern: Cascading Timers - #5 by F1nn)
This code is working fine:
@rule("Start Irrigation at 08:00")
@when("Time cron 0 0 8 * * ?")
@when("Item Irrigation_Manual received command ON")
def start_irrigation(event):
log.info("start_irrigation")
if items["Irrigation_Auto"] == ON or items["Irrigation_Manual"] == ON:
# Reset the gatekeeper
global gatekeeper
if gatekeeper:
gatekeeper.cancel_all()
gatekeeper = Gatekeeper(start_irrigation.log)
....
This code doesn’t work:
@rule("Start Irrigation at 08:00")
@when("Time cron 0 0 8 * * ?")
@when("Item Irrigation_Manual received command ON")
def start_irrigation(event):
if items["Irrigation_Auto"] == ON or items["Irrigation_Manual"] == ON:
# Reset the gatekeeper
global gatekeeper
if gatekeeper:
gatekeeper.cancel_all()
gatekeeper = Gatekeeper(start_irrigation.log)
....
It only goes beyond the IF condition when I add the log.info() before.
When I remove it, it doesn’t execute any code. Sometimes it does once but no more.
For reference, this tis the complete file (with lots of debug prints tho): from core.rules import rulefrom core.triggers import whenfrom core.utils imp - Pastebin.com
I don’t really understand why it is acting like that.