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

Update appd_ZeverSolarSensor.py #5

Open ByteBrewerJB opened 3 years ago

ByteBrewerJB commented 3 years ago

i tried to make it work for the energy dashboard.

QuaySo commented 3 years ago

It works for me, except the value drops to 0 when the inverter is shut down. This look weird in the energy graph, as if the inverter is using energy. To work properly for the energy dashboard the value should keep it's last value of that day until a new day starts.

ByteBrewerJB commented 3 years ago

and what if we set it al 'null' when there is no data?

QuaySo commented 3 years ago

That would probably work too. It's worth a try

QuaySo commented 3 years ago

and what if we set it al 'null' when there is no data?

I haven't been able to get this working. Did you>

RemcoA1 commented 3 years ago

For me it's working by setting the value to None when the inverter is offline.

       except:
            self.log("Error in connecting to Zever solar server", log="main_log")
            self.generatedPower = 0.00
            self.totalEnergyDaily = None

and I changed the last_reset attribute:

    def doGetGenAndSendAsSensor(self, arg):
        self.log("----- ZeverSolar sensor callback -----", log="main_log")
        #-- Get the generated power & energy
        self.requestSolarGeneration(self)
        lastUpdated = self.dateOfReading.strftime(datetimeFormat) # Last updated
        lastReset = self.dateOfReading.strftime("%Y-%m-%d 00:00:00+02:00")
        #-- Output the sensor values
        #-- Instantaneous Generated power
        stateInfo1 = generationFormat.format(self.generatedPower)
        self.set_state("sensor.zeverSolar_generated_power", state=stateInfo1, attributes=\
                       {"unit_of_measurement": "kW", \
                        "last_reset" : lastReset, \
                        "state_class": "measurement", \
                        "device_class": "energy", \
                        "icon": "mdi:white-balance-sunny", \
                        "friendly_name": "Generated Power",
                        "lastUpdated": lastUpdated
                       })
        #-- Daily energy generated
        #- Icons are located at http://materialdesignicons.com/
        stateInfo2 = generationFormat.format(self.totalEnergyDaily)
        self.set_state("sensor.zeverSolar_daily_energy", state=stateInfo2, attributes=\
                       {"unit_of_measurement": "kWh", \
                        "last_reset" : lastReset, \
                        "state_class": "measurement", \
                        "device_class": "energy", \
                        "icon": "mdi:white-balance-sunny", \
                        "friendly_name": "Daily Generated Energy",
                        "lastUpdated": lastUpdated
                       })
ByteBrewerJB commented 3 years ago

Thanks i will try it soon! I have a newborn at the moment, so my pc time is limited the next couple of weeks :)