def conservatory_fan(event): conservatory_fan.log.debug("conservatory_fan rulel now") fanOnSecs = 240 sp = items["CT_TemperatureSetpoint"] currentTemp = items["CT_Temperature"] if ((sp >= 20) and (currentTemp < (sp)) and (items["RecircFanEnable"] == ON)): conservatory_fan.log.debug("conservatory fan circulate heat rulel turn FAN ON NOW ZZZZZ") events.sendCommand("CT_Fan433PowerSocket", "ON") ScriptExecution.createTimer(DateTime.now().plusSeconds(fanOnSecs), lambda: ct_fan_body())
def __expired(self): """Called when the timer expired, reschedules if necessary""" when = self.function() if when: dt = to_datetime(when) self.timer = ScriptExecution.createTimer(dt, self.__expired)
def __proc_command(self): """ Called when it is time to execute another command. This function simply returns if the queue is empty. Otherwise it pops the next command, executes that command, and then sets a Timer to go off the given number of milliseconds and call __proc_command again to process the next command. """ # No more commands if self.commands.empty(): self.timer = None return # Pop the next command and run it cmd = self.commands.get() funct = cmd[1] before = DateTime.now().millis funct() after = DateTime.now().millis # Calculate how long to sleep delta = after - before pause = to_datetime(cmd[0]) trigger_time = to_datetime(cmd[0]).minusMillis(delta) # Create/reschedule the Timer if not self.timer: self.timer = ScriptExecution.createTimer(trigger_time, self.__proc_command) else: self.timer.reschedule(trigger_time)
def Scene_Goodnight(event): # Scene_Goodnight.log.info("::Boiler_Control rule -> A Heater recieved a command - updating boiler state::") LogAction.logError("Scene_Goodnight", "goodnight going to bed") global tgoodnight global CT_HPSP_Night events.sendCommand("CT_FairyLights433Socket", "OFF") events.sendCommand("ZbColourBulb01Switch", "OFF") events.sendCommand("ZbColourBulb02Switch", "OFF") events.sendCommand("radio", "OFF") events.sendCommand("vCT_TVKodiSpeakers", "OFF") events.postUpdate("CT_Heating_PresetTempNormal", items["CT_HPSP_Night"].toString()) events.postUpdate("FR_Heating_PresetTempNormal", items["FR_HPSP_Night"].toString()) events.postUpdate("ER_Heating_PresetTempNormal", items["ER_HPSP_Night"].toString()) events.postUpdate("AT_Heating_PresetTempNormal", items["AT_HPSP_Night"].toString()) events.postUpdate("BR_Heating_PresetTempNormal", items["BR_HPSP_Night"].toString()) events.postUpdate("OF_Heating_PresetTempNormal", items["OF_HPSP_Night"].toString()) events.postUpdate("HL_Heating_PresetTempNormal", items["HL_HPSP_Night"].toString()) events.sendCommand("Heating_UpdateHeaters", "ON") events.postUpdate("Scene_Goodnight", "OFF") events.sendCommand("workLightsPowerSocket", "OFF") events.sendCommand("workLightsPowerSocket", "OFF") # events.sendCommand("Heating_UpdateHeaters", "ON") #trigger updating of heaters and boiler etc tgoodnight = ScriptExecution.createTimer( DateTime.now().plusSeconds(300), lambda: events.sendCommand("ZbWhiteBulb01Switch", "OFF"))
def check(self, key, when, function=None, flapping_function=None, reschedule=False): """Call to check whether a key has a Timer. If no Timer exists, creates a new timer to run the passed in function. If a Timer exists, reschedule it if reschedule is True and if a flapping_function was passed, run it. Arguments: - key: The key to set a Timer for. - when: The time for when the timer should go off. Supports: - DateTime objects - ISO 8601 formatted Strings - Python int, treated as number of seconds into the future - DecimalType, PercentType, or QuantityType (intValue() is called), treated as number of seconds into the future - Duration string of the format Xd Xh Xm Xs where: - d: days - h: hours - m: minutes - s: seconds - X: integer or floating point number for the amount e.g. 1h3s represents one hour and three seconds - function: Optional function to call when the Timer expires - flapping_function: Optional function to call if the key already has a Timer running. Defaults to None. - reschedule: Optional flag that causes the Timer to be rescheduled when the key already has a Timer. Defaults to False. """ timeout = to_datetime(when) TimerMgr_logger.debug("timeout is: " + str(timeout)) # Timer exists: if the reschedule flag is set, reschedule it, otherwise # cancel it. If a flapping function was passed to us, call the flapping # function. if key in self.timers: if reschedule: self.timers[key]['timer'].reschedule(timeout) TimerMgr_logger.debug("rescheduling timer for: " + str(key)) else: self.cancel(key) TimerMgr_logger.debug("Timer cancelled for: " + str(key)) if flapping_function: flapping_function() TimerMgr_logger.debug("Running flapping function for: " + str(key)) # No timer exists, create the Timer else: TimerMgr_logger.debug("Creating timer for: " + str(key)) timer = ScriptExecution.createTimer( timeout, lambda: self.__not_flapping(key)) self.timers[key] = { 'timer': timer, 'flapping': flapping_function, 'not_flapping': function if function else self.__noop } TimerMgr_logger.debug("Timer created: " + str(self.timers[key]))
def conservatory_tv_on(event): global t_CTtvPowerOff conservatory_tv_on.log.info("conservatory_tv_on") Voice.say("Turning on conservatory TV", "voicerss:enGB", "chromecast:chromecast:GHM_Conservatory", PercentType(50)) # events.postUpdate("shutdownKodiConservatoryProxy", "ON") events.sendCommand("CT_TV433PowerSocket", "ON") events.sendCommand("amplifier_power", "ON") events.sendCommand("CT_pi_kodi_bg_wifisocket_1_power", "ON") if t_CTtvPowerOff is not None: t_CTtvPowerOff = None t_ampStandbyON = ScriptExecution.createTimer(DateTime.now().plusSeconds(45), lambda: events.sendCommand("amplifierStandby", "ON")) t_ampVideo01 = ScriptExecution.createTimer(DateTime.now().plusSeconds(50), lambda: events.sendCommand("amplifiervideo1", "ON"))
def dimmer(event): global iteration interval = 250 Loops = 0 Befehl = str(event.getItemCommand()).split(",") try: #Fehlerbehebung bei fehlenden FadeStep FadeStepMS = int(Befehl[4]) except (IndexError, ValueError): FadeStepMS = interval TargetValue = int(Befehl[1]) FadePeriodMs = int(Befehl[2]) Item = Befehl[3] try: StartValue = items[Item] except (KeyError): return if items[Item] == NULL: LogAction.logInfo("Timer Test", u"Abbruch") return LogAction.logInfo("Timer Test", u"Item = " + Item) if Item in dimmertimers: LogAction.logInfo("Timer Test", u"Item existiert") dimmertimers[Item]['timer'].cancel() dimmertimers[Item]['timer'] = None del dimmertimers[Item] PercentPerStep = ((float(str(StartValue))) - float(str(TargetValue))) / (FadePeriodMs / FadeStepMS) if PercentPerStep == 0: LogAction.logInfo("Dimmer Routine", u"Nichts zu tun!") return Loops = FadePeriodMs / FadeStepMS dimmertimers[Item] = { 'item': Item, 'timer': ScriptExecution.createTimer(DateTime.now().plusMillis(interval), lambda: DimNow(Item)), 'loops': Loops, 'TargetValue': TargetValue, 'FadePeriod': FadePeriodMs, 'PercentPerStep': PercentPerStep, 'FadeStepMS': FadeStepMS } dimmertimers[Item]['timer'].reschedule(DateTime.now().plusMillis(interval))
def scene_Goodnight_init(event): LogAction.logInfo("StartUp - set up Item Scene_Goodnight", "StartUp - set up Item Scene_Goodnight") # events.postUpdate("BridgeLightSensorState", "OFF") global tsceneStartup if tsceneStartup is None: tsceneStartup = ScriptExecution.createTimer( DateTime.now().plusSeconds(45), lambda: events.postUpdate("Scene_Goodnight", "OFF"))
def battery_charging_monitor(event): battery_charging_monitor.log.debug("Battery charging monitor: {}: start".format(event.itemState)) if items["Outlet9"] == ON and event.itemState <= DecimalType(8) and event.oldItemState <= DecimalType(8): if MY_TIMERS.get("charger_timer") is None or MY_TIMERS["charger_timer"].hasTerminated(): MY_TIMERS["charger_timer"] = ScriptExecution.createTimer(DateTime.now().plusMinutes(5), lambda: events.sendCommand("Outlet9","OFF")) battery_charging_monitor.log.info("Battery charging monitor: Started battery charging turn off timer: Outlet9_Power=[{}], oldItemState=[{}]".format(event.itemState, event.oldItemState)) elif MY_TIMERS.get("charger_timer") is not None and not MY_TIMERS["charger_timer"].hasTerminated(): MY_TIMERS.get("charger_timer").cancel() battery_charging_monitor.log.info("Battery charging monitor: Canceled battery charging turn off timer: Outlet9_Power=[{}], oldItemState=[{}]".format(event.itemState, event.oldItemState))
def bedroom_tv_off(event): bedroom_tv_off.log.info("bedroom_tv_off") global t_brtvPowerOff Voice.say("Turning off Bedroom TV", "voicerss:enGB", "chromecast:chromecast:GHM_Conservatory", PercentType(50)) events.postUpdate("shutdownKodiBedroomProxy", "OFF") if t_brtvPowerOff is None: t_brtvPowerOff = ScriptExecution.createTimer(DateTime.now().plusSeconds(30), lambda: brtvoffbody())
def zbAvail(event): LogAction.logInfo("gTHSensorTemperatures", "== gTHSensorTemperatures Item {} received update: {}", event.itemName, event.itemState) newname = event.itemName[:event.itemName.rfind('_')+1] + "reachable" events.postUpdate(newname, "Online") # use reachable not triggering event cos its temp zbAvail.log.info("== ZB temp sensor availability marked ONLINE::") if event.itemName not in timers or timers[event.itemName].hasTerminated(): timers[event.itemName] = ScriptExecution.createTimer(DateTime.now().plusMinutes(timeoutMinutes), lambda: events.postUpdate(newname, "Offline")) else: timers[event.itemName].reschedule(DateTime.now().plusMinutes(timeoutMinutes))
def fr_tv_off(event): fr_tv_off.log.info("front room_tv_off") global t_frtvPowerOff Voice.say("Turning off front room TV", "voicerss:enGB", "chromecast:chromecast:GHM_Conservatory", PercentType(50)) events.postUpdate("shutdownKodiFrontRoomProxy", "OFF") # events.sendCommand("amplifierStandby", "OFF") if t_frtvPowerOff is None: t_frtvPowerOff = ScriptExecution.createTimer(DateTime.now().plusSeconds(30), lambda: frtvoffbody())
def zone1WentOnline(event): zone1WentOnline.log.warn("Zone 1 went Online") NotificationAction.sendNotification("*****@*****.**", "Zone 1 came Online") global t5 if items["tableLamp1"] == ON: events.sendCommand("tableLamp1", "OFF") t5 = ScriptExecution.createTimer( DateTime.now().plusSeconds(2), lambda: events.sendCommand("CT_FairyLights433Socket", "ON"))
def pir_light_off(event): pir_light_off.log.debug("///// pir_occupancy_off triggering item : " + event.itemName + " : " + event.itemState.toString()) global pir01_off_timer global pir02_off_timer if event.itemName == "pir01_occupancy": pir_light_off.log.debug( "pir01_occupancy: STARTING TIMER KT_light_1_Power: OFF ") pir01_off_timer = ScriptExecution.createTimer( DateTime.now().plusSeconds(lights_timeout), lambda: pir01_off_body()) if event.itemName == "pir02_occupancy": pir_light_off.log.debug( "pir02_occupancy : STARTING TIMER KT_light_2&3_Power: OFF ") pir02_off_timer = ScriptExecution.createTimer( DateTime.now().plusSeconds(lights_timeout), lambda: pir02_off_body())
def AT_tv_off(event): AT_tv_off.log.info("attic_tv_off") global t_attvPowerOff Voice.say("Turning off attic TV", "voicerss:enGB", "chromecast:chromecast:GHM_Conservatory", PercentType(50)) events.postUpdate("shutdownKodiAtticProxy", "OFF") # events.sendCommand("amplifierStandby", "OFF") #if the power switch socket is ON then we are OK to do the shutdown routine #if items["wifi_socket_5_power"] == ON: if t_attvPowerOff is None: #shutdown timer is not currently running t_attvPowerOff = ScriptExecution.createTimer(DateTime.now().plusSeconds(30), lambda: attvoffbody())
def start_lock_timer(self, time_out_seconds): def timeout_callback(): log.warn("Occupancy LOCK timer for area {} expired".format( self.name)) self.unlock() self.lock_timer = ScriptExecution.createTimer( DateTime.now().plusSeconds(time_out_seconds), timeout_callback) self.lock_timer = Timer(time_out_seconds, timeout_callback) log.warn( "Occupancy LOCK timer for area {} started for {} seconds".format( self.name, time_out_seconds))
def zbRouterAvail(event): zbRouterAvail.log.debug("== zbRouterAvail::") LogAction.logDebug("zbRouterAvail", "==xxxccc Item {} received update: {}", event.itemName, event.itemState) events.postUpdate("ZbRouter_01_Reachable", "Online") #log.debug("Battery charging monitor: {}: start".format(event.itemState)) global zbRouterTimer if zbRouterTimer is not None and not zbRouterTimer.hasTerminated(): zbRouterTimer.cancel() zbRouterTimer = ScriptExecution.createTimer( DateTime.now().plusSeconds(routerTimeout), lambda: events.postUpdate("ZbRouter_01_Reachable", "Offline")) zbRouterAvail.log.debug("==== zbRouterAvail timer started!!!!!!!!!!!::")
def conservatory_tv_off(event): conservatory_tv_off.log.info("conservatory_tv_off") global t_CTtvPowerOff Voice.say("Turning off Conservatory TV", "voicerss:enGB", "chromecast:chromecast:GHM_Conservatory", PercentType(50)) # events.postUpdate("shutdownKodiConservatoryProxy", "OFF") - this routine can be removed if this works LogAction.logError("Shutdown Conservatory Kodi","Shutdown Conservatory Kodi: {}", event.itemName) events.sendCommand("kodiConservatory_systemcommand","Shutdown") events.sendCommand("amplifierStandby", "OFF") if t_CTtvPowerOff is None: t_CTtvPowerOff = ScriptExecution.createTimer(DateTime.now().plusSeconds(30), lambda: tvoffbody())
def OS_sensor_offline(event): OS_sensor_offline.log.error("outside sensor went offline") NotificationAction.sendNotification("*****@*****.**", "outside sensor gone offline") global t1 if items["outsideReboots"] == NULL: events.postUpdate("ousideReboots", 0) events.sendCommand("outsideSensorPower", "OFF") t1 = ScriptExecution.createTimer( DateTime.now().plusSeconds(15), lambda: events.sendCommand("outsideSensorPower", "ON")) events.postUpdate(ir.getItem("outsideReboots"), items["outsideReboots"].intValue() + 1)
def batteryChargingMonitor2(event): #log.debug("Battery charging monitor: {}: start".format(event.itemState)) global chargerTimer2 if items["Outlet9"] == ON and event.itemState <= DecimalType( 8) and event.oldItemState <= DecimalType(8): if chargerTimer2 is None or chargerTimer2.hasTerminated(): chargerTimer2 = ScriptExecution.createTimer( DateTime.now().plusMinutes(5), lambda: events.sendCommand("Outlet9", "OFF")) batteryChargingMonitor2.log.info( "Battery charging monitor: Started battery charging turn off timer: Outlet9_Power=[{}], oldItemState=[{}]" .format(event.itemState, event.oldItemState)) elif chargerTimer2 is not None and not chargerTimer2.hasTerminated(): chargerTimer2.cancel() batteryChargingMonitor2.log.info( "Battery charging monitor: Cancelled battery charging turn off timer: Outlet9_Power=[{}], oldItemState=[{}]" .format(event.itemState, event.oldItemState))
def start_timer(self, time_out_seconds): time_started = DateTime.now() def timeout_callback(): log.warn( "Occupancy timer for area {} expired, timer was started at {}". format(self.name, time_started)) self.set_area_vacant('Timer Expired') self.occupancy_timer = None self.occupancy_timeout = None self.cancel_timer() self.occupancy_timer = ScriptExecution.createTimer( DateTime.now().plusSeconds(time_out_seconds), timeout_callback) self.occupancy_timeout = DateTime.now().plusSeconds(time_out_seconds) log.warn("Occupancy Timer for area {} expires at {}".format( self.name, self.occupancy_timeout))
def bgAvail(event): LogAction.logDebug( "gBG_socket_maxworktime_updates", "!!!! gBG_socket_maxworktime_updates Item {} received update: {}", event.itemName, event.itemState) # create the 'reachable' item name e.g bg_wifisocket_4_maxworktime to bg_wifisocket_4_reachable newname = event.itemName[:event.itemName.rfind('_') + 1] + "reachable" events.postUpdate( newname, "Online") # use reachable not triggering event cos its temp bgAvail.log.debug("== BG sockets Online/Offline status marked ONLINE::") if event.itemName not in timers or timers[event.itemName].hasTerminated(): timers[event.itemName] = ScriptExecution.createTimer( DateTime.now().plusSeconds(timeoutSeconds), lambda: events.postUpdate(newname, "Offline")) else: timers[event.itemName].reschedule( DateTime.now().plusSeconds(timeoutSeconds))
def zone3lightson(event): zone3lightson.log.warn("zone3 lights o") NotificationAction.sendNotification("*****@*****.**", "Zone 3 light on") global t1, t2, t3 if items["gColourBulbs"] == ON: cycle_len = 5 #secs for x in range(0, 360, 15): events.sendCommand("gZbColourBulbsColour", str(x) + ",100,100") # time.sleep((cycle_len/360)*100) time.sleep(0.1) events.sendCommand("gZbColourBulbsColour", "0,100,100") # events.sendCommand("gColourBulbs", "ON") # ScriptExecution.createTimer(DateTime.now().plusSeconds(2), lambda: events.sendCommand("gZbColourBulbsColour", "120,100,100")) # ScriptExecution.createTimer(DateTime.now().plusSeconds(4), lambda: events.sendCommand("gZbColourBulbsColour", "240,100,100")) # ScriptExecution.createTimer(DateTime.now().plusSeconds(6), lambda: events.sendCommand("gZbColourBulbsColour", "0,100,100")) else: #0=red, 120=green, 240=blue, 360=red #https://community.openhab.org/t/ikea-tradfri-rgb-lights/35551/16 # var DecimalType hue = new DecimalType(hsb.hue.intValue % 360 + 10) // 0-360; 0=red, 120=green, 240=blue, 360=red(again) # var PercentType sat = new PercentType(hsb.saturation.intValue) // 0-100 # var PercentType bright = new PercentType(hsb.brightness.intValue) // 0-100 # var HSBType newHsb = new HSBType(hue,sat,bright) events.sendCommand("gZbColourBulbsColour", "0,100,100") events.sendCommand("gColourBulbs", "ON") ScriptExecution.createTimer( DateTime.now().plusSeconds(2), lambda: events.sendCommand("gZbColourBulbsColour", "120,100,100")) ScriptExecution.createTimer( DateTime.now().plusSeconds(4), lambda: events.sendCommand("gZbColourBulbsColour", "240,100,100")) t3 = ScriptExecution.createTimer( DateTime.now().plusSeconds(6), lambda: events.sendCommand("gColourBulbs", "OFF")) ScriptExecution.createTimer( DateTime.now().plusSeconds(6), lambda: events.sendCommand("gZbColourBulbsColour", "0,100,100"))
def __init__(self, function, when=None): """Initializes and kicks off the looping timer. Arguments: - function: The function to call when the timer goes off. The function must return the time for the next time the timer should run (see when below). If None is returned the timer will not be rescheduled. - when: Optional time when to kick off the first call to function. It can be any of the forms supported by to_datetime in time_utils (e.g. "1s"). If None is passed the lambda will be called immediately. """ self.function = function self.timer = None if not when: self.__expired() else: self.timer = ScriptExecution.createTimer(to_datetime(when), self.__expired)
def adjust_fan_based_on_humidity(event): global fan_timer if event.itemState >= DecimalType(90): # The conditions have been met to turn on the fan adjust_fan_based_on_humidity.log.debug( "Conditions met to turn off fan") if fan_timer is not None and not fan_timer.hasTerminated(): # If the timer is running, cancel it fan_timer.cancel() adjust_fan_based_on_humidity.log.debug("Timer stopped") if items["Bathroom_Fan"] == OFF: # The fan is OFF, so turn it ON events.sendCommand("Bathroom_Fan", "ON") elif items["Bathroom_Fan"] == ON and event.itemState < DecimalType(90): # The conditions have been met to turn OFF the fan adjust_fan_based_on_humidity.log.debug("Conditions met to turn on fan") if fan_timer is None or fan_timer.hasTerminated(): # A timer does not exist, so create one fan_timer = ScriptExecution.createTimer( DateTime.now().plusMinutes(5), lambda: events.sendCommand("Bathroom_Fan", "OFF")) adjust_fan_based_on_humidity.log.debug("Timer started")
def __iterate__(self): """Implements the main loop for the Timer. This function is called every second until the Timer expires, updating the Item with the amount of time left on the Timer each time. When the time is up it sets the Item to 0 and calls the function. """ self.log.debug("There is {} left on the timer" .format(self.time_left)) # Subtract a second from the time left. self.time_left = self.time_left - ONE_SEC # We have more time left, reschedule for a second into the future and # update the time_left Item. if self.time_left > ZERO_SEC: self.log.debug("Rescheduling the timer!") # Update the count Item. self.__update_item__() # Reschedule the Timer. If there is more than a second left, # reschedule for a second from now. If there is less than a second # this is the last iteration and schedule the Timer for the number # of milliseconds left. next_time = DateTime.now().plusSeconds(1) if self.time_left < ONE_SEC: next_time = DateTime.now().plusMillis( int(round(self.time_left.total_seconds() * 1000))) self.log.debug("Next timer will go off at {}".format(next_time)) self.timer = ScriptExecution.createTimer(next_time, self.__iterate__) # Time's up, call the passed in function. else: self.log.debug("Time's up!") self.time_left = ZERO_SEC self.__update_item__() self.func()
def conservatory_fan_pulse(event): conservatory_fan_pulse.log.debug("conservatory_fan rulel now") events.sendCommand("CT_Fan433PowerSocket", "ON") fan_pulse_timer = ScriptExecution.createTimer(DateTime.now().plusSeconds( 25), lambda: events.sendCommand("CT_Fan433PowerSocket", "OFF"))
def tvs_init(event): tvs_init.log.info("System started - set all rooms TV startup settings") events.postUpdate("BridgeLightSensorState", "OFF") global tStartup if tStartup is None: tStartup = ScriptExecution.createTimer(DateTime.now().plusSeconds(5), lambda: tv_startup_tbody())
def schedule_binding_restart( binding_id, binding_name, binding_thing_name, delay_seconds, reschedule_timer_on_update=False, notify_restart=False ): """ Schedule a binding restart if needed (if Thing status is not 'ONLINE') Arguments: binding_id {String} - The binding identifier (e.g. 'org.openhab.binding.xyzzy') binding_name {String} - The name of the binding, e.g. 'XYZZY' binding_thing_name {String} - The Thing name linked to the binding (e.g. binding:id:x:y:z) delay_seconds {Integer} - # seconds to wait before restarting the binding Keyword Arguments: reschedule_timer_on_update {bool} - Reschedule restart if update received notify_restart {bool} - Notify if the binding is scheduled for restarting """ global timers global binding_restarts if delay_seconds < 0: delay_seconds = 0 # First, check if Thing is already back online current_state = str(things.get(ThingUID(binding_thing_name)).status) if current_state == "ONLINE": if timers.get(binding_id): timers[binding_id].cancel() timers[binding_id] = None LogAction.logInfo(logTitle, u"No need to restart {} ({} back online)".format(binding_name, binding_thing_name)) return if timers.get(binding_id) is None: if notify_restart is True: NotificationAction.sendBroadcastNotification(u"Restart scheduled for {} in {}s (status={})".format(binding_name, delay_seconds, current_state)) # Define the call-back that will be executed when the timer expires. def cb(): global logTitle current_state = str(things.get(ThingUID(binding_thing_name)).status) if current_state == "ONLINE": LogAction.logInfo(logTitle, u"No need to restart {} (status={})".format(binding_name, current_state)) if notify_restart is True: NotificationAction.sendBroadcastNotification(u"Auto restart canceled for {} (status={})".format(binding_name, current_state)) else: LogAction.logInfo(logTitle, u"Will now restart {} (status={})".format(binding_name, current_state)) # Keep track of binding restarts restart_counter = binding_restarts.get(binding_id) if restart_counter is None: binding_restarts[binding_id] = 1 else: binding_restarts[binding_id] = int(restart_counter) + 1 if notify_restart is True: NotificationAction.sendBroadcastNotification(u"Auto restart of {} (status={})".format(binding_name, current_state)) # Restart the binding (use the 'openhab-karaf' entry in ssh config file) Exec.executeCommandLine("/bin/sh@@-c@@ssh openhab-karaf bundle:restart {}".format(binding_id)) timers[binding_id] = None timers[binding_id] = ScriptExecution.createTimer(DateTime.now().plusSeconds(delay_seconds), cb) else: if reschedule_timer_on_update is True: LogAction.logInfo(logTitle, u"Reschedule '{}' binding restart (status='{}').".format(binding_name, current_state)) timers.get(binding_id).reschedule(DateTime.now().plusSeconds(delay_seconds))