Open ByteBrewerJB opened 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.
and what if we set it al 'null' when there is no data?
That would probably work too. It's worth a try
and what if we set it al 'null' when there is no data?
I haven't been able to get this working. Did you>
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
})
Thanks i will try it soon! I have a newborn at the moment, so my pc time is limited the next couple of weeks :)
i tried to make it work for the energy dashboard.