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):
        sendCommand("Light_FF_Floor_Ceiling", ON)
        sendCommand("Light_SF_Bathroom_Ceiling", ON)
        sendCommand("Light_SF_Bathroom_Mirror", ON)
        sendCommand("Light_SF_Bedroom_Ceiling", ON)

        postUpdate("Scene2", OFF)
    def execute(self, module, input):
        global ruleTimeouts
        now = getNow().getMillis()
        last = ruleTimeouts.get("Motiondetector_Outdoor_Main_Switch", 0)

        if now - last > 1000:
            itemState = input["event"].getItemCommand()

            if itemState == ON:
                ruleTimeouts["Light_Outdoor"] = now

                sendCommand("Light_Outdoor_Garage_Streedside", OFF)
                sendCommand("Light_Outdoor_Frontdoor", OFF)
                sendCommand("Light_Outdoor_Carport", OFF)
                sendCommand("Light_Outdoor_Terrace", 0)
                sendCommand("Light_Outdoor_Garage_Gardenside", OFF)

            #ruleTimeouts["Motiondetector_Outdoor_Individual_Switches"] = now
            postUpdate("Motiondetector_Outdoor_Garage_Streetside_Switch",
                       itemState)
            postUpdate("Motiondetector_Outdoor_Frontdoor_Switch", itemState)
            postUpdate("Motiondetector_Outdoor_Carport_Switch", itemState)
            postUpdate("Motiondetector_Outdoor_Terrace_Switch", itemState)
            postUpdate("Motiondetector_Outdoor_Garage_Gardenside_Switch",
                       itemState)
    def execute(self, module, input):
        itemName = input['event'].getItemName()
        itemState = input['event'].getItemState()

        sendNotification(u"{}".format(itemName), u"{}".format(itemState))

        holgerPhone = itemState if itemName == "State_Holger_Presence" else getItemState(
            "State_Holger_Presence")
        sandraPhone = itemState if itemName == "State_Sandra_Presence" else getItemState(
            "State_Sandra_Presence")

        if holgerPhone == ON or sandraPhone == ON:
            # only possible if we are away
            if getItemState("State_Presence").intValue() == 0:
                postUpdate("State_Presence", 1)
                sendNotification(u"Tür", u"Willkommen")
        else:
            # only possible if we are present and not sleeping
            if getItemState("State_Presence").intValue() == 1:
                postUpdate("State_Presence", 0)
                lightMsg = u" - LICHT an" if getItemState(
                    "Lights_Indoor") != OFF else u""
                windowMsg = u" - FENSTER offen" if getItemState(
                    "Openingcontacts") != CLOSED else u""

                sendNotification(
                    u"Tür", u"Auf Wiedersehen{}{}".format(lightMsg, windowMsg))
    def execute(self, module, input):
        moverStatus = getItemState("MowerStatus").toString()

        if itemLastUpdateOlderThen("MowerWlanSignal",
                                   getNow().minusMinutes(60)):
            if moverStatus != "98":
                postUpdate("MowerStatus", 98)
                postUpdate(
                    "MowerStatusFormatted",
                    Transformation.transform("MAP", "robonect_status.map",
                                             "98"))
        else:
            seconds = getItemState("MowerDuration").intValue()
            hours = seconds / (60 * 60)
            seconds = seconds % (60 * 60)
            minutes = seconds / 60
            #seconds = seconds % 60

            msg = u"{} seit ".format(
                Transformation.transform("MAP", "robonect_status.map",
                                         moverStatus))
            if hours < 10: msg = u"{}0".format(msg)
            msg = u"{}{}:".format(msg, hours)
            if minutes < 10: msg = u"{}0".format(msg)
            msg = u"{}{}:".format(msg, minutes)

            postUpdateIfChanged("MowerStatusFormatted", msg)
    def execute(self, module, input):
        sendCommand("Motiondetector_Outdoor_Carport_Switch", OFF)
        sendCommand("Motiondetector_Outdoor_Frontdoor_Switch", OFF)
        sendCommand("Motiondetector_Outdoor_Terrace_Switch", OFF)
        sendCommand("Motiondetector_Outdoor_Garage_Streetside_Switch", OFF)
        sendCommand("Motiondetector_Outdoor_Garage_Gardenside_Switch", ON)

        postUpdate("Scene5", OFF)
 def execute(self, module, input):
     # only possible if we are sleeping
     if getItemState("State_Presence").intValue() == 2:
         # sometimes the "Lights_FF" state switches back and forth for a couple of milliseconds when set "Lights_FF" state to OFF
         if itemLastUpdateOlderThen("State_Presence",
                                    getNow().minusSeconds(5)):
             postUpdate("State_Presence", 1)
             sendNotification(u"System", u"Guten Morgen")
    def execute(self, module, input):
        if getItemState("TV_Online") == ON:
            if input["command"] == OFF:
                sendCommand("TV_Online", OFF)
        else:
            if input["command"] == ON:
                sendCommand("TV_Online", ON)

        postUpdate("Scene6", OFF)
示例#9
0
    def execute(self, module, input):

        now = getNow().getMillis()

        currentACPower = getItemState("Solar_AC_Power").intValue()

        currentPowerLimitation = getItemState(
            "Solar_Power_Limitation").intValue()

        currentConsumptionValue = getItemState(
            "Electricity_Current_Consumption").intValue()
        # must be called to fill history stack
        avgConsumptionValue = self.getAvgConsumption(now,
                                                     currentConsumptionValue)

        if currentACPower > 0:
            possiblePowerLimitation = self.getPossibleLimitation(
                currentConsumptionValue)
            possibleAvgPowerLimitation = self.getPossibleLimitation(
                avgConsumptionValue)

            self.log.info(
                u"currentLimit: {}%, currentConsumption: {}W, avgConsumption: {}W, possibleLimit: {}%, possibleAvgLimit: {}%, stack: {}, li: {}"
                .format(currentPowerLimitation, currentConsumptionValue,
                        avgConsumptionValue,
                        possiblePowerLimitation, possibleAvgPowerLimitation,
                        len(self.stack), (now - self.lastLimitationIncrease)))

            if possiblePowerLimitation >= currentPowerLimitation:
                self.lastLimitationIncrease = now
                if possiblePowerLimitation > currentPowerLimitation:
                    sendCommand("Solar_Power_Limitation",
                                possiblePowerLimitation)
                    self.log.info(
                        u"Increase power limitation from {}% to {}%".format(
                            currentPowerLimitation, possiblePowerLimitation))
                    return
            elif now - self.lastLimitationIncrease > maxTimeSlot:
                if possibleAvgPowerLimitation < currentPowerLimitation:
                    sendCommand("Solar_Power_Limitation",
                                possibleAvgPowerLimitation)
                    self.log.info(
                        u"Decrease power limitation from {}% to {}%".format(
                            currentPowerLimitation,
                            possibleAvgPowerLimitation))
                    return

            if len(input) == 0 and itemLastUpdateOlderThen(
                    "Solar_Power_Limitation",
                    getNow().minusMinutes(4)):
                sendCommand("Solar_Power_Limitation", currentPowerLimitation)
                self.log.info(u"Refresh power limitation of {}%".format(
                    currentPowerLimitation))
        elif currentPowerLimitation != 100:
            postUpdate("Solar_Power_Limitation", 100)
            self.log.info(u"Shutdown power limitation")
 def execute(self, module, input):
     start = getHistoricItemState(
         "Heating_Burner_Hours",
         getNow().withTimeAtStartOfDay()).intValue()
     aktuell = getItemState("Heating_Burner_Hours").intValue()
     if start > 0 and aktuell > 0:
         differenz = aktuell - start
         postUpdate("Heating_Burner_Hours_Current_Daily", differenz)
         msg = u"{} h, {} h".format(differenz, aktuell)
         postUpdateIfChanged("Heating_Burner_Hours_Message", msg)
    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)
示例#12
0
    def execute(self, module, input):
        if input["event"].getItemName() == "Solar_AC_Power":
            self.updateConsumption(input['event'].getItemState().intValue())
        else:
            if input["event"].getItemName() == "Power_Demand_Active":
                self.powerDemand = input["event"].getItemState().intValue()
                self.powerSupply = getItemState(
                    "Power_Supply_Active").intValue()

                if self.powerDemand != getItemState(
                        "Power_Demand_Active").intValue():
                    self.log.error(
                        "Item demand state differences: {}, item state: {}".
                        format(self.powerDemand,
                               getItemState("Power_Demand_Active").intValue()))
            else:
                self.powerDemand = getItemState(
                    "Power_Demand_Active").intValue()
                self.powerSupply = input["event"].getItemState().intValue()

                if self.powerSupply != getItemState(
                        "Power_Supply_Active").intValue():
                    self.log.error(
                        "Item supply state differences: {}, item state: {}".
                        format(self.powerSupply,
                               getItemState("Power_Supply_Active").intValue()))

            self.currentDemand = self.powerDemand - self.powerSupply

            if getItemState("State_Solar") == ON:
                # solar value update was not successful for a while
                #solarActive = getItemState("State_Solar") == ON
                #if itemLastUpdateOlderThen("Solar_Total_Yield", getNow().minusHours(5) if solarActive else getNow().minusHours(14)):
                if itemLastUpdateOlderThen("Solar_Total_Yield",
                                           getNow().minusHours(24)):
                    self.log.info(
                        u"Solar: ERROR • Values not updated. Fallback to '0' values."
                    )
                    postUpdate("Solar_AC_Power", 0)
                    postUpdateIfChanged("Solar_DC_Power", 0)
                    postUpdateIfChanged("Solar_DC_Current", 0)
                    postUpdateIfChanged("Solar_DC_Voltage", 0)
                    postUpdateIfChanged("Solar_Daily_Yield", 0)

                # triggers solar value update
                sendCommand("Solar_AC_Power", REFRESH)
            else:
                self.updateConsumption(0)

            postUpdateIfChanged("Electricity_Current_Demand",
                                self.currentDemand)
示例#13
0
    def execute(self, module, input):
        sendCommand("Light_FF_Livingroom_Hue_Brightness", 60)

        states = [OFF, PercentType.ZERO]

        for child in getItem("Lights_FF").getAllMembers():
            if child.getState() not in states and child.getName(
            ) != "Light_FF_Livingroom_Hue_Brightness":
                sendCommand(child, OFF)

        for child in getItem("Lights_SF").getAllMembers():
            if child.getState() not in states:
                sendCommand(child, OFF)

        postUpdate("Scene1", OFF)
示例#14
0
    def execute(self, module, input):
        now = getNow()

        supplyCurrent = getItemState(
            "Energy_Supply_Active").intValue() / 1000.0
        zaehlerStandCurrent = (startEnergyTotalSupplyValue + supplyCurrent)
        postUpdateIfChanged("Electricity_Total_Supply", zaehlerStandCurrent)

        postUpdateIfChanged(
            "Electricity_Meter_Supply",
            (zaehlerStandCurrent - startElectricityMeterSupplyValue) *
            energyTotalSupplyCorrectureFactor)

        # *** Tageslieferung ***
        zaehlerStandOld = getHistoricItemState(
            "Electricity_Total_Supply",
            now.withTimeAtStartOfDay()).doubleValue()
        currentSupply = zaehlerStandCurrent - zaehlerStandOld

        postUpdateIfChanged("Electricity_Current_Daily_Supply", currentSupply)
        # *** Jahreslieferung ***

        zaehlerStandOld = getHistoricItemState(
            "Electricity_Total_Supply",
            now.withDate(now.getYear(), 1,
                         1).withTimeAtStartOfDay()).doubleValue()
        currentSupply = zaehlerStandCurrent - zaehlerStandOld

        if postUpdateIfChanged("Electricity_Current_Annual_Supply",
                               currentSupply):
            # Hochrechnung
            zaehlerStandCurrentOneYearBefore = getHistoricItemState(
                "Electricity_Total_Supply", now.minusYears(1)).doubleValue()
            forecastSupply = zaehlerStandOld - zaehlerStandCurrentOneYearBefore

            zaehlerStandOldOneYearBefore = getHistoricItemState(
                "Electricity_Total_Supply",
                now.withDate(now.getYear() - 1, 1,
                             1).withTimeAtStartOfDay()).doubleValue()

            hochrechnungSupply = int(round(currentSupply + forecastSupply))
            vorjahresSupply = int(
                round(zaehlerStandOld - zaehlerStandOldOneYearBefore))
            msg = u"{}kWh, {} kWh".format(hochrechnungSupply, vorjahresSupply)
            postUpdate("Electricity_Current_Annual_Supply_Forecast", msg)
    def findStep(self):
        duration = getItemState(
            "Watering_Program_Duration").intValue() * 60.0 * 1000.0

        remaining = 0
        activeStep = None

        if getItemState("Watering_Circuits") == OFF:
            for loop in circuits:
                #self.log.info("start " + loop[0][0])
                sendCommand(loop[0][0], ON)
            activeStep = circuits[0][0]
            remaining = (duration * activeStep[2])
        else:
            activeIndex = -1
            for i in range(len(circuits[0])):
                step = circuits[0][i]
                if getItemState(step[0]) == ON:
                    activeIndex = i
                    activeStep = step
                    break

            if activeStep != None:
                runtime = getNow().getMillis() - getItemLastUpdate(
                    activeStep[0]).getMillis()

                remaining = (duration * activeStep[2]) - runtime

                if remaining <= 0:
                    activeIndex += 1
                    if activeIndex < len(circuits[0]):
                        #self.log.info("next " + circuits[0][activeIndex][0])
                        sendCommand(circuits[0][activeIndex][0], ON)
                        sendCommand(activeStep[0], OFF)
                        activeStep = circuits[0][activeIndex]
                        remaining = (duration * activeStep[2])
                    else:
                        activeStep = None
                        #self.log.info("finish")
                        self.disableAllCircuits()
                        postUpdate("Watering_Program_Start", OFF)

        return [activeStep[1] if activeStep != None else u"", remaining]
示例#16
0
    def execute(self, module, input):
        sendCommand("Light_FF_Floor_Hue_Brightness", 60)
        sendCommand("Light_SF_Bathroom_Ceiling", ON)
        sendCommand("Light_SF_Bathroom_Mirror", ON)
        sendCommand("Light_SF_Bedroom_Right", ON)

        states = [OFF, PercentType.ZERO]

        for child in getItem("Lights_FF").getAllMembers():
            if child.getState() not in states and child.getName(
            ) != "Light_FF_Floor_Hue_Brightness":
                sendCommand(child, OFF)

        #for child in getItem("Lights_SF").getAllMembers():
        #    if child.getState() not in states and child.getName() not in ["Light_SF_Bathroom_Mirror", "Light_SF_Bedroom_Right"]:
        #        sendCommand(child, OFF)

        sendCommand("Scene6", ON)
        postUpdate("Scene3", OFF)
示例#17
0
 def execute(self, module, input):
     postUpdate("Auto_Sunprotection", OFF)
 def callback(self):
     self.timer = None
     postUpdate("Dooropener_Timer", OFF)
    def execute(self, module, input):
        # only possible if we are present
        if getItemState("State_Presence").intValue() == 1:
            postUpdate("State_Presence", 2)

        postUpdate("Scene4", OFF)
 def execute(self, module, input):
     if getItemState("roomba_error") == ON:
         postUpdate("roomba_errorFormatted", getItemState("roomba_errortext").toString())
     else:
         postUpdate("roomba_errorFormatted", "Alles OK")
 def execute(self, module, input):
     state = getItemState("roomba_phase").toString()
     if state == "run":
         postUpdate("roomba_command", "start")
     elif state == "hmUsrDock":
         postUpdate("roomba_command", "pause")
     elif state == "hmMidMsn":
         postUpdate("roomba_command", "pause")
     elif state == "hmPostMsn":
         postUpdate("roomba_command", "dock")
     elif state == "charge":
         postUpdate("roomba_command", "dock")
     elif state == "stop":
         postUpdate("roomba_command", "stop")
     elif state == "pause":
         postUpdate("roomba_command", "pause")
     elif state == "stuck":
         postUpdate("roomba_command", "stop")
 def execute(self, module, input):
     postUpdate("roomba_sqm", u"{}".format( round(getItemState("roomba_sqft").doubleValue() / 10.76391041671) ))
示例#23
0
 def execute(self, module, input):
     postUpdate("Security_Last_Change", DateTimeType())
示例#24
0
 def execute(self, module, input):
     urllib2.urlopen("http://192.168.0.40:5000/reload").read()
     postUpdate("Scene7", OFF)
示例#25
0
 def execute(self, module, input):
     if autoChangeInProgress:
         global autoChangeInProgress
         autoChangeInProgress = False
     else:
         postUpdate("Ventilation_Auto_Mode", 0)
示例#26
0
 def execute(self, module, input):
     postUpdate(
         "TV_KEY_POWER",
         ON if input["event"].getStatusInfo().getStatus().toString()
         == "ONLINE" else OFF)
 def disableAllCircuits(self):
     for child in getGroupMember("Watering_Circuits"):
         sendCommand(child, OFF)
     postUpdate("Watering_Program_State", u"läuft nicht")
示例#28
0
    def execute(self, module, input):
        now = getNow()
        Aktuell_End = getItemState("Gas_Pulse_Counter").doubleValue()

        # Aktueller Zählerstand
        zaehlerStandCurrent = startGasMeterValue + (
            (Aktuell_End - startGasImpulseCounter) * 0.01)

        zaehlerStandSaved = getItemState("Gas_Current_Count").doubleValue()

        #self.log.info("{}".format(zaehlerStandCurrent))

        if zaehlerStandCurrent < zaehlerStandSaved:
            self.log.error("Consumption: Calculation is wrong {} {}".format(
                zaehlerStandCurrent, zaehlerStandSaved))
            return

        if zaehlerStandCurrent > zaehlerStandSaved:
            # Aktueller Zählerstand
            postUpdate("Gas_Current_Count", zaehlerStandCurrent)

        # *** Aktueller Verbrauch ***
        value5Min = getHistoricReference(self.log, "Gas_Current_Count", 300,
                                         615, 900, 300)
        postUpdateIfChanged("Gas_Current_Consumption", value5Min)

        # *** Aktueller Tagesverbrauch ***
        zaehlerStandOld = getHistoricItemState(
            "Gas_Current_Count", now.withTimeAtStartOfDay()).doubleValue()
        currentConsumption = zaehlerStandCurrent - zaehlerStandOld
        if currentConsumption < 0:
            currentConsumption = 0

        postUpdateIfChanged("Gas_Current_Daily_Consumption",
                            currentConsumption)

        # *** Jahresverbrauch ***
        zaehlerStandOld = getHistoricItemState(
            "Gas_Current_Count",
            now.withDate(now.getYear(), 1,
                         1).withTimeAtStartOfDay()).doubleValue()
        currentConsumption = zaehlerStandCurrent - zaehlerStandOld
        if currentConsumption < 0:
            currentConsumption = 0

        if postUpdateIfChanged("Gas_Annual_Consumption", currentConsumption):
            # Hochrechnung
            zaehlerStandCurrentOneYearBefore = getHistoricItemState(
                "Gas_Current_Count", now.minusYears(1)).doubleValue()
            forecastConsumtion = zaehlerStandOld - zaehlerStandCurrentOneYearBefore

            zaehlerStandOldOneYearBefore = getHistoricItemState(
                "Gas_Current_Count",
                now.withDate(now.getYear() - 1, 1,
                             1).withTimeAtStartOfDay()).doubleValue()

            hochrechnungVerbrauch = round(currentConsumption +
                                          forecastConsumtion)

            msg = u"{} m³, {} m³".format(
                hochrechnungVerbrauch,
                int(round(zaehlerStandOld - zaehlerStandOldOneYearBefore)))
            postUpdate("Gas_Forecast", msg)
示例#29
0
    def execute(self, module, input):
        if itemStateOlderThen("Bell_Last_Change", getNow().minusSeconds(30)):
            sendNotification("Klingel", "Es klingelt",
                             "https://smartmarvin.de/cameraStrasseImage")

        postUpdate("Bell_Last_Change", DateTimeType())