Exemplo n.º 1
0
 def execute(self, module, input):
     if getItemState("State_Presence").intValue() == 0 \
             and getItemState("roomba_auto") == ON \
             and getItemState("roomba_status").toString() == "Charging" \
             and getItemState("roomba_batPct").intValue() >= 100 \
             and getItemState("roomba_error") == OFF \
             and getItemState("roomba_full") == OFF:
         if itemLastUpdateOlderThen("roomba_cleaning_state", getNow().minusMinutes(360)) \
                 and itemLastUpdateOlderThen("State_Presence", getNow().minusMinutes(60)):
             sendCommand("roomba_command", "start")
    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)
Exemplo n.º 3
0
    def execute(self, module, input):
        if getItemState("Ventilation_Auto_Mode").intValue() != 1:
            return

        currentLevel = getItemState("Ventilation_Fan_Level").intValue()

        raumTemperatur = getItemState("Temperature_FF_Livingroom").doubleValue()
        zielTemperatur = getItemState("Ventilation_Comfort_Temperature").doubleValue
        
        presenceSate = getItemState("State_Presence").intValue()
        
        isTooWarm = raumTemperatur >= zielTemperatur
        coolingPossible = getItemState("Temperature_Garden").doubleValue() < raumTemperatur

        # Sleep
        if presenceSate == 2:
            reducedLevel = 2    # Level 1
            defaultLevel = 2    # Level 1
            coolingLevel = 2    # Level 1
        # Away since 30 minutes
        elif presenceSate == 0 and itemLastUpdateOlderThen("State_Presence", getNow().minusMinutes(60)):
            reducedLevel = 1    # Level A
            defaultLevel = 2    # Level 1
            coolingLevel = 3    # Level 2
        else:
            reducedLevel = 2    # Level 1
            defaultLevel = 3    # Level 2
            coolingLevel = 3    # Level 2
            
        # reducedLevel if it is too warm inside and also outside
        # coolingLevel if it is too warm inside but outside colder then inside
        newLevel = (coolingLevel if coolingPossible else reducedLevel) if isTooWarm else defaultLevel

        if newLevel != currentLevel:
            # Wenn der aktuelle Level Stufe 'A' (also 1) ist, sollte vor einem erneuten umschalten gewartet werden damit ein
            # hin und herschalten vermieden wird. z.B. bei kurzzeitigen Temperaturschwankungen
            if currentLevel == 1:
                waitBeforeChange = 15
            else:
                # must be > 1. Otherwise cangedSince dows not work propperly
                waitBeforeChange = 2

            if itemLastUpdateOlderThen("Ventilation_Fan_Level", getNow().minusMinutes(waitBeforeChange)):
                global autoChangeInProgress
                autoChangeInProgress = True

                sendCommand("Ventilation_Fan_Level", newLevel)
 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")
Exemplo n.º 5
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")
Exemplo n.º 6
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)
 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()
    def execute(self, module, input):
        group = u"Fehler"
        active = []

        if getItemState("Ventilation_Filter_Error_I").intValue() > 0 \
                or getItemState("Ventilation_Filter_Error_E").intValue() > 0 \
                or getItemState("Ventilation_Error_Message").toString() != "Ok":
            active.append(u"Lüftung")

        if getItemState("Heating_Common_Fault").intValue() > 0:
            active.append(u"Heizung")

        if getItemState("State_Server").intValue() > 1:
            active.append(u"Server")

        refDate = getNow().minusMinutes(1440)  # last 24 hours

        if itemLastUpdateOlderThen("Temperature_FF_Livingroom", refDate) \
                or itemLastUpdateOlderThen("Temperature_FF_Boxroom", refDate) \
                or itemLastUpdateOlderThen("Temperature_FF_Guestroom", refDate) \
                or itemLastUpdateOlderThen("Temperature_FF_GuestWC", refDate) \
                or itemLastUpdateOlderThen("Temperature_FF_Floor", refDate) \
                or itemLastUpdateOlderThen("Temperature_FF_Utilityroom", refDate) \
                or itemLastUpdateOlderThen("Temperature_FF_Garage", refDate) \
                or itemLastUpdateOlderThen("Temperature_SF_Bedroom", refDate) \
                or itemLastUpdateOlderThen("Temperature_SF_Dressingroom", refDate) \
                or itemLastUpdateOlderThen("Temperature_SF_Child1", refDate) \
                or itemLastUpdateOlderThen("Temperature_SF_Child2", refDate) \
                or itemLastUpdateOlderThen("Temperature_SF_Bathroom", refDate) \
                or itemLastUpdateOlderThen("Temperature_SF_Floor", refDate) \
                or itemLastUpdateOlderThen("Temperature_SF_Attic", refDate):
            active.append("Sensors")

        if len(active) == 0:
            active.append(u"Alles normal")
            group = u"Info"

        msg = u", ".join(active)

        if postUpdateIfChanged("MainStatus", msg):
            sendNotification(group, msg)