Exemplo n.º 1
0
    def execute(self, module, input):
        now = ZonedDateTime.now()

        currentSupply = getItemState(
            "pGF_Utilityroom_Electricity_Total_Supply").doubleValue()
        currentYield = getItemState(
            "pGF_Garage_Solar_Inverter_Total_Yield").doubleValue()

        # Tagesverbrauch
        startSupply = getHistoricItemState(
            "pGF_Utilityroom_Electricity_Total_Supply",
            now.toLocalDate().atStartOfDay(now.getZone())).doubleValue()
        startYield = getHistoricItemState(
            "pGF_Garage_Solar_Inverter_Total_Yield",
            now.toLocalDate().atStartOfDay(now.getZone())).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("pGF_Garage_Solar_Inverter_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("pGF_Garage_Solar_Inverter_Daily_Consumption",
                            dailyConsumption)

        # Jahresverbrauch
        refDay = now.withYear(now.getYear()).withMonth(1).withDayOfMonth(1)
        refDate = refDay.toLocalDate().atStartOfDay(refDay.getZone())
        startSupply = getHistoricItemState(
            "pGF_Utilityroom_Electricity_Total_Supply", refDate).doubleValue()
        startYield = getHistoricItemState(
            "pGF_Garage_Solar_Inverter_Total_Yield", refDate).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("pGF_Garage_Solar_Inverter_Annual_Consumption",
                            annualConsumption)
Exemplo n.º 2
0
    def execute(self, module, input):
        now = ZonedDateTime.now()

        supplyCurrent = getItemState(
            "pGF_Utilityroom_Energy_Supply_Active").intValue() / 1000.0
        zaehlerStandCurrent = (startEnergyTotalSupplyValue + supplyCurrent)
        postUpdateIfChanged("pGF_Utilityroom_Electricity_Total_Supply",
                            zaehlerStandCurrent)

        postUpdateIfChanged(
            "pGF_Utilityroom_Electricity_Meter_Supply",
            zaehlerStandCurrent - startElectricityMeterSupplyValue)

        # *** Tageslieferung ***
        zaehlerStandOld = getHistoricItemState(
            "pGF_Utilityroom_Electricity_Total_Supply",
            now.toLocalDate().atStartOfDay(now.getZone())).doubleValue()
        currentSupply = zaehlerStandCurrent - zaehlerStandOld

        postUpdateIfChanged("pGF_Utilityroom_Electricity_Current_Daily_Supply",
                            currentSupply)
        # *** Jahreslieferung ***

        refDay = now.withYear(now.getYear()).withMonth(1).withDayOfMonth(1)
        zaehlerStandOld = getHistoricItemState(
            "pGF_Utilityroom_Electricity_Total_Supply",
            refDay.toLocalDate().atStartOfDay(refDay.getZone())).doubleValue()
        currentSupply = zaehlerStandCurrent - zaehlerStandOld

        if postUpdateIfChanged(
                "pGF_Utilityroom_Electricity_Current_Annual_Supply",
                currentSupply):
            # Hochrechnung
            zaehlerStandCurrentOneYearBefore = getHistoricItemState(
                "pGF_Utilityroom_Electricity_Total_Supply",
                now.minusYears(1)).doubleValue()
            forecastSupply = zaehlerStandOld - zaehlerStandCurrentOneYearBefore

            refDay = now.withYear(now.getYear() -
                                  1).withMonth(1).withDayOfMonth(1)
            zaehlerStandOldOneYearBefore = getHistoricItemState(
                "pGF_Utilityroom_Electricity_Total_Supply",
                refDay.toLocalDate().atStartOfDay(
                    refDay.getZone())).doubleValue()

            hochrechnungSupply = int(round(currentSupply + forecastSupply))
            vorjahresSupply = int(
                round(zaehlerStandOld - zaehlerStandOldOneYearBefore))
            msg = u"{}kWh, {} kWh".format(hochrechnungSupply, vorjahresSupply)
            postUpdate(
                "pGF_Utilityroom_Electricity_Current_Annual_Supply_Forecast",
                msg)
Exemplo n.º 3
0
    def execute(self, module, input):
        now = ZonedDateTime.now()

        currentTotal = getItemState("Solar_Total_Yield").doubleValue()

        startTotal = getHistoricItemState(
            "Solar_Total_Yield",
            now.toLocalDate().atStartOfDay(now.getZone())).doubleValue()
        postUpdateIfChanged("Solar_Daily_Yield", currentTotal - startTotal)

        refDay = now.withYear(now.getYear()).withMonth(1).withDayOfMonth(1)
        startTotal = getHistoricItemState(
            "Solar_Total_Yield",
            refDay.toLocalDate().atStartOfDay(refDay.getZone())).doubleValue()
        postUpdateIfChanged("Solar_Annual_Yield", currentTotal - startTotal)
Exemplo n.º 4
0
 def execute(self, module, input):
     refDay = ZonedDateTime.now()
     start = getHistoricItemState(
         "pGF_Utilityroom_Heating_Solar_Hours",
         refDay.toLocalDate().atStartOfDay(refDay.getZone())).intValue()
     aktuell = getItemState(
         "pGF_Utilityroom_Heating_Solar_Hours").intValue()
     if start > 0 and aktuell > 0:
         differenz = aktuell - start
         msg = u"{} h, {} h".format(differenz, aktuell)
         postUpdateIfChanged("pGF_Utilityroom_Heating_Solar_Hours_Message",
                             msg)
Exemplo n.º 5
0
    def execute(self, module, input):
        now = ZonedDateTime.now()
        Aktuell_End = getItemState(
            "pGF_Utilityroom_Gas_Meter_Pulse_Counter").doubleValue()

        # Aktueller Zählerstand
        zaehlerStandCurrent = startGasMeterValue + (
            (Aktuell_End - startGasImpulseCounter) * 0.01)

        zaehlerStandSaved = getItemStateWithFallback(
            "pGF_Utilityroom_Gas_Meter_Current_Count",
            DecimalType(0.0)).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("pGF_Utilityroom_Gas_Meter_Current_Count",
                       zaehlerStandCurrent)

        # *** Aktueller Tagesverbrauch ***
        zaehlerStandOld = getHistoricItemState(
            "pGF_Utilityroom_Gas_Meter_Current_Count",
            now.toLocalDate().atStartOfDay(now.getZone())).doubleValue()
        currentConsumption = zaehlerStandCurrent - zaehlerStandOld
        if currentConsumption < 0:
            currentConsumption = 0

        postUpdateIfChanged("pGF_Utilityroom_Gas_Current_Daily_Consumption",
                            currentConsumption)

        # *** Jahresverbrauch ***
        refDay = now.withYear(now.getYear()).withMonth(1).withDayOfMonth(1)
        zaehlerStandOld = getHistoricItemState(
            "pGF_Utilityroom_Gas_Meter_Current_Count",
            refDay.toLocalDate().atStartOfDay(refDay.getZone())).doubleValue()
        currentConsumption = zaehlerStandCurrent - zaehlerStandOld
        if currentConsumption < 0:
            currentConsumption = 0

        if postUpdateIfChanged("pGF_Utilityroom_Gas_Annual_Consumption",
                               currentConsumption):
            # Hochrechnung
            zaehlerStandCurrentOneYearBefore = getHistoricItemState(
                "pGF_Utilityroom_Gas_Meter_Current_Count",
                now.minusYears(1)).doubleValue()
            forecastConsumtion = zaehlerStandOld - zaehlerStandCurrentOneYearBefore

            refDay = now.withYear(now.getYear() -
                                  1).withMonth(1).withDayOfMonth(1)
            zaehlerStandOldOneYearBefore = getHistoricItemState(
                "pGF_Utilityroom_Gas_Meter_Current_Count",
                refDay.toLocalDate().atStartOfDay(
                    refDay.getZone())).doubleValue()

            hochrechnungVerbrauch = round(currentConsumption +
                                          forecastConsumtion)

            msg = u"{} m³, {} m³".format(
                hochrechnungVerbrauch,
                int(round(zaehlerStandOld - zaehlerStandOldOneYearBefore)))
            postUpdate("pGF_Utilityroom_Gas_Forecast", msg)