示例#1
0
 def execute(self, module, input):
     if getItemState(
             "pOther_Manual_State_Auto_Lighting") == ON and getItemState(
                 "pOther_Presence_State").intValue(
                 ) == PresenceHelper.STATE_AWAY:
         sendCommand("pGF_Corridor_Light_Hue_Color", 30)
         sendCommand("pGF_Livingroom_Light_Hue4_Color", 30)
示例#2
0
    def execute(self, module, input):
        now = ZonedDateTime.now()

        if itemStateOlderThen("Dawn_Time", now) and itemStateNewerThen(
                "Dusk_Time", now):
            # triggers solar value update
            sendCommand("Solar_Total_Yield", REFRESH)

            sendCommand("Solar_AC_Power", REFRESH)

            acPower = getItemState('Solar_AC_Power').intValue()
            dailyConsumption = getItemState("Solar_Daily_Yield").doubleValue()

            msg = "{} W, {:.2f} kWh".format(acPower, dailyConsumption)

            if itemLastUpdateOlderThen(
                    "Solar_Total_Yield",
                    now.minusMinutes(15)) and itemStateOlderThen(
                        "Dawn_Time", now.minusMinutes(60)):
                self.log.error("Solar values not updated")

        else:
            msg = "Inaktiv"

        postUpdateIfChanged("Solar_Message", msg)
示例#3
0
    def execute(self, module, input):
        if getItemState("pOther_Manual_State_Auto_Rollershutter") != ON:
            return

        contactItemName = input['event'].getItemName()

        if contactItemName not in contact_map:
            return

        config = contact_map[contactItemName]

        state = None
        if input['event'].getItemState() == OPEN:
            state = UP
        else:
            if getItemState("pOther_Automatic_State_Rollershutter").intValue(
            ) == SunProtectionHelper.STATE_ROLLERSHUTTER_DOWN:
                # check that more windows are DOWN than UP.
                #closedShutters = 0
                #for _config in configs:
                #    if getItemState(_config["shutter"]).intValue() == 100:
                #        closedShutters += 1
                #if closedShutters >= math.floor( len(configs) / 2 ):
                state = DOWN
            elif ("sunprotection" in config
                  and getItemState(config["sunprotection"]) == ON
                  and "sunprotectionOnlyIfAway" not in config):
                state = DOWN

        if state is None:
            return

        sendCommand(config["shutter"], state)
示例#4
0
    def execute(self, module, input):
        global ruleTimeouts
        now = ZonedDateTime.now()
        last = ruleTimeouts.get("Livingroom_Hue_Color_Backward", now)

        if ChronoUnit.SECONDS.between(last, now) > 1:
            postUpdate("pGF_Livingroom_Light_Hue_Scene", "")
            sendCommand("pOther_Manual_State_Lightprogram", 0)
示例#5
0
    def execute(self, module, input):
        sendCommand("pOutdoor_Carport_Automatic_Switch", OFF)
        sendCommand("pOutdoor_Streedside_Frontdoor_Automatic_Switch", OFF)
        sendCommand("pOutdoor_Terrace_Automatic_Switch", OFF)
        sendCommand("pOutdoor_Streedside_Garage_Automatic_Switch", OFF)
        sendCommand("pOutdoor_Garden_Garage_Automatic_Switch", ON)

        postUpdate("pOther_Scene5", OFF)
示例#6
0
 def execute(self, module, input):
     if getItemState("pOther_Presence_State").intValue() == PresenceHelper.STATE_AWAY and itemLastChangeOlderThen("pOther_Presence_State", ZonedDateTime.now().minusMinutes(60)) \
             and getItemState("pIndoor_Roomba_auto") == ON \
             and getItemState("pIndoor_Roomba_status").toString() == "Charging" \
             and getItemState("pIndoor_Roomba_batPct").intValue() >= 100 \
             and getItemState("pIndoor_Roomba_error") == OFF \
             and getItemState("pIndoor_Roomba_full") == OFF \
             and itemLastChangeOlderThen("pIndoor_Roomba_cleaning_state", ZonedDateTime.now().minusMinutes(360)):
         sendCommand("pIndoor_Roomba_command", "start")
示例#7
0
    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("pOther_Scene6", OFF)
示例#8
0
    def findStep(self):
        duration = getItemState(
            "pOutdoor_Watering_Logic_Program_Duration").intValue() * 60.0

        remaining = 0
        info = u""

        # detect current active index
        activeIndex = -1
        for i in range(len(circuits)):
            group = circuits[i]
            if getItemState(group[2][0] + "_Powered") == ON:
                activeIndex = i
                runtime = ChronoUnit.SECONDS.between(
                    getItemLastChange(group[2][0] + "_Powered"),
                    ZonedDateTime.now())
                remaining = (duration * group[0]) - runtime
                break

        if remaining <= 0:
            nextIndex = -1

            # detect next index
            for i in range(len(circuits)):
                if activeIndex != -1 and i <= activeIndex:
                    continue
                group = circuits[i]
                for circuit in group[2]:
                    if getItemState(circuit + "_Auto") == ON:
                        nextIndex = i
                        break
                if nextIndex != -1:
                    break

            if nextIndex == -1:
                self.disableAllCircuits()
                postUpdate("pOutdoor_Watering_Logic_Program_Start", OFF)
            else:
                for circuit in circuits[nextIndex][2]:
                    if getItemState(circuit + "_Auto") == ON:
                        sendCommand(circuit + "_Powered", ON)

                nextGroup = circuits[nextIndex]

                remaining = (duration * nextGroup[0])
                info = nextGroup[1]

                # deactivate current index
                if activeIndex != -1:
                    for circuit in circuits[activeIndex][2]:
                        sendCommand(circuit + "_Powered", OFF)
        else:
            info = circuits[activeIndex][1]

        return [info, remaining]
示例#9
0
    def execute(self, module, input):
        if self.timer is not None:
            self.timer.cancel()
            self.timer = None

        #self.log.info("{}".format(input["newState"]))

        if input["newState"] == ON:
            sendCommand("pOutdoor_Streedside_Gardendoor_Opener_Powered", ON)
            self.timer = startTimer(self.log, 3.0, self.callback)
        else:
            sendCommandIfChanged(
                "pOutdoor_Streedside_Gardendoor_Opener_Powered", OFF)
示例#10
0
    def execute(self, module, input):
        sendCommand("pGF_Corridor_Light_Ceiling_Powered", ON)
        sendCommand("pFF_Bathroom_Light_Ceiling_Powered", ON)
        sendCommand("pFF_Bathroom_Light_Mirror_Powered", ON)
        sendCommand("pFF_Bedroom_Light_Ceiling_Powered", ON)

        postUpdate("pOther_Scene2", OFF)
示例#11
0
 def execute(self, module, input):
     if getItemState(
             "pOther_Automatic_State_Sunprotection_Terrace").intValue(
             ) == SunProtectionHelper.STATE_TERRACE_MAYBE_CLOSED:
         pass
     elif getItemState(
             "pOther_Automatic_State_Sunprotection_Terrace").intValue(
             ) == SunProtectionHelper.STATE_TERRACE_CLOSED:
         # DOWN only if automatic is enabled and (people are present or where present changed recently or terrace door is open)
         if (getItemState("pOther_Manual_State_Auto_Sunprotection") == ON
                 and
             (getItemState("pOther_Presence_State").intValue() not in [
                 PresenceHelper.STATE_AWAY,
                 PresenceHelper.STATE_MAYBE_PRESENT
             ] or itemLastChangeNewerThen(
                 "pOther_Presence_State",
                 ZonedDateTime.now().minusMinutes(120)) or getItemState(
                     "pGF_Livingroom_Openingcontact_Window_Terrace_State")
              == OPEN)):
             #self.log.info(u"down")
             sendCommand("pOutdoor_Terrace_Shading_Left_Control", DOWN)
             sendCommand("pOutdoor_Terrace_Shading_Right_Control", DOWN)
     else:
         #self.log.info(u"up")
         # UP always when sun protection time is over
         sendCommand("pOutdoor_Terrace_Shading_Left_Control", UP)
         sendCommand("pOutdoor_Terrace_Shading_Right_Control", UP)
示例#12
0
    def _setCurrentColors(self, data):
        global ruleTimeouts
        ruleTimeouts["Livingroom_Hue_Color_Backward"] = ZonedDateTime.now()

        sendCommand("pGF_Livingroom_Light_Hue1_Color",
                    u"{},{},{}".format(data[0][0], data[0][1], data[0][2]))
        sendCommand("pGF_Livingroom_Light_Hue2_Color",
                    u"{},{},{}".format(data[1][0], data[1][1], data[1][2]))
        sendCommand("pGF_Livingroom_Light_Hue3_Color",
                    u"{},{},{}".format(data[2][0], data[2][1], data[2][2]))
        sendCommand("pGF_Livingroom_Light_Hue4_Color",
                    u"{},{},{}".format(data[3][0], data[3][1], data[3][2]))
        sendCommand("pGF_Livingroom_Light_Hue5_Color",
                    u"{},{},{}".format(data[4][0], data[4][1], data[4][2]))
示例#13
0
    def execute(self, module, input):
        if getItemState("pOther_Manual_State_Auto_Rollershutter") != ON:
            return

        if getItemState("pOther_Automatic_State_Rollershutter").intValue(
        ) == SunProtectionHelper.STATE_ROLLERSHUTTER_DOWN:
            for config in configs:
                if getItemState(config["contact"]) != CLOSED:
                    continue
                sendCommand(config["shutter"], DOWN)
        elif getItemState("pOther_Presence_State").intValue(
        ) == PresenceHelper.STATE_AWAY and getItemState(
                "pOther_Automatic_State_Rollershutter").intValue(
                ) == SunProtectionHelper.STATE_ROLLERSHUTTER_UP:
            sendCommand("gShutters", UP)
示例#14
0
    def callback(self):
        if getItemState("pOther_Manual_State_Lightprogram").intValue() == 0:
            return

        color1 = getItemState("pGF_Livingroom_Light_Hue1_Color")
        color2 = getItemState("pGF_Livingroom_Light_Hue2_Color")
        color3 = getItemState("pGF_Livingroom_Light_Hue3_Color")
        color4 = getItemState("pGF_Livingroom_Light_Hue4_Color")
        color5 = getItemState("pGF_Livingroom_Light_Hue5_Color")

        global ruleTimeouts
        ruleTimeouts["Livingroom_Hue_Color_Backward"] = ZonedDateTime.now()

        sendCommand("pGF_Livingroom_Light_Hue1_Color", color2)
        sendCommand("pGF_Livingroom_Light_Hue2_Color", color3)
        sendCommand("pGF_Livingroom_Light_Hue3_Color", color4)
        sendCommand("pGF_Livingroom_Light_Hue4_Color", color5)
        sendCommand("pGF_Livingroom_Light_Hue5_Color", color1)

        self.timer = startTimer(self.log, self.timeout, self.callback)
示例#15
0
    def callback(self, entry):
        global timerMappings
        if getItemState(entry[1]) == ON:
            for motionDetectorItem in entry[2]:
                if getItemState(motionDetectorItem) == OPEN:
                    timerMappings[entry[0]] = startTimer(
                        self.log, timerDuration, self.callback, [entry])
                    return

            global ruleTimeouts
            ruleTimeouts["Light_Outdoor"] = ZonedDateTime.now()

            self.log.info(u"MotionDetectorRule: callback for {} => {}".format(
                entry[0], ruleTimeouts["Light_Outdoor"]))

            sendCommand(entry[0],
                        0 if getItem(entry[0]).getType() == "Dimmer" else OFF)
            timerMappings[entry[0]] = None
        else:
            timerMappings[entry[0]] = None
示例#16
0
    def execute(self, module, input):
        itemName = input['event'].getItemName()

        entry = manualMappings[self.triggerMappings[itemName]]
        if getItemState("pOther_Automatic_State_Outdoorlights"
                        ) == ON and getItemState(entry[1]) == ON:
            timerMappings[entry[0]] = startTimer(self.log,
                                                 timerDuration,
                                                 self.callback, [entry],
                                                 oldTimer=timerMappings.get(
                                                     entry[0]))

            global ruleTimeouts
            ruleTimeouts["Light_Outdoor"] = ZonedDateTime.now()

            self.log.info(u"MotionDetectorRule: execute for {} => {}".format(
                entry[0], ruleTimeouts["Light_Outdoor"]))

            sendCommand(entry[0],
                        100 if getItem(entry[0]).getType() == "Dimmer" else ON)
    def execute(self, module, input):
        hour = ZonedDateTime.now().getHour()

        state = getItemState(
            "pOther_Manual_State_Auto_Attic_Light").intValue()

        if state == 2:
            if hour == 5:
                sendCommand("pFF_Attic_Socket_Powered", ON)
            elif hour == 23:
                sendCommand("pFF_Attic_Socket_Powered", OFF)
        elif state == 3:
            if hour == 8:
                sendCommand("pFF_Attic_Socket_Powered", ON)
            elif hour == 20:
                sendCommand("pFF_Attic_Socket_Powered", OFF)
示例#18
0
    def execute(self, module, input):
        if getItemState("pOther_Manual_State_Auto_Rollershutter") != ON:
            return

        sunprotectionItemName = input['event'].getItemName()
        configs = sunprotection_map[sunprotectionItemName]
        state = DOWN if input['event'].getItemState() == ON else UP

        for config in configs:
            if state == DOWN:
                # shutdown shutters only if the window is closed
                if getItemState(config["contact"]) != CLOSED:
                    continue

                # skip closing shutters if we must be away but we are still present or not long enough away
                if "sunprotectionOnlyIfAway" in config and (
                        getItemState("pOther_Presence_State").intValue() !=
                        PresenceHelper.STATE_AWAY or itemLastChangeNewerThen(
                            "pOther_Presence_State",
                            ZonedDateTime.now().minusSeconds(1800))):
                    continue

            sendCommand(config["shutter"], state)
示例#19
0
    def execute(self, module, input):
        if getItemState("pOther_Manual_State_Auto_Christmas") != ON:
            return

        if input['event'].getItemName(
        ) == "pOther_Automatic_State_Outdoorlights":
            if input["event"].getItemState() == ON:
                sendCommand("pOutdoor_Streeside_Socket_Powered", ON)
            else:
                sendCommand("pOutdoor_Streeside_Socket_Powered", OFF)
        else:
            if input["event"].getItemState().intValue(
            ) == PresenceHelper.STATE_PRESENT:
                if getItemState("pOther_Automatic_State_Outdoorlights") == ON:
                    sendCommand("pOutdoor_Streeside_Socket_Powered", ON)
            elif input["event"].getItemState().intValue(
            ) == PresenceHelper.STATE_SLEEPING:
                sendCommand("pOutdoor_Streeside_Socket_Powered", OFF)
示例#20
0
    def execute(self, module, input):
        sendCommand("gGF_Livingroom_Light_Hue_Color", 60)

        states = [OFF, PercentType.ZERO]

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

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

        postUpdate("pOther_Scene1", OFF)
示例#21
0
 def disableAllCircuits(self):
     for child in getGroupMember("gOutdoor_Watering_Circuits"):
         sendCommand(child, OFF)
     postUpdate("pOutdoor_Watering_Logic_Program_State", u"läuft nicht")
示例#22
0
 def execute(self, module, input):
     if input["event"].getItemCommand() == ON:
         sendCommand("pGF_Livingroom_Television_KeyPOWER_ON",ON)
     else:
         pass
    def execute(self, module, input):
        if 'event' in input.keys() and input['event'].getItemName(
        ) == "pGF_Utilityroom_Ventilation_Fan_Level":
            if self.autoChangeInProgress:
                self.autoChangeInProgress = False
            else:
                postUpdate("pGF_Utilityroom_Ventilation_Auto_Mode", OFF)
            return

        if getItemState("pGF_Utilityroom_Ventilation_Auto_Mode") == OFF:
            return

        if isinstance(
                getItemState("pGF_Utilityroom_Ventilation_Fan_Level"),
                UnDefType) or isinstance(
                    getItemState(
                        "pGF_Utilityroom_Ventilation_Comfort_Temperature"),
                    UnDefType):
            return

        currentLevel = getItemState(
            "pGF_Utilityroom_Ventilation_Fan_Level").intValue()
        if self.activeLevel == -1:
            self.activeLevel = currentLevel

        raumTemperatur = getItemState(
            "pGF_Livingroom_Air_Sensor_Temperature_Value").doubleValue()
        zielTemperatur = getItemState(
            "pGF_Utilityroom_Ventilation_Comfort_Temperature").doubleValue

        presenceState = getItemState("pOther_Presence_State").intValue()

        isTooWarm = raumTemperatur >= zielTemperatur

        outdoorTemperatureItemName = getItemState(
            "pOutdoor_WeatherStation_Temperature_Item_Name").toString()
        coolingPossible = getItemState(
            outdoorTemperatureItemName).doubleValue() < raumTemperatur

        # Sleep
        if presenceState in [
                PresenceHelper.STATE_MAYBE_SLEEPING,
                PresenceHelper.STATE_SLEEPING
        ]:
            reducedLevel = 2  # Level 1
            defaultLevel = 2  # Level 1
            coolingLevel = 2  # Level 1
        # Away since 60 minutes
        elif presenceState == [
                PresenceHelper.STATE_AWAY, PresenceHelper.STATE_MAYBE_PRESENT
        ] and itemLastChangeOlderThen("pOther_Presence_State",
                                      ZonedDateTime.now().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 changedSince does not work properly
                waitBeforeChange = 2

            # 1. self.activeLevel != currentLevel means last try was not successful
            # 2. 'event' in input.keys() is an presence or auto mode change
            # 3. is cron triggered event
            if self.activeLevel != currentLevel or 'event' in input.keys(
            ) or itemLastChangeOlderThen(
                    "pGF_Utilityroom_Ventilation_Fan_Level",
                    ZonedDateTime.now().minusMinutes(waitBeforeChange)):
                self.autoChangeInProgress = True

                sendCommand("pGF_Utilityroom_Ventilation_Fan_Level", newLevel)
                self.activeLevel = newLevel
 def execute(self, module, input):
     if input["newState"] == OPEN:
         sendCommand("pGF_Livingroom_Socket_Bassbox_Powered", ON)
     else:
         sendCommand("pGF_Livingroom_Socket_Bassbox_Powered", OFF)
示例#25
0
    def execute(self, module, input):

        now = ZonedDateTime.now()

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

        currentPowerLimitation = getItemStateWithFallback(
            "pGF_Garage_Solar_Inverter_Power_Limitation",
            DecimalType(0)).intValue()

        currentConsumptionValue = getItemState(
            "pGF_Utilityroom_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),
                    ChronoUnit.MILLIS.between(self.lastLimitationIncrease,
                                              now)))

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

            if len(input) == 0 and itemLastChangeOlderThen(
                    "pGF_Garage_Solar_Inverter_Power_Limitation",
                    ZonedDateTime.now().minusMinutes(4)):
                sendCommand("pGF_Garage_Solar_Inverter_Power_Limitation",
                            currentPowerLimitation)
                self.log.info(u"Refresh power limitation of {}%".format(
                    currentPowerLimitation))
        elif currentPowerLimitation != 100:
            postUpdate("pGF_Garage_Solar_Inverter_Power_Limitation", 100)
            self.log.info(u"Shutdown power limitation")
示例#26
0
    def execute(self, module, input):
        if getItemState("pOther_Manual_State_Auto_Christmas") != ON:
            return

        if input["event"].getItemState().intValue(
        ) == PresenceHelper.STATE_PRESENT:
            sendCommand("pGF_Corridor_Socket_Powered", ON)
            sendCommand("pGF_Livingroom_Socket_Couch_Powered", ON)
            sendCommand("pGF_Livingroom_Socket_Fireplace_Powered", ON)
            sendCommand("pMobile_Socket_1_Powered", ON)
            sendCommand("pMobile_Socket_2_Powered", ON)
            sendCommand("pMobile_Socket_3_Powered", ON)
            sendCommand("pMobile_Socket_4_Powered", ON)

        elif input["event"].getItemState().intValue() in [
                PresenceHelper.STATE_AWAY, PresenceHelper.STATE_SLEEPING
        ]:
            sendCommand("pGF_Corridor_Socket_Powered", OFF)
            sendCommand("pGF_Livingroom_Socket_Couch_Powered", OFF)
            sendCommand("pGF_Livingroom_Socket_Fireplace_Powered", OFF)
            sendCommand("pMobile_Socket_1_Powered", OFF)
            sendCommand("pMobile_Socket_2_Powered", OFF)
            sendCommand("pMobile_Socket_3_Powered", OFF)
            sendCommand("pMobile_Socket_4_Powered", OFF)
示例#27
0
 def execute(self, module, input):
     if getItemState("pOther_Automatic_State_Solar") == ON:
         # triggers solar value update
         sendCommand("pGF_Garage_Solar_Inverter_Total_Yield", REFRESH)
示例#28
0
    def execute(self, module, input):
        if input["event"].getItemName(
        ) == "pGF_Garage_Solar_Inverter_AC_Power":
            self.updateConsumption(input['event'].getItemState().intValue())
        else:
            if input["event"].getItemName(
            ) == "pGF_Utilityroom_Power_Demand_Active":
                self.powerDemand = input["event"].getItemState().intValue()
                self.powerSupply = getItemState(
                    "pGF_Utilityroom_Power_Supply_Active").intValue()

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

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

            self.currentDemand = self.powerDemand - self.powerSupply

            #self.log.info(u"{}".format(itemLastUpdateOlderThen("pGF_Garage_Solar_Inverter_Total_Yield", ZonedDateTime.now().minusMinutes(15))))

            if getItemState("pOther_Automatic_State_Solar") == ON:
                if itemLastUpdateOlderThen(
                        "pOther_Automatic_State_Solar",
                        ZonedDateTime.now().minusMinutes(60)):
                    # solar value update was not successful for a while
                    #solarActive = getItemState("pOther_Automatic_State_Solar") == ON
                    #if itemLastUpdateOlderThen("pGF_Garage_Solar_Inverter_Total_Yield", ZonedDateTime.now().minusHours(5) if solarActive else ZonedDateTime.now().minusHours(14)):
                    if (itemLastUpdateOlderThen(
                            "pGF_Garage_Solar_Inverter_Total_Yield",
                            ZonedDateTime.now().minusMinutes(15)) or
                        (itemLastUpdateOlderThen(
                            "pGF_Garage_Solar_Inverter_AC_Power",
                            ZonedDateTime.now().minusMinutes(60))
                         and getItemState("pGF_Garage_Solar_Inverter_AC_Power"
                                          ).intValue() > 0)):
                        #  and
                        #(itemLastUpdateOlderThen("pGF_Garage_Solar_Inverter_AC_Power", ZonedDateTime.now().minusMinutes(15)) or getItemState("pGF_Garage_Solar_Inverter_AC_Power").intValue() == 0)):
                        if postUpdateIfChanged(
                                "pGF_Garage_Solar_Inverter_Is_Working", OFF):
                            postUpdate("pGF_Garage_Solar_Inverter_AC_Power", 0)
                            postUpdateIfChanged(
                                "pGF_Garage_Solar_Inverter_DC_Power", 0)
                            postUpdateIfChanged(
                                "pGF_Garage_Solar_Inverter_DC_Current", 0)
                            postUpdateIfChanged(
                                "pGF_Garage_Solar_Inverter_DC_Voltage", 0)
                            postUpdateIfChanged(
                                "pGF_Garage_Solar_Inverter_Daily_Yield", 0)
                    else:
                        postUpdateIfChanged(
                            "pGF_Garage_Solar_Inverter_Is_Working", ON)

                # triggers solar value update
                sendCommand("pGF_Garage_Solar_Inverter_AC_Power", REFRESH)
            else:
                self.updateConsumption(0)
                postUpdateIfChanged("pGF_Garage_Solar_Inverter_Is_Working", ON)
            postUpdateIfChanged("pGF_Utilityroom_Electricity_Current_Demand",
                                self.currentDemand)
示例#29
0
 def execute(self, module, input):
     if getItemState(
             "pOther_Manual_State_Auto_Lighting") == ON and getItemState(
                 "pOther_Presence_State").intValue(
                 ) == PresenceHelper.STATE_AWAY:
         sendCommand("pGF_Corridor_Light_Ceiling_Powered", OFF)
示例#30
0
    def execute(self, module, input):
        sendCommand("pGF_Corridor_Light_Hue_Color", 60)
        sendCommand("pFF_Bathroom_Light_Ceiling_Powered", ON)
        sendCommand("pFF_Bathroom_Light_Mirror_Powered", ON)
        sendCommand("pFF_Bedroom_Light_Hue_Right_Switch", ON)

        states = [OFF, PercentType.ZERO]

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

        #for child in getItem("gFF_Lights").getAllMembers():
        #    if child.getState() not in states and child.getName() not in ["pFF_Bathroom_Light_Mirror_Powered", "pFF_Bedroom_Light_Hue_Right_Switch"]:
        #        sendCommand(child, OFF)

        sendCommand("pOther_Scene6", ON)
        postUpdate("pOther_Scene3", OFF)