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): 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): 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 getHistoricReference(log, itemName, valueTime, outdatetTime, messureTime, intervalTime): endTime = getItemLastUpdate(itemName) endTimestampInMillis = endTime.getMillis() nowInMillis = getNow().getMillis() if endTimestampInMillis < nowInMillis - (outdatetTime * 1000): log.info(u"No consumption. Last value is too old.") return 0 minMessuredTimestampInMillis = nowInMillis - (messureTime * 1000) endValue = getItemState(itemName).doubleValue() startTimestampInMillis = endTimestampInMillis startValue = 0 currentTime = DateTime(startTimestampInMillis - 1) itemCount = 0 while True: itemCount = itemCount + 1 historicEntry = getHistoricItemEntry(itemName, currentTime) startValue = historicEntry.getState().doubleValue() _millis = historicEntry.getTimestamp().getTime() # current item is older then the allowed timeRange if _millis < minMessuredTimestampInMillis: log.info(u"Consumption time limit exceeded") startTimestampInMillis = startTimestampInMillis - (intervalTime * 1000) if _millis > startTimestampInMillis: startTimestampInMillis = _millis break # 2 items are enough to calculate with elif itemCount >= 2: log.info(u"Consumption max item count exceeded") startTimestampInMillis = _millis break else: startTimestampInMillis = _millis currentTime = DateTime(startTimestampInMillis - 1) durationInSeconds = round( float(endTimestampInMillis - startTimestampInMillis) / 1000.0) value = ((endValue - startValue) / durationInSeconds) * valueTime if value < 0: value = 0 startTime = DateTime(startTimestampInMillis) log.info(u"Consumption {} messured from {} ({}) to {} ({})".format( value, startValue, dateTimeFormatter.print(startTime), endValue, dateTimeFormatter.print(endTime))) return value
def execute(self, module, input): global ruleTimeouts now = getNow().getMillis() last = ruleTimeouts.get("Livingroom_Hue_Color_Backward",0) if now - last > 1000: sendCommand("State_Lightprogram", 0)
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): global ruleTimeouts now = getNow().getMillis() last = ruleTimeouts.get("Motiondetector_Outdoor_Main_Switch", 0) if now - last > 1000: itemState = input["event"].getItemState() if itemState == ON: ruleTimeouts["Light_Outdoor"] = now sendCommandIfChanged("Light_Outdoor_Garage_Streedside", OFF) sendCommandIfChanged("Light_Outdoor_Frontdoor", OFF) sendCommandIfChanged("Light_Outdoor_Carport", OFF) sendCommandIfChanged("Light_Outdoor_Terrace", 0) sendCommandIfChanged("Light_Outdoor_Garage_Gardenside", OFF) #ruleTimeouts["Motiondetector_Outdoor_Individual_Switches"] = now postUpdateIfChanged( "Motiondetector_Outdoor_Garage_Streetside_Switch", itemState) postUpdateIfChanged("Motiondetector_Outdoor_Frontdoor_Switch", itemState) postUpdateIfChanged("Motiondetector_Outdoor_Carport_Switch", itemState) postUpdateIfChanged("Motiondetector_Outdoor_Terrace_Switch", itemState) postUpdateIfChanged( "Motiondetector_Outdoor_Garage_Gardenside_Switch", itemState)
def execute(self, module, input): #self.log.info(u"{}".format(input)) global ruleTimeouts now = getNow().getMillis() last = ruleTimeouts.get("Light_Outdoor", 0) # No Motion Detector related events if now - last > 1000: itemName = input['event'].getItemName() global timerMappings timer = timerMappings.get(itemName) if timer is not None: timer.cancel() for i, entry in enumerate(manualMappings): if entry[0] == itemName: #ruleTimeouts["Motiondetector_Outdoor_Individual_Switches"] = now if postUpdateIfChanged(entry[1], OFF): ruleTimeouts[ "Motiondetector_Outdoor_Main_Switch"] = now # must be a command to inform physical knx switch sendCommandIfChanged("Motiondetector_Outdoor_Switch", OFF) #self.log.info(u"{} {}".format(itemName,now-last)) break
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 _setCurrentColors(self,data): global ruleTimeouts ruleTimeouts["Livingroom_Hue_Color_Backward"] = getNow().getMillis() sendCommand("Light_FF_Livingroom_Hue_Color1",u"{},{},{}".format(data[0][0],data[0][1],data[0][2])) sendCommand("Light_FF_Livingroom_Hue_Color2",u"{},{},{}".format(data[1][0],data[1][1],data[1][2])) sendCommand("Light_FF_Livingroom_Hue_Color3",u"{},{},{}".format(data[2][0],data[2][1],data[2][2])) sendCommand("Light_FF_Livingroom_Hue_Color4",u"{},{},{}".format(data[3][0],data[3][1],data[3][2])) sendCommand("Light_FF_Livingroom_Hue_Color5",u"{},{},{}".format(data[4][0],data[4][1],data[4][2]))
def execute(self, module, input): start = getHistoricItemState( "Heating_Solar_Hours", getNow().withTimeAtStartOfDay()).intValue() aktuell = getItemState("Heating_Solar_Hours").intValue() if start > 0 and aktuell > 0: differenz = aktuell - start msg = u"{} h, {} h".format(differenz, aktuell) postUpdateIfChanged("Heating_Solar_Hours_Message", msg)
def execute(self, module, input): start = getHistoricItemState( "Heating_Burner_Starts", getNow().withTimeAtStartOfDay()).intValue() aktuell = getItemState("Heating_Burner_Starts").intValue() if start > 0 and aktuell > 0: differenz = aktuell - start postUpdate("Heating_Burner_Starts_Current_Daily", differenz) msg = u"{}, {}".format(differenz, aktuell) postUpdateIfChanged("Heating_Burner_Starts_Message", msg)
def findStep(self): duration = getItemState( "Watering_Program_Duration").intValue() * 60.0 * 1000.0 remaining = 0 info = u"" if getItemState("Watering_Circuits") == OFF: for group in circuits: #self.log.info("start " + loop[0][0]) isActive = False for circuit in group[2]: if getItemState(circuit + "_Auto") == ON: sendCommand(circuit, ON) isActive = True if isActive: remaining = (duration * group[0]) info = group[1] break else: activeIndex = -1 activeGroup = None for i in range(len(circuits)): group = circuits[i] if getItemState(group[2][0]) == ON: activeIndex = i activeGroup = group break if activeGroup != None: runtime = getNow().getMillis() - getItemLastUpdate( activeGroup[2][0]).getMillis() remaining = (duration * activeGroup[0]) - runtime if remaining <= 0: activeIndex += 1 if activeIndex < len(circuits): for circuit in circuits[activeIndex][2]: sendCommand(circuit, ON) for circuit in activeGroup[2]: sendCommand(circuit, OFF) activeGroup = circuits[activeIndex] remaining = (duration * activeGroup[0]) info = activeGroup[1] else: self.disableAllCircuits() postUpdate("Watering_Program_Start", OFF) else: info = activeGroup[1] return [info, remaining]
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): now = getNow() currentSupply = getItemState("Electricity_Total_Supply").doubleValue() currentYield = getItemState("Solar_Total_Yield").doubleValue() # Tagesverbrauch startSupply = getHistoricItemState( "Electricity_Total_Supply", now.withTimeAtStartOfDay()).doubleValue() startYield = getHistoricItemState( "Solar_Total_Yield", now.withTimeAtStartOfDay()).doubleValue() # sometimes solar converter is providing wrong value. Mostly if he is inactive in the night if currentYield > 1000000000 or startYield > 1000000000: # can be INFO because it is a 'normal' behavior of this solar converter self.log.info( u"Wrong Solar Value: currentYield is {}, startYield is {}". format(currentYield, startYield)) return totalSupply = currentSupply - startSupply totalYield = currentYield - startYield dailyConsumption = totalYield - totalSupply postUpdateIfChanged("Solar_Daily_Yield", totalYield) #self.log.info(u"A {} {}".format(currentSupply,currentYield)) #self.log.info(u"B {} {}".format(startSupply,startYield)) #self.log.info(u"C {} {}".format(totalSupply,totalYield)) postUpdateIfChanged("Solar_Daily_Consumption", dailyConsumption) # Jahresverbrauch startSupply = getHistoricItemState( "Electricity_Total_Supply", now.withDate(now.getYear(), 1, 1).withTimeAtStartOfDay()).doubleValue() startYield = getHistoricItemState( "Solar_Total_Yield", now.withDate(now.getYear(), 1, 1).withTimeAtStartOfDay()).doubleValue() totalSupply = currentSupply - startSupply totalYield = currentYield - startYield annualConsumption = totalYield - totalSupply #self.log.info(u"D {} {}".format(startSupply,startYield)) #self.log.info(u"E {}".format(annualConsumption)) postUpdateIfChanged("Solar_Annual_Consumption", annualConsumption)
def execute(self, module, input): zaehlerNeu = getItemState("Rain_Garden_Counter").intValue() zaehlerAlt = getHistoricItemState("Rain_Garden_Counter", getNow().minusHours(1)).intValue() lastHourRain = 0 if zaehlerAlt != zaehlerNeu: differenz = zaehlerNeu - zaehlerAlt if differenz < 0: differenz = zaehlerNeu lastHourRain = float(differenz) * 295.0 / 1000.0 postUpdateIfChanged("Rain_Garden_Current", lastHourRain)
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 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): hour = getNow().getHourOfDay() state = getItemState("Auto_Attic_Light").intValue() if state == 2: if hour == 5: sendCommand("Socket_Attic", ON) elif hour == 23: sendCommand("Socket_Attic", OFF) elif state == 3: if hour == 8: sendCommand("Socket_Attic", ON) elif hour == 20: sendCommand("Socket_Attic", OFF)
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
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)
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 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 execute(self, module, input): global ruleTimeouts ruleTimeouts["Livingroom_Hue_Color_Backward"] = getNow().getMillis() command = input['event'].getItemCommand() colors = command.toString().split(",") red = round(float(colors[0])) green = round(float(colors[1])) blue = round(float(colors[1])) command = u"{},{},{}".format(red,green,blue) sendCommand("Light_FF_Livingroom_Hue_Color1", command) sendCommand("Light_FF_Livingroom_Hue_Color2", command) sendCommand("Light_FF_Livingroom_Hue_Color3", command) sendCommand("Light_FF_Livingroom_Hue_Color4", command) sendCommand("Light_FF_Livingroom_Hue_Color5", command) sendCommand("State_Lightprogram", 0)
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)
def execute(self, module, input): now = getNow() # Dawn_Time # Sunrise_Time # Sunset_Time # Dusk_Time cloudCover = getItemState("Cloud_Cover_Current").intValue() if getItemState("State_Rollershutter") == ON: _upTime = getItemState("Sunrise_Time").calendar.getTimeInMillis() _upTime = int(_upTime + ( cloudCover * 30.0 / 9.0 ) * 60 * 1000) _lastDownTime = getItemState("State_Rollershutter_Down").calendar.getTimeInMillis() if now.getMillis() > _upTime and _upTime > _lastDownTime: postUpdate("State_Rollershutter", OFF) postUpdateIfChanged("State_Rollershutter_Up", DateTime(_upTime).toString() ) else: _downTime = getItemState("Dusk_Time").calendar.getTimeInMillis() _downTime = int(_downTime - ( cloudCover * 30.0 / 9.0 ) * 60 * 1000) if now.getMillis() > _downTime: postUpdate("State_Rollershutter", ON) postUpdateIfChanged("State_Rollershutter_Down", DateTime(_downTime).toString() ) if itemStateOlderThen("Sunset_Time", now) or itemStateNewerThen("Sunrise_Time", now): postUpdateIfChanged("State_Outdoorlights", ON) else: postUpdateIfChanged("State_Outdoorlights", OFF) if itemStateOlderThen("Dusk_Time", now) or itemStateNewerThen("Dawn_Time", now): postUpdateIfChanged("State_Solar", OFF) else: postUpdateIfChanged("State_Solar", ON)
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()
def execute(self, module, input): timerStatus = getItemState("MowerTimerStatus").toString() msg = u"" if timerStatus != "STANDBY": msg = u"{}{}".format( msg, Transformation.transform("MAP", "robonect_timer_status.map", timerStatus)) else: if itemStateNewerThen("MowerNextTimer", getNow().plusHours(24 * 4)): msg = u"{}Starte am {}".format( msg, getItemState("MowerNextTimer").format( "%1$td.%1$tm %1$tH:%1$tM")) else: msg = u"{}Starte {}".format( msg, getItemState("MowerNextTimer").format("%1$tA %1$tH:%1$tM")) postUpdateIfChanged("MowerTimerStatusFormatted", msg)
def execute(self, module, input): now = getNow() for room in filter( lambda room: room.getHeatingVolume() != None and room.getName() in controllableRooms,Heating.getRooms()): circuiteItem = Heating.getHeatingCircuitItem(room) maintainanceModeActive = room in maintenanceMode if maintainanceModeActive or itemLastUpdateOlderThen(circuiteItem,now.minusHours(24)): hour = now.getHourOfDay() if hour == 2 or getItemState(circuiteItem) == OFF: postUpdateIfChanged(circuiteItem,ON) else: postUpdateIfChanged(circuiteItem,OFF) if room.hasAdditionalRadiator(): hkItem = Heating.getHeatingHKItem(room) if hour == 2 or getItemState(hkItem) == OFF: sendCommandIfChanged(hkItem,ON) else: sendCommandIfChanged(hkItem,OFF) if hour == 2: del maintenanceMode[room] elif not maintainanceModeActive: maintenanceMode[room] = True
def execute(self, module, input): zaehlerNeu = getItemState("Rain_Garden_Counter").intValue() zaehlerAlt = getHistoricItemState( "Rain_Garden_Counter", getNow().withTimeAtStartOfDay()).intValue() todayRain = 0 if zaehlerAlt != zaehlerNeu: differenz = zaehlerNeu - zaehlerAlt if differenz < 0: differenz = zaehlerNeu todayRain = float(differenz) * 295.0 / 1000.0 postUpdateIfChanged("Rain_Garden_Current_Daily", todayRain) msg = u"{}".format(round(todayRain * 10.0) / 10.0) if getItemState("Regen_State_Garden").intValue() == 1: msg = u"(Regen) {} mm".format(msg) else: msg = u"{} mm".format(msg) postUpdateIfChanged("Rain_Garden_Message", msg)