My Electric Time Of Use App For Economy 10

Absolutely! That looks very much like where I was heading, I’ll definitely take a look.

Thanks for pointing it out.

I’ve had a look at the costcomparison app from Stuart and it has a completely different focus to what I was planning. He has however solved some of the same problems I was about to deal with so it was very timely that I have seen his work now :slight_smile:

I’m not sure I’ll take the same approach but it has given me plenty to think about.

1 Like

Great, Different app implementations are always welcome, let us know how you get on!

Ok, I’ve made plenty of progress with this, anyone who’d like to take a look is welcome to grab a copy from:
https://github.com/greeebs/emoncms-app.git. make sure you grab the “tou_au” branch.

There’s still a bug to fix in the “hover” when clicked through to the powergraph (the same bug is in the timeofuse.php App that I started with) and I haven’t catered for public holidays yet.

What it does do:
Allows you to define any number of individual tariff Tiers (specify Name and price)
Allows you to define the daily start times for each tariff tier for both weekdays and weekends. (It assumes the start times for each tariff are identical each weekday and identical each weekend day)
Switching to Cost mode displays a bar graph of the cost split between tiers instead of the power use split.

Clicking through to the power graph also shows the different tiers as different colours (using the same tier colours in the daily use graphs)

Feedback would be most appreciated before I submit a PR.

@Westerner, this may do what you were asking when you started this thread?

1 Like

Wow nice work! looks really nice, here’s a screen for others interested:

Very minor heading fix I think for “Weekend Tier Start Times” should be “Public holidays”? Happy to merge pull request

Cool, I’ll try and get the public holiday handling sorted tonight, fix that heading change and then submit the PR.

Appreciate the feedback.

I have downloaded the zip file from Greebo’s fork: do I just copy all the files over to the app directory on my emonpi? Apologies for the question, but I have not found an answer elsewhere.

I’ve fixed the public holiday handling and submitted a PR.

@Westerner, if @TrystanLea is happy with the PR and merges it, you should just be able to do a regular update from the web interface. Just unzipping your download into the app folder will certainly allow you to play with the new app in the meantime, but I’m not sure what that will do to future updates (I’m not familiar enough with Git to work that out!)

If you don’t want to wait, I suggest you grab the zip again now though as I’ve only just fixed a few annoying things (and added the public holiday handling).

I hope you find it useful!

My next task will be to add another App that adds a Controlled Load feed (off-peak hot water) to the Time of Use feed.

1 Like

Ok, thanks. I will await the merge … The screenshot Trystan put up looks good!

@Greebo, while awaiting the merge, would you mind educating me on how to preview your app, given that I have downloaded the zip file? I have Windows and Ubuntu machines. Many thanks.

On your local emoncms server (Raspberry Pi with emonBase in my case), log in with ssh using your “pi” account. If the Ubuntu machine is running your emoncms, log into that with whatever user account you have that will have access to write to /var/www/emoncms

From the command line, run the following commands:

rpi-rw 
cd /var/www/emoncms/Modules
mv app app_orig
git clone https://github.com/greeebs/emoncms-app.git
mv emoncms-app app
cd app
git checkout tou_au

Those commands do this:

  • Put the file system in read/write mode (assuming you’re using the low-write SD version for the RPi)
  • Change current directory to the webserver Modules directory
  • Rename the existing app folder to app_orig
  • Download my repository directly from GitHub
  • Rename the folder that git created when cloning my repository
  • Change directory to the newly renamed app folder containing my version
  • Switch to the git branch with my changes in it.

If you go to the Apps module in your local emoncms web interface, you should see the new “Time of Use - flexible” app there.

To put it all back, just delete the app folder and put the old one that you copied out of the way back into place (assumes you followed the above exactly):

rpi-rw
cd /var/www/emoncms/Modules
rm -rf app
mv app_orig app

Excellent. Thanks very much.

This is great. A couple of points - I have entered UK pound symbol (£)in setup but it is still showing the $ symbol in cost mode display (for Totals and Averages). The £ symbol displays correctly in the bar graph hover display, except for the Total figure. Also the Use Today data is from the previous, not current day. There is no data displayed for the current day.

Do you have any issues with Daylight Saving? My electricity meter works on GMT alone (i.e. it ignores BST), so in the summer I have to manually adjust any power consumption to coincide with GMT rather than BST. Emoncms automatically adjusts for BST. Are the tier start times tied to GMT, or will that adjust according to the time zone that the EmonPi is set to?

Nice work @Greebo I didn’t add the complexity of different weekend rates into my code, although it could do with it!

This is my Cost Comparison app which was added into emonCMS a few weeks ago, for comparision.

The key difference is the ability to select different tariffs so you can compare potential energy providers on your “real data”. You also get a 30 minute breakdown of the energy use over a period of time so can see when your peak usage point are.

1 Like

Thanks @stuart, The 30 minute breakdown is a really nice feature!

I’ll take a look at the erroneous $, it must be hardcoded in a few places.
The Use Today really should be today’s use - it certainly is on mine. The “Time Of Use” Development app that I started with did not handle that situation so I made a specific effort to include it. I’ve even tested it just after midnight to ensure it ticked over correctly. Would you mind helping to debug it?

It’s all client side, so it uses whatever your browser thinks the time is. It should work perfectly fine with or without.

@Greebo the underlying time of use API is affected by the timezone setting in the user profile. which handles BST etc. To see the current day you usually have to make sure this setting aligns with your browser timezone.

The “daily” API might, but I’m not using that. Unless I’m completely misunderstanding the code…
Each of the calls specify a “start” and “end” time in javascript milliseconds. These are all from the perspective of the browser as far as I can tell.

EDIT: I just did some testing and there is definitely a weird interaction of timezones going on, which may be why @Westerner isn’t seeing today’s usage. I set the emoncms user profile to a different timezone to my browser to test it.
The specific calculations for the tiers are definitely calculated based on the browser timezone, but I’ll have to dig a little deeper to work out which exact data is returned from the API.

Here’s the call to the time of day function:

var elec_result = feed.getdataDMY_time_of_use(feeds["use_kwh"].id,start,end,"daily",JSON.stringify(hourly));

https://github.com/emoncms/app/blob/master/apps/timeofuse2.php#L673

and the related function call in the feed_controller:

Thanks Trystan, I’m definitely going to dig a little deeper.