Giter Club home page Giter Club logo

cape-town-loadshedding-schedule's Introduction

Cape Town Loadshedding Schedule

A class that can be used to fetch loadshedding times for Cape Town, South Africa based on Eskom stages 1-8. It does this all with maths instead of storing it all in tables. So the LoadSheddingSchedule class and the current Eskom loadshedding stage is all you need. Based on these tables: http://resource.capetown.gov.za/documentcentre/Documents/Procedures%2c%20guidelines%20and%20regulations/Load_Shedding_All_Areas_Schedule_and_Map.pdf

There is a javascript class with a demo on how to use the functionality and a java class for Android.

The simplest way to use it:

  1. scrape the current Eskom stage integer from their website (or elsewhere like EWN's little API https://ewn.co.za/assets/loadshedding/api/status)
  2. check if you are currently in loadshedding using isLoadSheddingNow()
  3. You can also check when the next loadshedding time is using getNextTimeSlot()

Why does this exist?

I was creating a "Kiosk" Android app for a tablet in my house to display the loadshedding status in a more custom way than existing apps. I needed the schedule but when I looked at the tables, it seemed like they were generated with simple increments. So I decided I wanted to be overly efficient for some reason and just generated what info I need on the fly instead of storing tables (and painstakingly adding all that data). It may be overboard, but it feels nice just adding a class instead of extra bloat (tables) to an app. And it was an interesting exercise in the end!

Hope it can be useful for others too :)

cape-town-loadshedding-schedule's People

Contributors

quantiversal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

biovolt

cape-town-loadshedding-schedule's Issues

Stage 5 and above error + Python implementation

Not sure if this Repo is still active, but there is a small issue.

When the stage is set to anything greater than 4, then the areas returned is not correct...
This is manifested in a number of functions, but the root of the issue can be attributed to

getAreaCodesByTimeSlot(stage, day, timeSlot)

I'm not sure if my fix for this is appropriate, but after some debugging I simply added the following to the function:
after this line:
let areaCodeAcc = this._getAreaCodeAccumulationDayStart(stage, day) + timeSlot;
added:

if(stage > 4) {
    areaCodeAcc ++
}

Technically I did not do this in Java, as my requirement was to have similar functionality in python. Instead, I created a similar set of functions in a Python file. At first I thought I made a mistake in my code, but testing the Javascript rendered the same error.

Please feel free to add it to your repo if you want to. The files are attached.

Thank you for this... Would have taken me days to create the base logic you did, and I HATED the idea of using a lookup table!
loadsheddingschedule-py.zip

OK so not an issue but I can't fathom out how to message you :(

Some seriously clever maths in that!

Have you fathomed a way or do you have a source for getting the loadshedding stage for the City of Cape town municipality? They are usually a stage better but that's a bit hit and miss for automation etc.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.