Git Product home page Git Product logo

e3dc-rest's Introduction

e3dc-rest

This is a simple REST API to access a E3DC system

Getting Started

This script uses a Python library which can be found here: https://github.com/fsantini/python-e3dc and exposes the values as REST API endpoints.

The API uses exposed environment variables to access the E3DC.

Configuring the E3DC correctly

  • ToDo...

Local startup

You need to export the variables so the script can read them

# IP address of your local E3DC system
export E3DC_IP_ADDRESS='192.168.1.99'
# username as used to log into the E3DC web portal
export E3DC_USERNAME='[email protected]'
# password as used to log into the E3DC web portal
export E3DC_PASSWORD='Passw0rd'
# The E3DC RSCP Password (encryption key), as set on the device under Main Page -> Personalize -> User profile -> RSCP password
export E3DC_KEY='secretkey'
# Password to protect e3dc-rest api
export ADMIN_PASSWORD='admin'

Create a self contained environment

python3 -m venv .venv

then you can go into the new made environment and install the requirements

source .venv/bin/activate
pip3 install -r requirements.txt

Dev Webserver:

cd api
python3 api.py

or use

cd api
gunicorn --bind 0.0.0.0:8080 wsgi:app --access-logfile -

Container/Kubernetes

Prebuild images are pushed to ghcr.io/vchrisb/e3dc-rest with tags latest, sha-xxxxxx and version 0.0.x available. Latest tags can be found here: https://github.com/vchrisb/e3dc-rest/pkgs/container/e3dc-rest

Build

docker build . -t e3dc-rest

Docker

docker run --name e3dc-rest -p 8080:8080 -e E3DC_IP_ADDRESS -e E3DC_USERNAME -e E3DC_PASSWORD -e E3DC_KEY -e ADMIN_PASSWORD="admin" ghcr.io/vchrisb/e3dc-rest:latest

Kubernetes

Create Secret:

kubectl create secret generic e3dc-secret --from-literal=username='[email protected]' --from-literal=password='password' --from-literal=ip_address='192.168.1.99' --from-literal=key='password' --from-literal=config='{}' --from-literal=admin_password='admin'

Deploy with Ingress Controller:

kubectl apply -f ingress.yml -f service-ingress.yml -f deplyoment.yml

Calling the API

curl http://admin:admin@localhost:8080/api/poll
curl -H "Content-Type: application/json"  -X POST -d '{"powerLimitsUsed": true,"maxChargePower": 1000,"maxDischargePower": 1300,"dischargeStartPower": 65}' http://admin:[email protected]:8080/api/power_settings
curl http://admin:admin@localhost:8080/api/power_settings 

e3dc-rest's People

Contributors

vchrisb avatar spali avatar dependabot-preview[bot] 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.