Open sincze opened 1 year ago
Great! I already prepared the plugin for filling historic data, but it didn't work for previous Domoticz versions. Did you already patch the plugin? Can you create a PR for it?
Sure it now fills on plugin start in.my version What are your ideas to loop through it? Everyday Sunday each week?
Do we want to play with the date?? Now it is 1900 :)
Let me know.
I propose to fill the historic data at every start of the plugin. The amount of data is relatively limited, so the overhead will be minimal.
What do you mean with the date? (1900)
What do you mean with the date? (1900)
My bad 1990 ;-) so it will grab all sessions since.
startDate = datetime.datetime(1990,1,1)
My idea was to regularly call the function for the last week and then update the counter. Just an idea.
def runScheduledTask(self, chargerId):
now = datetime.datetime.now()
# Check if it's Sunday (day 6) and the time is 03:00
if now.weekday() == 6 and now.hour == 3 and now.minute == 0:
Domoticz.Log("Running scheduled task to fill historic energy data...")
# Charger ID to use
self.fillHistoricEnergyData(chargerId)
And add to the function
def onHeartbeat(self):
Domoticz.Log("onHeartbeat called")
self.countDown = self.countDown - 1
if self.countDown <= 0:
self.countDown = self.countDownInit
self.messageQueue.put({"Type": "Update"})
# Check for the scheduled task
self.runScheduledTask(chargerId)
Just wanted to let you know. https://github.com/domoticz/domoticz/issues/5809#issuecomment-1709825891
Historic Import from within the plugin is now possible.