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):
     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)
Example #5
0
    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)
Example #6
0
    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()
        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)