CheongKoo / HA_AppDaemonZeverSolarSensor

Get power generation from ZeverSolar Inverter and present it to front end as a sensor for Hass.IO
GNU General Public License v3.0
7 stars 3 forks source link

Zeversolar is showing wrong daily energy under certain circumstances #8

Open QuaySo opened 2 years ago

QuaySo commented 2 years ago

While I was debugging I noticed my daily energy from de inverter shows incorrect values under certain circumstances. Normally the daily energy is given with 2 decimals, but when it is below 0.10 the values are displayed wrong.

Normally the sequence would be: 0.01, 0.02, 0.03, 0.04, 0.05 .... 0.09, 0.10, 0.11, 0.12 But values I receive are: 0.1, 0.2, 0.3, 0.4, 0.5 .... 0.9, 0.10, 0.11, 0.12

Because of this, Homeassistant is showing incorrect hourly values in the energy dashboard.

I'm not sure this is a general problem, or just on my site. As a workaround I added a couple of lines of code to determine the correct values for the daily energy sensor. If your seeing the same behavior on your site, you may try this:

    #---------------------------------------------------------------------
    #-- Gets the reading from the URL. Returns 0 if no generation
    def requestSolarGeneration(self, arg):
        self.dateOfReading = datetime.now() # Get date & time of reading
        req = Request(zeverSolarURL)
        try:
            response = urlopen(req)
            htmlresponse = response.read()
            st = htmlresponse.decode()
            st = st.split() # Convert the string into a list
            #-- Get the string for the Generated Power and Daily Energy
            genPower = st[genPowerIndex]
            dailyEnergy = st[dailyEnergyIndex]
            #-- Because Zeversolar calculation of kWh is incorrect (23.1  is not 23.1 but 23.01) a correction is done
            dailyEnergySplit = dailyEnergy.split('.')
            dailyEnergyWhole = dailyEnergySplit[0]
            dailyEnergyDec = dailyEnergySplit[1]

            if len(dailyEnergyDec) == 1:
              dailyEnergyDec = '0'+ dailyEnergyDec
            dailyEnergyCorrect = dailyEnergyWhole + '.' + dailyEnergyDec

            #-- Convert string into Int and Float
            self.generatedPower = float(genPower)/1000 # Its in W eg. 4978. Convert into kW
            self.totalEnergyDaily = float(dailyEnergyCorrect) # It is already in kWh eg. 14.52
            return
        except:
            self.log("Error in connecting to Zever solar server", log="main_log")
            self.generatedPower = 0.00
            self.totalEnergyDaily = None
            return
RemcoA1 commented 2 years ago

Hi,

I got similar issues where the dailypower graphs showed weird spikes: image I think you found the issue, I also reported the issue to Zeversolar support. I will give them the link to this issue.

ByteBrewerJB commented 2 years ago

Thank you, i guess the problem is specific to some devices from ZeverSolar