Small mod to graph2.js scaling / decimal precision

Hello,

If possible I would like to see decimal precision to 3 decimal places when using Graph+ for calibration purposes against my revenue meter in the circled figure.

At present, when it’s below 10kWh I’m presented with 2 decimal places then 1 at 10kWh and above up to 100kWh and so on and I’d like it to be 3.

I found the table below in graph2.js which I am assuming is the correct place to make my proposed modifications?

I have asterisked the relevant lines that I plan to change. Can I make these edits without removing the SD card? If I make the changes will I be able to save them without extracting and editing the file on the SD on my laptop?

//*********************************************************************************************
// Table used to scale kilo, milli, etc with associated decimal precision
//*********************************************************************************************

var formats = [
{ max: 1, div: 0.001, prefix: “m”, dp: 0 },
*{ max: 10, div: 1, prefix: “”, dp: 2 }, CHANGE TO: { max: 10, div: 1, prefix: “”, dp: 3 },
*{ max: 100, div: 1, prefix: “”, dp: 1 }, CHANGE TO: { max: 100, div: 1, prefix: “”, dp: 3 },
*{ max: 1000, div: 1, prefix: “”, dp: 0 }, POSS CHANGE TO: { max: 1000, div: 1, prefix: “”, dp: 3 },
{ max: 10000, div: 1000, prefix: “k”, dp: 2 },
{ max: 100000, div: 1000, prefix: “k”, dp: 1 },
{ max: 1000000, div: 1000, prefix: “k”, dp: 0 },
{ max: 10000000, div: 1000000, prefix: “M”, dp: 2 },
{ max: 100000000, div: 1000000, prefix: “M”, dp: 1 },
{ max: 100000000000, div: 1000000, prefix: “M”, dp: 0 },
];

I’m asking before I break my IoTaWatt!

Thanks in advance.
Steve

I understand what you want to do, but using the power integration in Graph+ is not the most accurate way to do it. The answer that you get would be based on data that has three significant digits no matter how you display it.

So, let’s back up to what you want to know. You want to know the total Watt-Hours for a specific period. IoTaWatt actually keeps that information for any period as a double precision floating point number. You need to know how to read it out with Graph+.

First recognize that the units you are after are Watt-Hours (Wh) not Watts. So, select that.
image
Now select the period that you want, Group = All, the source(s) that you are interested in and select statistics at the bottom.:


IoTaWatt shows 37,417.35 Wh or 37.417 kWh.

The same data using the Graph+ Power integration gives:

If you wanted weekly totals for the past 4 weeks, you can do this and look at the CSV for the results:


This works for any grouping over any period. Hourly, Daily, Weekly, Monthly, Yearly.

You can edit the files on your IoTaWatt without removing the SDcard.

OK, thank you Bob,

I delayed replying because I thought I’d seen an odd result but no, I must have had some finger or brain trouble! I just spent a little more time now checking and all was well. Requirement met!

Thanks,
Steve

I did successfully make the decimal point mods Bob but I don’t need them now and put them back as they were.

Thanks again,
Steve

1 Like