Strange output in "My Electric" apps

Noticed some oddness on My Electric this morning, with the “todays KWh” not showing the proper value. Its only recently setup, and has about 4 or 5 days worth of data in it. Ive not noticed this before, but i noticed this morning as the value seemed unrealistically high.

Its a self hosted emoncms, running on a Ubuntu 16.04 server. It was pulled from git a week ago, showing version 9.8.6.

On my phone (android), running the emoncms app, it seems to display correctly. This morning i’ve used about 3.2kwh since midnight, and the phone shows 3.2kwh. If i plot the kwh series in graph mode, i can follow the numbers and confirm 3.2kwh.

However in the web based version, its showing 10.8kwh. Looking back thru the graph, 10.8kwh is the amount i’ve used in the last 24hrs, rather than the amount used today.

The “My Electric 2” app also shows this incorrect data.

Any ideas whats going on here?

More puzzling, the output is actually just stuck showing 10.8.

A few hours later the phone is now showing 7.9kwh, but the web-app is still stuck showing 10.8…

So the 10.8 was simply yesterdays value. Its done the same thing today. this morning its stuck at 13.2, which was the total consumption yesterday…

No-one knows whats going on?

If i get a minute today i might see if i can compare the code in the Android App to the code in the web app :confused:

The Apps module recently underwent a refactor when it was expanded to include “My Electric 2” so it’s quite possible something crept in then. Perhaps @TrystanLea can shed some light on this for you.

I have checked my emoncms.org account and that seems to be ok, as does my own self-hosted emoncms which is still running a pre-refactor apps module at the moment. I don’t have any self-hosted instance running the latest apps module yet so I have just set up a couple of feeds and apps on my test emonPi, but it will take a day or 2 before I can confirm, hopefully someone will come to your rescue before that.

So this is somewhat peculiar.

Tracing back thru the code, we get to the actual data request:

var result = feed.getdataDMY(use_kwh,start1000,end1000,“daily”);

That result comes back with its last data point showing as 1am this morning (surely this should show midnight for each day?)…

But the code later on seems to assume that the last entry will contain the amount used today…

Visualisations makes the same error:

No idea how the android app deals with this properly though?!

Edit - added image to post, deleted link to 3rd prty site. BT, Moderator

ahha, cracked it!

The 1am cutoff was the key.

Went into the profile in emoncms and set my location to Europe/London, and now the cutoff appears correctly at midnight, and the code now correctly displays todays value!

1 Like

Hi Kevin,

Instead of using a third-party site like Dropbox, please add your images to your post.
If, for some reason the image becomes inaccessible, your post loses some (possibly all) of its value.
Including your image in the post prevents that.

Just tried setting my timezone back to “UTC” on emoncms.org and got the same result as you i.e. yesterday’s fixed value for today. I wonder if this error will happen even when the correct timezone is set after the clocks go back again and the localtime here in the UK equals UTC.

Theres a segment of code that checks if the last entry = midnight today, and if so adds the current total to the end of the array.

obviously the data i was getting back wasnt midnight, so that code wasnt running, and thus wasnt adding the last value!

var lastday = data[data.length-1][0];

    var d = new Date();
    d.setHours(0,0,0,0);
    if (lastday==d.getTime()) {
        // last day in kwh data matches start of today from the browser's perspective
        // which means its safe to append today kwh value
        var next = data[data.length-1][0] + (interval*1000);
        if (feeds[use_kwh]!=undefined) {
            data.push([next,feeds[use_kwh].value*1.0]);
        }
    }

The last day value does require the timezone set in the emoncms account profile section to match your browser or computer’s timezone/time. If there is a mismatch the last day isnt shown as you have identified.

Wouldnt it be useful to tweak the if statement to do something else if the time doesnt match?

Perhaps duplicate the last kwh reading, which would then mean the “today” field shows 0?

you’d just need something like:

else data.push([data[data.length-1][0] + (interval*1000),data[data.length-1][1]]);

Or even just popup a dialog saying theres a timezone issue?

Thats true an alert would be nice, I will see if I can add that in.

Trystan, how can I set the timezone in my emoncms account profile section? My emoncms is showing yesterday’s total as per the OP… mine started going wrong when the clocks went forward!

Please DO NOT cross-post. It only adds confusion. [Moderator - RW]

I agree cross-posting is not a good idea but I wouldn’t cross-post if I got a reply to the first! Who is to say that the first was actually read as they are different threads.

It would be nice to actually get some help with this tbh.

Paul, i’ve taken this screenshot showing where i changed the time zone:

Hope that helps you?