Hi Guys, I have been a member for a little while but haven’t posted for a bit. I have been busy working out the physical attributes of my next automation phase. Now that the weather has turned cold, I’m back trying to write some code.
My system is :
OH 2.5 running on a Razzberry Pi4B
Two slave Pi’s that are 3B that communicate over MQTT
rules are written with Jython/Python code, but I’m still a newbie at it.
Communication works fine and i can get the inputs and outputs to work, but I’m having difficulty getting a timer to run.
This is my rule.
def timer_light__on(log):
log.info("The light timer is now running")
sendCommand("house_garage_light_2", ON)
log.info("Running the light timer")
global timer_lights_on
timer_lights_on = createTimer(DateTime.now().plusSeconds(45), lambda: timer_light_on(log))
@rule("Rule Garage Lights on 1", description="Turns the garage lights on wgen the roller RH door opens")
@when("Item house_rollerdoor_door1_up changed")
def Garage_lights_on(event):
global timer_lights_on
if items["house_rollerdoor_door1_up"] == ON:
sendCommand("house_garage_light_2", ON)
timer_light_on = createTimer(DateTime.now().plusSeconds(45), lambda: timer_lights_on(rule_Garage_lights_on.log))
log.warn("Garage roof lights on, running timer")
else:
sendCommand("house_garage_light_2", OFF)
@rule("Rule Garage Lights on 2", description="Turns the garage lights on wgen the roller LH door opens")
@when("Item house_rollerdoor_door2_up changed")
def Garage_lights_on2(event):
global timer_lights_on
if items["house_rollerdoor_door2_up"] == ON:
sendCommand("house_garage_light_2", ON)
timer_light_on = createTimer(DateTime.now().plusSeconds(45), lambda: timer_lights_on(rule_Garage_lights_on.log))
log.warn("Garage roof lights on, running timer")
else:
sendCommand("house_garage_light_2", OFF)
When the upper read switch turns on, the garage lights turn on but then turn off again once the door starts coming down and the switch turns off. I think I’ve missed something, but om not sure what it is.
Any help would be most appreciated.
your code goes here