Skip to main content

Module for interacting with Wallbox EV charger api

Project description

wallbox

Python Module interface for Wallbox EV chargers api

Requirements

Python 3.7 or older

Python module "requests>=2.22.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

resumeSchedule(chargerId)

  • revert charger back to default schedule after manually starting a charging session, it reverts the charger back into "Eco Smart and Scheduled" charing mode, if used.

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.

updateFirmware(chargerId)

  • trigger a firmware update when available.

setIcpMaxCurrent(chargerId, newIcpMaxCurrentValue)

  • sets charger Maximum ICP Current available (Amps).

Please note that the wallbox may refuse this action if not setup properly of if not supported by your model

getChargerSchedules(chargerId)

  • gets the currently configured schedules for that charger.

Response is a JSON structure like the following:

{
    'schedules': [{
        'chargerId': 42,
        'enable': 1,
        'max_current': 1,
        'max_energy': 0,
        'days': {'friday': true, 'monday': true, 'saturday': true, 'sunday': true, 'thursday': true,
                    'tuesday': true, 'wednesday': true},
        'start': '2100',
        'stop': '0500'
    }]
}

setChargerSchedules(chargerId, newSchedules)

  • Create or replace an existing schedule.

newSchedules is a dictionary like the following:

{
    'schedules': [{
        'id': 0,
        'chargerId': 42,
        'enable': 1,
        'max_current': 1,
        'max_energy': 0,
        'days': {'friday': true, 'monday': true, 'saturday': true, 'sunday': true, 'thursday': true,
                    'tuesday': true, 'wednesday': true},
        'start': '2100',
        'stop': '0500'
    }]
}

As schedules returned by getChargerSchedules are positional, the id field in the payload represents the position of the schedule to add/replace.

enableEcoSmart(chargerId, mode)

  • Enable Eco Smart (called Solar Charging in the app)

Valid modes:

  • 0: Eco smart
  • 1: Full solar

disableEcoSmart(chargerId)

  • Disable Eco Smart (called Solar Charging in the app)

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}")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wallbox-0.9.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

wallbox-0.9.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file wallbox-0.9.0.tar.gz.

File metadata

  • Download URL: wallbox-0.9.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for wallbox-0.9.0.tar.gz
Algorithm Hash digest
SHA256 34ec38b95da10f5a1a2ef15768159190bec2597c2027e0df8730df66df62106c
MD5 3db6179205b493930468030186aa30c5
BLAKE2b-256 ff516ea41031af8ca633a5478275f588398e7c71fb7e111b8af698855012cda1

See more details on using hashes here.

File details

Details for the file wallbox-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: wallbox-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for wallbox-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2f2cb1fa79028d50d2e104d904e10a5e9142b7c2f8a8df870aacd7e06bb160de
MD5 c56c3142bcc400f26eac1afa16176dd8
BLAKE2b-256 ab5a6aae8f6f8644beca5ab66332fea5e45a28f0f043c8ccd902572f0f160508

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page