Coder Social home page Coder Social logo

wallbox-python's Introduction

wallbox

Python Module interface for Wallbox EV chargers api

Requirements

Python 3.7 or older Python modules "requests>=2.22.0", "simplejson>=3.16.0"

Python module "aenum>=3.1.8"

Installation

pip install wallbox

Implemented methods

authenticate()

  • authenticates to the wallbox api.

getChargersList()

  • returns a list of chargers available to the account

getChargerStatus(chargerID)

  • returns a dictionary containing the charger status data

unlockCharger(chargerId)

  • unlocks charger

lockCharger(chargerId)

  • locks charger

setMaxChargingCurrent(chargerId, chargingCurrentValue)

  • sets charger Maximum Charging Current (Amps)

pauseChargingSession(chargerId)

  • pauses a charging session

resumeChargingSession(chargerId)

  • resumes a charging session

getSessionList(chargerId, startDate, endDate)

  • provides the list of charging sessions between startDate and endDate
  • startDate and endDate are provided in Python datetime format (i.e. 2021-05-04 08:41:12.765644)

setEnergyCost(chargerId, energyCost)

  • sets the energy cost for the charger per kWh

restartCharger(chargerId)

  • restarts (reboots) charger
  • a full charger reboot can take a few minutes. Charger status will be slow to update (ie: READY (10s) -> DISCONNECTED (90s) -> READY) CAUTION: use this method with care!! Check if the charger is not in the middle of a firmware upgrade as this can brick your charger.

Simple example

from wallbox import Wallbox, Statuses
import time
import datetime

w = Wallbox("user@email", "password")

# Authenticate with the credentials above
w.authenticate()

# Print a list of chargers in the account
print(w.getChargersList())

# Get charger data for all chargers in the list, then lock and unlock chargers
for chargerId in w.getChargersList():
    chargerStatus = w.getChargerStatus(chargerId)
    print(f"Charger Status: {chargerStatus}")
    print(f"Lock Charger {chargerId}")
    endDate = datetime.datetime.now()
    startDate = endDate - datetime.timedelta(days = 30)
    sessionList = w.getSessionList(chargerId, startDate, endDate)
    print(f"Session List: {sessionList}")
    w.lockCharger(chargerId)
    time.sleep(10)
    chargerStatus = w.getChargerStatus(chargerId)
    print(f"Charger {chargerId} lock status {chargerStatus['config_data']['locked']}")
    print(f"Unlock Charger {chargerId}")
    w.unlockCharger(chargerId)
    time.sleep(10)
    chargerStatus = w.getChargerStatus(chargerId)
    print(f"Charger {chargerId} lock status {chargerStatus['config_data']['locked']}")
    # Set charger Energy Cost to 0.1€/kWh
    energyCost = w.setEnergyCost(chargerId, 0.1)
    print(f"Charger {chargerId} energy cost {energyCost['energy_price']} {energyCost['currency']['symbol']}")

    # Print the status the charger is currently in using the status id
    print(f"Charger Mode: {Statuses(chargerStatus['status_id']).name}")

wallbox-python's People

Contributors

cliviu74 avatar hesselonline avatar florian7843 avatar matz694 avatar flix6x avatar jeremy-compostella avatar victor-falcon avatar angelbarrera92 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.