Skip to content

Telegram Bot that provides Eskom Loadshedding updates - running on AWS Serverless

Notifications You must be signed in to change notification settings

jojo786/loadshedding-power-updater-bot

Repository files navigation

Loadshedding Power Updater Telegram Bot

Power Updater is an app that provides Eskom Loadshedding updates - running on AWS Serverless. Users can interact with Power Updater in two ways:

  1. A Telegram bot: @PowerUpdatedBot
  2. A web front-end: https://powerupdater.hacksaw.co.za/

The app pulls the Eskom loadshedding stage and schedule info from https://loadshedding.eskom.co.za/LoadShedding/, and makes it available as a Telegram bot and Flask web app. You can interact with the bot directly and request the loadshedding using the /schedule command, and/or the bot can be added to your Telegram community groups/channels, and it will post the schedule for your area.

The bot will post the following information five times a day (or depending on the EventBridge Schedule):

Buccleuch Loadshedding Notice 
Stage 6  
The loadshedding schedule for today - Sun, 16 Apr: 
 16:00  -  20:30 (4 hours)
  
The loadshedding schedule for tomorrow - Mon, 17 Apr: 
 06:00  -  08:30
 14:00  -  18:30 (4 hours)
 22:00  -  02:30

The bot also supports you asking it for the schedule on an ad-hoc basis using the /schedule command.

The bot has a web front-end: https://powerupdater.hacksaw.co.za/ - where you can see the list of areas and schedules.

Loosely-based off https://github.com/daffster/mypowerstats, but completly re-written.

Architecture

For a detailed view of the architecture, read my blog about how this uses choreography and orchestration

architecture

  1. get_schedule_lambda.py Lambda function gets invoked via an EventBridge schedule to call the Eskom loadshedding status endpoint and get the loadshedding stage. This is stored on DynamoDB, for each area/location/suburb.
  2. A filter is setup on DynamoDB Streams to send changes to the notification_lambda.py Lambda function. If the loadshedding stage has changed, the new stage will be sent, which will be posted to Telegram.
  3. Once a day, get_schedule_lambda.py Lambda function gets invoked via an EventBridge schedule to call the Eskom loadshedding schedule endpoint and store the schedule in DynamoDB.
  4. A filter is setup on DynamoDB Streams to send changes to the notification_lambda.py Lambda function. If the loadshedding schedule has changed, it will be posted to Telegram
  5. Every 2 hours, notification_lambda.py Lambda function gets invoked via cron schedule (EventBridge rule) to send loadshedding reminders. It reads the latest stage and schedule from DynamoDB, and posts to Telegram

How to run it

  • Create your bot using BotFather, and take note of the token, e.g. 12334342:ABCD124324234

  • Use AWS SAM to build and deploy to AWS:

  • To build and deploy your application for the first time, run the following in your shell:

sam build
sam deploy --guided

For future deploys, you can just run:

sam build && sam deploy

TODO

  • Even though area is a field in the DB, need to configure it properly for multiple areas
  • Pull announcements from https://twitter.com/Eskom_SA

About

Telegram Bot that provides Eskom Loadshedding updates - running on AWS Serverless

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages