historic/aggregated data missing

Python and python framework

Moderator: leecollings

Post Reply
JanJaap
Posts: 215
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

historic/aggregated data missing

Post by JanJaap »

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

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()
Adding data

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
Results in this graph:
Schermafbeelding 2025-03-26 223245.png
Schermafbeelding 2025-03-26 223245.png (66.85 KiB) Viewed 636 times
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
User avatar
waltervl
Posts: 5843
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: historic/aggregated data missing

Post by waltervl »

Not looking at the code but are you using a managed counter? Then you need to build the history from the plugin. Domoticz core will not do that for you.

Perhaps check a plugin for future energy prices how they implemented that?

Edit: see the wiki:
sValue must 3 semicolon separated values, the last value being a date ("%Y-%m-%d" format) to update last week/month/year history, for instance "123456;78;2019-09-24"
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
JanJaap
Posts: 215
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Re: historic/aggregated data missing

Post by JanJaap »

OK, so that is actually the sValue input. See logging below:

Code: Select all

2025-03-29 19:55:31.036 Solar forecast achter: sValue = 418;289;2025-04-01 19:00:00
2025-03-29 19:55:31.036 Solar forecast achter: Updating device 'Solar forecast achter - 24h forecast' with current sValue '' to '418;289;2025-04-01 19:00:00'
2025-03-29 19:55:31.067 Solar forecast achter: sValue = 0;247;2025-04-01 20:10:47
2025-03-29 19:55:31.068 Solar forecast achter: Updating device 'Solar forecast achter - 24h forecast' with current sValue '' to '0;247;2025-04-01 20:10:47'
2025-03-29 19:55:31.100 Solar forecast achter: sValue = -1;6833;2025-03-30
2025-03-29 19:55:31.100 Solar forecast achter: Updating device 'Solar forecast achter - 24h forecast' with current sValue '' to '-1;6833;2025-03-30'
2025-03-29 19:55:31.132 Solar forecast achter: sValue = -1;9224;2025-03-31
2025-03-29 19:55:31.132 Solar forecast achter: Updating device 'Solar forecast achter - 24h forecast' with current sValue '' to '-1;9224;2025-03-31'
2025-03-29 19:55:31.164 Solar forecast achter: sValue = -1;18478;2025-04-01
2025-03-29 19:55:31.164 Solar forecast achter: Updating device 'Solar forecast achter - 24h forecast' with current sValue '' to '-1;18478;2025-04-01'
First lines give the hourly updates, last lines the full day updates
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
User avatar
waltervl
Posts: 5843
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: historic/aggregated data missing

Post by waltervl »

I am not sure how this works for using a managed counter as forecast device but I suppose it is only visible in the short log data (top graph). The other graphs probably only show real history data (but again, I am not sure)
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
JanJaap
Posts: 215
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Re: historic/aggregated data missing

Post by JanJaap »

OK so it works now. However, I'm entering future day data but that is not being displayed. Is there any device that lets me display (aggregated) future data?

What I want, is to load this predicition data and use it in another script to determine the best operating mode for my home batteries. I think it should not be in a combined plugin as the target operating mode depends on data from both the devices that give the electricity prices as well as the predicted solar energy and then controls the battery. These are 3 different plugins. So any advice on how to do this is welcome.

So this is what the graph looks like (now is April 1 21:06)
Schermafbeelding 2025-04-01 210724.png
Schermafbeelding 2025-04-01 210724.png (81.77 KiB) Viewed 439 times
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest