def callbackFaded(self,step,data):
     if getItemState("State_Lightprogram").intValue() == 0:
         return
         
     color1, color2, color3, color4, color5 = data
     
     if step == self.fadingSteps:
         newColor1 = color2
         newColor2 = color3
         newColor3 = color4
         newColor4 = color5
         newColor5 = color1
     else:
         currentColor1, currentColor2, currentColor3, currentColor4 , currentColor5 = self._getCurrentColors()
         
         newColor1 = self._fade( step, color1, color2, currentColor1 )
         newColor2 = self._fade( step, color2, color3, currentColor2 )
         newColor3 = self._fade( step, color3, color4, currentColor3 )
         newColor4 = self._fade( step, color4, color5, currentColor4 )
         newColor5 = self._fade( step, color5, color1, currentColor5 )
         
     self.log.info(u"{} - 1 {}, from {} => {}".format(step,newColor1,color1, color2))
     self.log.info(u"{} - 2 {}, from {} => {}".format(step,newColor2,color2, color3))
     self.log.info(u"{} - 3 {}, from {} => {}".format(step,newColor3,color3, color4))
     self.log.info(u"{} - 4 {}, from {} => {}".format(step,newColor4,color4, color5))
     self.log.info(u"{} - 5 {}, from {} => {}".format(step,newColor5,color5, color1))
     
     self._setCurrentColors([newColor1,newColor2,newColor3,newColor4,newColor5])
     
     if step < self.fadingSteps:
         self.timer = createTimer(self.timeout, self.callbackFaded, [step + 1, data] )
         self.timer.start()
     else:
         self.timer = createTimer(self.timeout, self.callbackFaded, [1, self._getCurrentColors() ] )
         self.timer.start()
    def callbackProgress(self):
        if self.progressTimer is not None and self.currentProgressMsg != getItemState(
                "Watering_Program_State").toString():
            self.log.info("Cancel Watering Progress Zombie Timer")
            self.cleanProgressTimer()
            return

        msg, remaining = self.findStep()

        if remaining <= 0:
            self.cleanProgressTimer()
            return

        remainingInMinutes = int(math.floor(round(remaining / 1000.0) / 60.0))

        if remainingInMinutes > 0:
            msg = u"{} noch {} min".format(msg, remainingInMinutes)
        else:
            msg = u"{} gleich fertig".format(msg)

        self.currentProgressMsg = msg
        postUpdate("Watering_Program_State", self.currentProgressMsg)

        self.progressTimer = createTimer(60.0, self.callbackProgress)
        self.progressTimer.start()
    def execute(self, module, input):
        if self.timer is not None:
            self.timer.cancel()
            self.timer = None

        if input["newState"] == OPEN:
            postUpdate("Dooropener_FF_Floor", ON)
            self.timer = createTimer(3.0, self.callback)
            self.timer.start()

        else:
            postUpdateIfChanged("Dooropener_FF_Floor", OFF)
Exemplo n.º 4
0
    def execute(self, module, input):
        if getItemState("Auto_Christmas") == ON:
            if input["event"].getItemState().intValue() == 1:
                sendCommand("Socket_Floor", ON)
                sendCommand("Socket_Livingroom_Couch", ON)
                sendCommand("Socket_Livingroom_Fireplace", ON)
                sendCommand("Socket_Mobile_1", ON)

                # must be a timer, otherwise sometimes it does not work. Maybe a conflict with Socket_Mobile_1 action
                timer = createTimer(1.0, self.callback, [ON])
                timer.start()

            else:
                sendCommand("Socket_Floor", OFF)
                sendCommand("Socket_Livingroom_Couch", OFF)
                sendCommand("Socket_Livingroom_Fireplace", OFF)
                sendCommand("Socket_Mobile_1", OFF)

                # must be a timer, otherwise sometimes it does not work. Maybe a conflict with Socket_Mobile_1 action
                timer = createTimer(1.0, self.callback, [OFF])
                timer.start()
Exemplo n.º 5
0
    def execute(self, module, input):
        if getItemState("State_Outdoorlights") == ON and getItemState(
                "Motiondetector_Outdoor_Terrace_Switch") == ON:
            global timerMappings
            if timerMappings.get("Light_Outdoor_Terrace") is not None:
                timerMappings["Light_Outdoor_Terrace"].cancel()
            timerMappings["Light_Outdoor_Terrace"] = createTimer(
                timerDuration, self.callback)
            timerMappings["Light_Outdoor_Terrace"].start()

            global ruleTimeouts
            ruleTimeouts["Light_Outdoor"] = getNow().getMillis()

            sendCommand("Light_Outdoor_Terrace", 100)
    def execute(self, module, input):
        if self.timer != None:
            self.timer.cancel()
            self.timer = None
            
            if self.orgColors != None:
                self._setCurrentColors(self.orgColors)
                self.orgColors = None
        
        itemState = input["event"].getItemState().intValue()
        
        if itemState > 0:
            self.orgColors = self._getCurrentColors()

            if itemState == 1:

                self.timer = createTimer(1, self.callback)
                self.timer.start()

            elif itemState == 2:
        
                self.timer = createTimer(1, self.callbackFaded, [1, self.orgColors])
                self.timer.start()'''
 def execute(self, module, input):
     if input["event"].getItemName() == "Door_FF_Floor":
         if self.isArriving:
             if getItemState("State_Outdoorlights") == ON:
                 sendCommand("Light_FF_Floor_Ceiling", ON)
             self.isArriving = False
     # 10 minutes matches the max time ranges used by presence detection to ping phones => see pingdevice thing configuration
     # it can happen that State_Presence changes after Door_FF_Floor was opened
     elif itemLastUpdateOlderThen("Door_FF_Floor",
                                  getNow().minusMinutes(10)):
         self.isArriving = input["event"].getItemState().intValue(
         ) == 1 and input["oldState"].intValue() == 0
         if self.isArriving:
             self.arrivingTimer = createTimer(60, self.arrivingCallback)
             self.arrivingTimer.start()
Exemplo n.º 8
0
    def callback(self, entry):
        global timerMappings
        if getItemState(entry[1]) == ON:
            if getItemState(entry[2]) == OPEN:
                timerMappings[entry[0]] = createTimer(timerDuration,
                                                      self.callback, [entry])
                timerMappings[entry[0]].start()
            else:
                global ruleTimeouts
                ruleTimeouts["Light_Outdoor"] = getNow().getMillis()

                sendCommand(entry[0], OFF)
                timerMappings[entry[0]] = None
        else:
            timerMappings[entry[0]] = None
Exemplo n.º 9
0
    def execute(self, module, input):
        itemName = input['event'].getItemName()

        entry = manualMappings[self.triggerMappings[itemName]]
        if getItemState("State_Outdoorlights") == ON and getItemState(
                entry[1]) == ON:
            if timerMappings.get(entry[0]) is not None:
                timerMappings[entry[0]].cancel()
            timerMappings[entry[0]] = createTimer(timerDuration, self.callback,
                                                  [entry])
            timerMappings[entry[0]].start()

            global ruleTimeouts
            ruleTimeouts["Light_Outdoor"] = getNow().getMillis()

            sendCommand(entry[0], ON)
Exemplo n.º 10
0
    def callback(self):
        global timerMappings
        if getItemState("Motiondetector_Outdoor_Terrace_Switch") == ON:
            if getItemState(
                    "Motiondetector_Outdoor_Terrace1") == OPEN or getItemState(
                        "Motiondetector_Outdoor_Terrace2") == OPEN:
                timerMappings["Light_Outdoor_Terrace"] = createTimer(
                    timerDuration, self.callback)
                timerMappings["Light_Outdoor_Terrace"].start()
            else:
                global ruleTimeouts
                ruleTimeouts["Light_Outdoor"] = getNow().getMillis()

                sendCommand("Light_Outdoor_Terrace", 0)
                timerMappings["Light_Outdoor_Terrace"] = None
        else:
            timerMappings["Light_Outdoor_Terrace"] = None
 def callback(self):
     if getItemState("State_Lightprogram").intValue() == 0:
         return
     
     color1 = getItemState("Light_FF_Livingroom_Hue_Color1")
     color2 = getItemState("Light_FF_Livingroom_Hue_Color2")
     color3 = getItemState("Light_FF_Livingroom_Hue_Color3")
     color4 = getItemState("Light_FF_Livingroom_Hue_Color4")
     color5 = getItemState("Light_FF_Livingroom_Hue_Color5")
         
     global ruleTimeouts
     ruleTimeouts["Livingroom_Hue_Color_Backward"] = getNow().getMillis()
 
     sendCommand("Light_FF_Livingroom_Hue_Color1",color2)
     sendCommand("Light_FF_Livingroom_Hue_Color2",color3)
     sendCommand("Light_FF_Livingroom_Hue_Color3",color4)
     sendCommand("Light_FF_Livingroom_Hue_Color4",color5)
     sendCommand("Light_FF_Livingroom_Hue_Color5",color1)
                 
     self.timer = createTimer(self.timeout, self.callback )
     self.timer.start()