Graph+ issue from hourly to daily - import/export limitations explained

Hi I have a strange result whan going from hourly to daily grouping of the data, I post two picture of the graph
hourly the data are ok

in the daily all the data are wrong…

there is anything I have to ceck?

Hmmmm. Can you post them again with the CSV displayed? It looks like the two are combined in the second graph. The CSV will show if that’s happening in query or Graph+.

Also, are those inputs or outputs?

thanks for the quick reply, they are outputs,


here are the screen with the csv

Now I see what’s going on. This is an ongoing issue. There is a solution, but bear with me. (I really should explain this in the documentation).

When you allow negative values, IoTaWatt measures net usage on a CT. That not only applies to the 5 second intervals in the datalog, but due to the way that the datalog and query works, it applies to any interval that you examine.

When you apply the script electricity_grid max 0 to an interval, the result is the net positive usage during that interval. That’s not necessarily what you imported, it’s what you imported minus what you exported during that interval. After a day where you imported 10kWh and exported 12kWh, the net would be -2kWh and script would evaluate to zero. On the other hand, if the interval is an hour, some of those 24 hourly periods would have positive net usage, as in your first hourly graph, and would show import. That’s what is happening in your case.

If you want to get true import, you must integrate smaller intervals. Unfortunately the IoTaWatt doesn’t have the horsepower to do ad-hoc integrations with reasonable response times. It does have the ability to determine import and export for each 5 second interval. The problem is that there is no extra space in the datalog to save that detail. There is a technique that you can use that essentially sacrifices an input to get space to save the data. It’s a little convoluted, but works fine. It’s explained here.

The referenced method uses a redundant CT on the main. That should not be necessary. There is a way to get around that and if you decide to do it, and tell me which input would be used, I can tell you how to edit your config file to cause the IoTaWatt to use the same CT for two inputs. On the other hand, if you have another CT, that would be fine.

Another solution is to upload the data to any of the supported databases and get your import/export from there. You can import and export outputs work fine at 5 second resolution and having an external database sum them would be easy.

Thanks tomorrow I’m going to check the solution, beacaise I want yo retain the two years of data I think I’m going to try the export to an external server (really a local rasp) and see if a can jave the data I need.
Thanks for the help

Hi I manage to export everything on a rasp with emoncms, now I have another problem, my history is from the 19th of April in 2019 but iotawatt exported only from the 26th of January 2020 to 16th of January 2021 leave me a gap before and a gap from 16th to this morning 28th of January, how can I export everthing?
here the gap

and here the correct data stored on iotawatt

IoTaWatt will only upload data from the current log, which is approximately the past year.

I don’t know why you have a hole in January if you upload your message log, I’ll take a look and see if I can determine why,and what you might be able to do about it.

ok here it’s my log thanksiotamsgs.txt (296.0 KB)

From what I can see in the log:

Since commissioning your IoTaWatt you have been uploading to Emoncms, beginning on April 10, 2019.

With respect to Emoncms.org, everything went smoothly for about 21 months. There were various issues and restarts which recovered as expected, uploaded history, and pressed on.

For whatever reason, on January 19 this year at about noon, you stopped the uploader, changed the URL to address a local instance of Emoncms, and restarted the uploader.

Long story short, you were able to upload your current log history to that instance and it appears the hole occurred during the end of that upload. My suspicion is that it has something to do with restarting the Emoncms instance.

Private instances of Emoncms, as opposed to the enterprise Emoncms.org, use Redis to hold the inputs database in memory. On restart, they are lost and so cannot respond to IoTaWatt’s query with the time of last input. As a result, IoTaWatt starts uploading from the current time.
IotaWatt to EmonCMS reload

So I think that’s what happened. Not sure how to recover. I don’t believe it’s possible with the tools available in Emoncms.

Question: Why did you switch from Emoncms.org? It appears to have been working fine for a year and a half. If you have not changed anything, you should be able to simply reset your uploader to Emoncms.org and it should pick up where it left off at about noon on January 19th.

I change to local emoncms because I have a spare rasp here seating on my desk for some time so I decided to try to go local instead, if there is no way to recover that days I will survive anyway.

Now I bought another CT to solve the original problem. If I understand correctly I install the new CT on the main cable but in the opposite direction compared to the one already installed. Now I should collect only the positive value from these CTs so one record only the export and the other one only the import. I have tried that but it didn’t work so I’m missing something

You install the new CT alongside the old, with the same orientation, and do not check “allow negative values”. So on one you should see both positive (import) and negative (export) values. On the other you should see the same positive import values, but the export values will be changed to positive. It’s a little complicated, but the math is explained in the link.

Once you have a day or two of data, plot the two with Graph+ so I can see that it’s correct and I’ll show you the scripts you need for import and export.

If you call the input that allows negative values “NET” and the input that doesn’t allow negative values “ABS” (absolute value) then:

Import = (NET + ABS) / 2
Export = (ABS - NET) / 2