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 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): 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)
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 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 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): reference_duration = getItemState( "Watering_Program_Duration").intValue() for i in range(len(circuits)): for circuit in circuits[i][2]: if getItemState(circuit + "_Auto") == ON: duration = (circuits[i][0] * reference_duration) duration = int(math.floor(duration)) postUpdate(circuit + "_Info", u"{} min.".format(duration)) else: postUpdate(circuit + "_Info", u"inaktiv")
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): 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)
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): 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)
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 setSunStates(self, cr, hhs ): effectiveSouthRadiation = cr.getSunSouthRadiation() / 60.0 effectiveWestRadiation = cr.getSunWestRadiation() / 60.0 #self.log.info(u"{} {}".format(effectiveSouthRadiation,effectiveWestRadiation)) #hasRadiation = effectiveSouthRadiation > 0.0 or effectiveWestRadiation > 0.0 currentOutdoorTemperature = cr.getReferenceTemperature() fallbackTargetTemperature = hhs.getHeatingState("FF_Livingroom").getHeatingTargetTemperature() for room in Heating.getRooms(): rs = cr.getRoomState(room.getName()) targetRoomTemperature = fallbackTargetTemperature if room.getHeatingVolume() == None else hhs.getHeatingState(room.getName()).getHeatingTargetTemperature() for transition in room.transitions: if not isinstance(transition,Window) or transition.getRadiationArea() == None or transition.getSunProtectionItem() == None: continue currentRoomTemperature = rs.getCurrentTemperature() effectiveRadiation = effectiveSouthRadiation if transition.getDirection() == 'south' else effectiveWestRadiation if getItemState(transition.getSunProtectionItem()) == ON: targetRoomTemperature = targetRoomTemperature - 0.6 if effectiveRadiation < 3.7 or currentRoomTemperature < targetRoomTemperature or currentOutdoorTemperature < targetRoomTemperature: postUpdate(transition.getSunProtectionItem(), OFF ) self.log.info(u"DEBUG: SP switching off {} {} {} {} {}".format(room.getName(),effectiveRadiation,currentRoomTemperature,currentOutdoorTemperature,targetRoomTemperature)) #else: # self.log.info(u"SP still needed") else: targetRoomTemperature = targetRoomTemperature - 0.5 if effectiveRadiation > 3.8 and currentRoomTemperature > targetRoomTemperature and currentOutdoorTemperature > targetRoomTemperature: postUpdate(transition.getSunProtectionItem(), ON ) self.log.info(u"DEBUG: SP switching on {} {} {} {} {}".format(room.getName(),effectiveRadiation,currentRoomTemperature,currentOutdoorTemperature,targetRoomTemperature))
def execute(self, module, input): global autoChangeInProgress if autoChangeInProgress: autoChangeInProgress = False else: postUpdate("Ventilation_Auto_Mode", 0)
def execute(self, module, input): postUpdate( "TV_KEY_POWER", ON if input["event"].getStatusInfo().getStatus().toString() == "ONLINE" else OFF)
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): 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): if getItemState("roomba_error") == ON: postUpdate("roomba_errorFormatted", getItemState("roomba_errortext").toString()) else: postUpdate("roomba_errorFormatted", "Alles OK")
def execute(self, module, input): postUpdate( "roomba_sqm", u"{}".format( round( getItemState("roomba_sqft").doubleValue() / 10.76391041671)))
def execute(self, module, input): postUpdate("Security_Last_Change", DateTimeType())
def disableAllCircuits(self): for child in getGroupMember("Watering_Circuits"): sendCommand(child, OFF) postUpdate("Watering_Program_State", u"läuft nicht")
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)
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())