A Telegram bot for monitoring spot prices of electricity. To sauna or not to sauna, that is the question.
The app pulls hourly spot prices for Nord Pool and adds electricity company margin, Finnish VAT, grid transfer fees and electricity tax to the spot prices, so all values shown are total prices per kWh. Therefore, even when the spot price is zero, the final price is around ~6-7 eurocents per kWh.
npm install
npm run build
npm run start
By default, when ran locally, the program will do a dryrun, printing the price data, the text messages that would be sent to Telegram, and outputs the price graph as graph.png into the root of the repo. It will call the upstream API for the prices, but it will not call Telegram API.
In order to send messages to Telegram, you'll need to setup a Telegram bot and a chat, and either disable the local dryrun in the handler, or deploy the program to AWS Lambda where it will not run in dryrun mode.
npm run build
npm run lint
npm run test:unit
npm run test:integration
Unit tests can be run completely offline, while integration tests call the remote API. Use npm run test to run all tests.
Unfortunately, there's several manual steps to completely deploy this project:
- Setup working AWS CLI credentials
- Install node-canvas lambda layer as a Serverless Application into your AWS account. We render the price chart using Chart.js, but its prerequisite node-canvas is too big to bundle into a lambda function, so we'll use a layer that handles it.
- Download a font
.ttffile that you want to use in the chart, and include it in therender.ts. - Setup a Telegram bot with BotFather and get your secret bot auth token and chat ID
Install Pulumi CLI and configure your stack:
npm install
npm run build
pulumi install
export AWS_PROFILE=heap
pulumi login s3://heap-pulumi-state/elektro-scrooge
pulumi stack init dev
pulumi config set aws:region eu-west-1
pulumi config set --secret telegram_bot_auth_token <your-bot-token>
pulumi config set --secret telegram_chat_id <your-chat-id>
Deploy:
export AWS_PROFILE=heap
npm run deploy
To remove all resources:
export AWS_PROFILE=heap
npm run pulumi:destroy

