historic/aggregated data missing
Posted: Wednesday 26 March 2025 22:32
Hey,
I'm trying to build a solar forecast plugin. I'm nicely adding data to the unit but it doesn't create the aggregated views. What am I doing wrong? I tried all of the commented out Options (yes, I deleted the device first)
Creating device
Adding data
Results in this graph:
I'm trying to build a solar forecast plugin. I'm nicely adding data to the unit but it doesn't create the aggregated views. What am I doing wrong? I tried all of the commented out Options (yes, I deleted the device first)
Creating device
Code: Select all
if self.deviceId not in Devices or (1 not in Devices[self.deviceId].Units):
#Options={"AddDBLogEntry" : "true", "DisableLogAutoUpdate" : "true"}
#Options={"AddDBLogEntry" : "true"}
#Domoticz.Unit(Name=self.deviceId + ' - 24h forecast', Unit=1, Type=243, Subtype=33, Switchtype=4, Used=1, Options=Options, DeviceID=self.deviceId).Create()
Domoticz.Unit(Name=self.deviceId + ' - 24h forecast', Unit=1, Type=243, Subtype=33, Switchtype=4, Used=1, DeviceID=self.deviceId).Create()
Code: Select all
if dateline.date() > date.today():
sValue = str(json["result"]["watts"][dtline])+";"+str(json["result"]["watt_hours_period"][dtline])+";"+str(dtline)
#sValue = "-1;"+str(json["result"]["watt_hours_period"][dtline])+";"+str(dtline)
# Domoticz.Debug("sValue = "+str(sValue))
self.UpdateDevice(self.deviceId, 1, 0, sValue)
def UpdateDevice(self, Device, Unit, nValue, sValue, AlwaysUpdate=False, Name=""):
# Make sure that the Domoticz device still exists (they can be deleted) before updating it
if (Device in Devices and Unit in Devices[Device].Units):
if (Devices[Device].Units[Unit].nValue != nValue) or (Devices[Device].Units[Unit].sValue != sValue) or AlwaysUpdate:
Domoticz.Debug("Updating device '"+Devices[Device].Units[Unit].Name+ "' with current sValue '"+Devices[Device].Units[Unit].sValue+"' to '" +sValue+"'")
if isinstance(nValue, int):
Devices[Device].Units[Unit].nValue = nValue
else:
Domoticz.Log("nValue supplied is not an integer. Device: "+str(Device)+ " unit "+str(Unit)+" nValue "+str(nValue))
Devices[Device].Units[Unit].nValue = int(nValue)
Devices[Device].Units[Unit].sValue = sValue
if Name != "":
Devices[Device].Units[Unit].Name = Name
Devices[Device].Units[Unit].Update()
else:
Domoticz.Error("trying to update a non-existent unit "+str(Unit)+" from device "+str(Device))
return