Git Product home page Git Product logo

ssardina / ev-energy-demand-manager Goto Github PK

View Code? Open in Web Editor NEW

This project forked from angelara/ev-energy-demand-manager

0.0 0.0 0.0 211 KB

Python daemon job to control home load. Includes a web browser to set threshold price, switching off power plugs when wholesale price (using Amber electric API) is above the threshold.

License: Apache License 2.0

Python 3.18% HTML 1.10% Jupyter Notebook 95.72%

ev-energy-demand-manager's Introduction

You can deploy this codebase on a Raspberry Pi. It works with the Rasperry Pi Zero, which is the less expensive version, up to the latest one. The next task is to get one of the smart-plugs available in your local hardware-store. We used a TP-link tapo p110, available in Bunnings. Finally, perhaps most importantly, you will need to change your retailer to Amber Electric to be able to use their API and be exposed to the electricity wholesale market price. Once you are set up as a customer, you must create an API Token.

Setup

install the following libraries

sudo apt-get install libatlas-base-dev
pip install Flask gunicorn
pip install git+https://github.com/almottier/TapoP100.git@main
pip install amberelectric
pip install matplotlib
pip install python-daemon
pip install schedule

Install the following libraries as a superuser to allow the code to be initiated by the system. See below the settings for cron.

sudo pip install Flask gunicorn
sudo pip install git+https://github.com/almottier/TapoP100.git@main
sudo pip install amberelectric
sudo pip install schedule
sudo pip install python-daemon

Service

Edit the setting.json file. It has the following variables needed to connect to your plug and connect to Amber.

{
    "configFile" : "<fullpath>/home-energy-demand-manager/webapp/config.json",
    "smartPlugIP" : "yourSmartPlugIP",
    "smartPlugUsername" : "yourUsername",
    "smartPlugPass": "yourPass",
    "amberToken": "yourAPItoken",
    "logFile" : "/tmp/amber_service.log"
}

The logFile will contain the result of each query to Amber's API, whether the smart plug has been switched off/on, and whether the threshold price has changed. This is an example of the log content:

2023-10-16 14:10:53,944 - INFO - NEM 2023-10-16 13:30 - Threshold 15 & current price is 9.08895 cents. The plug stateOn = True has not been changed
2023-10-16 14:20:55,866 - INFO - NEM 2023-10-16 13:30 - Threshold 15 & current price is 9.10343 cents. The plug stateOn = True has not been changed
2023-10-16 14:30:58,181 - INFO - NEM 2023-10-16 14:00 - Threshold 15 & current price is 9.47102 cents. The plug stateOn = True has not been changed
2023-10-16 14:37:48 - New Threshold has been set via the webapp with value 13

The logfile will be in the temporal folder and removed whenever your system restarts. If you want a persistent logFile, change it to another folder.

To run the scheduled jobs every 10 minutes

python3 amber_service.py 

Webserver

To run the webserver to monitor the service and update the threshold if needed

gunicorn -c gunicorn_config.py app:app

Schedule as a Daemon (Cron on reboot)

To make sure the service runs when the raspberry pi starts, edit crontab as follows:

crontab -e

Add the following line, making sure the path points to where the script is located.

@reboot cd <fullpath>/home-energy-demand-manager/ && sudo python3 amber_service.py
@reboot cd <fullpath>/home-energy-demand-manager/webapp/ && sudo gunicorn -c gunicorn_config.py app:app

Explore Amber's API

Check the exploration python notebook

ev-energy-demand-manager's People

Contributors

angelara avatar

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.