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): msg = u"→ {}°C, ← {}°C".format( getItemState("Ventilation_Outdoor_Incoming_Temperature").format( "%.1f"), getItemState("Ventilation_Outdoor_Outgoing_Temperature").format( "%.1f")) postUpdateIfChanged("Ventilation_Outdoor_Temperature_Message", msg)
def execute(self, module, input): self.log.info("test") self.log.info("{}".format(input["event"].getItemState())) if input["event"].getItemState().intValue() == 1: postUpdateIfChanged("State_Notify", OFF) else: postUpdateIfChanged("State_Notify", ON)
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): active = [] Ventilation_Filter_Error_I_State = getItemState( "Ventilation_Filter_Error_I").intValue() Ventilation_Filter_Error_E_State = getItemState( "Ventilation_Filter_Error_E").intValue() if Ventilation_Filter_Error_I_State == 1 or Ventilation_Filter_Error_E_State == 1: value = u"Filter: " if Ventilation_Filter_Error_I_State == 1: value = u"{}I".format(value) if Ventilation_Filter_Error_I_State == 1 and Ventilation_Filter_Error_E_State == 1: value = u"{} & ".format(value) if Ventilation_Filter_Error_E_State == 1: value = u"{}E".format(value) active.append(value) if getItemState("Ventilation_Error_Message").toString() != "Ok": active.append(u"Error: {}".format( getItemState("Ventilation_Error_Message").toString())) if len(active) == 0: active.append(u"Alles in Ordnung") msg = ", ".join(active) postUpdateIfChanged("Ventilation_State_Message", msg)
def updateConsumption(self, solarPower): consumption = self.currentDemand + solarPower if consumption > 0: postUpdateIfChanged("Electricity_Current_Consumption", consumption) else: self.log.info( u"Skip consumption update. powerDemand: {}, powerSupply: {}, solarPower: {}" .format(self.powerDemand, self.powerSupply, solarPower))
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): state = getItemState("PlantSensorInfo").toString() if state != "Feucht genug" and state != "Nicht aktiv": msg = state else: msg = u"Alles normal" postUpdateIfChanged("SensorInfo", msg)
def execute(self, module, input): msg = u"" if getItemState("Wind_Garden_Converted").intValue() == 0: msg = u"Ruhig" else: msg = u"{} km/h, {}".format( getItemState("Wind_Garden_Converted").format("%.1f"), getItemState("Wind_Direction").toString()) postUpdateIfChanged("Wind_Message", msg)
def execute(self, module, input): dailyEnergyDemand = getItemState( "Electricity_Current_Daily_Demand").doubleValue() dailyEnergySupply = getItemState( "Electricity_Current_Daily_Supply").doubleValue() dailySolarSupply = getItemState("Solar_Daily_Yield").doubleValue() postUpdateIfChanged( "Electricity_Current_Daily_Consumption", dailyEnergyDemand - dailyEnergySupply + dailySolarSupply)
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 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)
def execute(self, module, input): active = [] if getItemState("Auto_Rollershutter") == ON: active.append("R") if getItemState("Auto_Sunprotection") == ON: active.append("S") if getItemState("Auto_Lighting") == ON: active.append("L") if getItemState("Auto_Christmas") == ON: active.append("W") if getItemState("Auto_Attic_Light").intValue() > 1: active.append("D") if len(active) == 0: active.append("Inaktiv") msg = ", ".join(active) postUpdateIfChanged("AutoStatus", msg)
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 getItemState("Heating_Solar_Pump_State").intValue() == 1: msg = "an" else: msg = "aus" msg = msg + ", " if getItemState("Heating_Solar_Reheating_State").intValue() == 1: msg = msg + "an" else: msg = msg + "aus" postUpdateIfChanged("Heating_Solar_State_Message", msg)
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): active = [] if getItemState("SoilMoistSensor1Enabled") == ON: active.append("1") if getItemState("SoilMoistSensor2Enabled") == ON: active.append("2") if getItemState("SoilMoistSensor3Enabled") == ON: active.append("3") if getItemState("SoilMoistSensor4Enabled") == ON: active.append("4") if getItemState("SoilMoistSensor5Enabled") == ON: active.append("5") if getItemState("SoilMoistSensor6Enabled") == ON: active.append("6") postUpdateIfChanged("SoilMoistSensorInfo", u", ".join(active))
def execute(self, module, input): active = [] if getItemState("Watering_Circuits") == ON: active.append(u"Bewässerung") if getItemState("Motiondetector_Outdoor_Switch") != ON: active.append(u"Beleuchtung") if len(active) == 0: active.append(u"Alles normal") msg = ", ".join(active) postUpdateIfChanged("GardenStatus", msg)
def updateInfoMessage(self, infoItem, temperatureItem, humidityItem, temperatureTargetItem=None): msg = u"" if temperatureTargetItem is not None: msg = u"{}({}°C) ".format( msg, getItemState(temperatureTargetItem).format("%.1f")) msg = u"{}{}°C, ".format(msg, getItemState(temperatureItem).format("%.1f")) msg = u"{}{}%".format(msg, getItemState(humidityItem).format("%.1f")) postUpdateIfChanged(infoItem, msg)
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): active = [] count = len(getFilteredChildItems("Sensor_Doors_FF", OPEN)) if count > 0: if count == 1: active.append(u"1 Tür") else: active.append(u"{} Türen".format(count)) count = len(getFilteredChildItems("Sensor_Window_FF", OPEN)) count += len(getFilteredChildItems("Sensor_Window_SF", OPEN)) if count > 0: active.append(u"{} Fenster".format(count)) if len(active) > 0: msg = u"{} offen".format(u" und ".join(active)) else: msg = u"Alles geschlossen" postUpdateIfChanged("RoomStatus", msg)
def execute(self, module, input): msg = u"Nicht aktiv" if getItemState("Auto_Attic_Light").intValue() != 1: soilMoistSensor1 = getItemState("SoilMoistSensor1").intValue( ) if getItemState("SoilMoistSensor1Enabled") == ON else 1000 soilMoistSensor2 = getItemState("SoilMoistSensor2").intValue( ) if getItemState("SoilMoistSensor2Enabled") == ON else 1000 soilMoistSensor3 = getItemState("SoilMoistSensor3").intValue( ) if getItemState("SoilMoistSensor3Enabled") == ON else 1000 soilMoistSensor4 = getItemState("SoilMoistSensor4").intValue( ) if getItemState("SoilMoistSensor4Enabled") == ON else 1000 if soilMoistSensor1 < 380 or soilMoistSensor2 < 380 or soilMoistSensor3 < 380 or soilMoistSensor4 < 380: msg = u"Jetzt Giessen" elif soilMoistSensor1 < 400 or soilMoistSensor2 < 400 or soilMoistSensor3 < 400 or soilMoistSensor4 < 400: msg = u"Giessen" else: msg = u"Feucht genug" postUpdateIfChanged("PlantSensorInfo", msg)
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): laufzeit = getItemState("Ventilation_Filter_Runtime").doubleValue() weeks = int(math.floor(laufzeit / 168.0)) days = int(math.floor((laufzeit - (weeks * 168.0)) / 24)) active = [] if weeks > 0: if weeks == 1: active.append(u"1 Woche") else: active.append(u"{} Wochen".format(weeks)) if days > 0: if days == 1: active.append(u"1 Tag") else: active.append(u"{} Tage".format(days)) msg = u", ".join(active) postUpdateIfChanged("Ventilation_Filter_Runtime_Message", msg)
def execute(self, module, input): msg = "" cleaning_state = OFF if getItemState("roomba_online") == OFF: msg = "Offline" else: status = getItemState("roomba_status").toString() if status == "Running": msg = "Reinigt" cleaning_state = ON elif status == "Charging": msg = "In Ladestation" elif status == "Stuck": msg = u"Hängt fest" else: msg = status postUpdateIfChanged("roomba_StatusFormatted", msg) postUpdateIfChanged("roomba_cleaning_state", cleaning_state)
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)
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): 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): group = "Fehler" active = [] if getItemState("roomba_status").toString() == "Stuck" or getItemState( "roomba_full") == ON: active.append("Roomba") if getItemState("MowerStatus").intValue() == 7 or getItemState( "MowerStatus").intValue() == 8: active.append("Mower") if len(active) == 0: active.append("Alles normal") group = "Info" msg = ", ".join(active) if postUpdateIfChanged("RoboterStatus", msg): sendNotification("Roboter " + group, msg)