This release is a pre-release and may not be stable for production use.
python-evnex
Python client for the Evnex API.
Author not affiliated with Evnex.
Features
- Talks to your Evnex charger via Cloud API
- Automatic retries with exponential backoff
- Automatic re-authentication
- Optionally pass in a
httpxclient - Optionally pass in tokens to resume an existing session
Installation
pip install evnex
Requirements: Python 3.11+
Usage
EvnexAuth handles signing in and keeping the session alive; the Evnex
client uses it to call the API. Credentials establish a session once and are
never stored:
import asyncio
import os
from evnex.api import Evnex
from evnex.auth import EvnexAuth
async def main():
auth = EvnexAuth()
await auth.start_authentication(
os.environ["EVNEX_CLIENT_USERNAME"],
os.environ["EVNEX_CLIENT_PASSWORD"],
)
evnex = Evnex(auth=auth)
user = await evnex.get_user_detail()
for org in user.organisations:
for entry in await evnex.get_org_insight(days=7, org_id=org.id):
print(org.name, entry)
asyncio.run(main())
Multi-factor authentication
If the account has MFA enabled, start_authentication returns an
AuthChallenge instead of tokens. Show it to the user, collect their
6-digit code, and answer it:
from evnex.auth import AuthChallenge
result = await auth.start_authentication(username, password)
while isinstance(result, AuthChallenge):
code = input(f"Enter the 6-digit code ({result.name}): ")
result = await auth.respond_to_challenge(result, code)
Challenges are short-lived (a few minutes): ChallengeExpiredError means
start over, while InvalidChallengeResponseError means the code was wrong
and the same challenge can be retried. A challenge serializes to JSON
(to_dict()/from_dict()), so a web backend or config flow can answer it
in a later request or another process.
Staying signed in
Store the tokens and resume later — the refresh token alone is enough, no
password or MFA prompt. Expired sessions renew automatically; register
on_token_update to be handed every newly issued token set, and it will
have completed before any request uses the new tokens, so your stored copy
can never fall behind one that's already in use:
from evnex.auth import EvnexAuth, TokenSet
async def save_tokens(tokens: TokenSet) -> None:
my_store.write(tokens.to_dict())
auth = EvnexAuth(
tokens=TokenSet.from_dict(my_store.read()),
on_token_update=save_tokens,
)
evnex = Evnex(auth=auth)
user = await evnex.get_user_detail()
If a request is rejected mid-session, the client refreshes and retries it
once, transparently. When the session truly can't be renewed, calls raise
ReauthenticationRequiredError — run the interactive sign-in again.
See examples/get_token.py for a complete sign-in and persistence flow.
Managing MFA devices
The EVNEX app doesn't currently expose changing or removing your MFA device;
the API does, and EvnexAuth wraps it (requires a signed-in session):
status = await auth.get_mfa_status() # which methods are enabled
enrollment = await auth.begin_totp_enrollment()
print(enrollment.provisioning_uri("you@example.com")) # render as QR code
await auth.confirm_totp_enrollment(code, device_name="New phone")
await auth.set_mfa_preference(totp=True) # turn TOTP on / make preferred
await auth.set_mfa_preference() # disable MFA entirely
Completing a new TOTP enrollment replaces the previously registered authenticator device.
Changing or resetting your password
EvnexAuth also manages the account password:
# Change the password of a signed-in account:
await auth.change_password(current_password, new_password)
# Reset a forgotten password (no session needed):
destination = await auth.start_password_reset("you@example.com") # masked email
await auth.confirm_password_reset("you@example.com", emailed_code, new_password)
The CLI equivalents are evnex auth change-password (prompts for the current
and new password) and evnex auth reset-password (sends a code to your email,
then prompts for the code and a new password).
Command line
Everything above is also available as a CLI, runnable directly with uv:
export EVNEX_CLIENT_USERNAME=you@example.com
export EVNEX_CLIENT_PASSWORD=<your password>
uvx evnex auth login # sign in (uses cached tokens when valid)
uvx evnex auth status # signed-in user, session, and MFA state
uvx evnex auth logout # forget the cached session
uvx evnex auth mfa enable # enroll a TOTP device and turn MFA on
uvx evnex auth mfa disable # turn MFA off entirely
uvx evnex auth change-password # change your password (prompts)
uvx evnex auth reset-password # reset a forgotten password via email
uvx evnex status # live view: connectors, power, sessions
uvx evnex charge-points list # id, name, serial, network status
uvx evnex charge-points show # detail for one charge point
uvx evnex sessions list # recent charging sessions
uvx evnex locations list # name, city, ICP number, retailer, timezone
uvx evnex insights # daily energy, cost, and session counts
uvx evnex charge now # start charging immediately
uvx evnex charge auto # return to the configured schedule
uvx evnex charge stop # stop the active charging session
uvx evnex schedule show # the configured charging schedule
The resource commands pick the charge point automatically when the account has
only one; otherwise select it with --charge-point ID, where ID is a charge
point id or a part of its name or serial of its name or serial. Add --json to status,
the listings, and schedule show for a machine-readable document on stdout:
uvx evnex status --json
evnex auth status shows who you are signed in as (decoded from the cached
token), when the session expires, and which MFA methods are enabled.
evnex auth mfa enable is the interactive one-shot: it prints an otpauth://
URI (paste it straight into a password manager's one-time password field),
the bare secret, and a QR code, then asks for a code from the new device and
makes TOTP the preferred method. For automation, the same flow is split into
evnex auth mfa enroll (print the URI/secret/QR and exit) and
evnex auth mfa confirm CODE (verify and enable; --no-prefer registers the
device without changing the MFA preference). The QR code renders in the
terminal, or in the browser with --browser.
Session tokens are cached (mode 0600, ~/.cache/evnex/tokens.json by default,
or EVNEX_TOKEN_CACHE) so an MFA sign-in is only needed occasionally. To
answer sign-in challenges from a password manager instead of typing codes —
for example with the 1Password CLI
v2+:
uvx evnex auth login --otp-command 'op item get Evnex --otp'
Examples
python-evnex is intended as a library, but a few example scripts are provided in the examples folder.
Providing authentication for the examples is via environment variables, e.g. on nix systems:
export EVNEX_CLIENT_USERNAME=you@example.com
export EVNEX_CLIENT_PASSWORD=<your password>
python -m examples.get_charge_point_detail
Developer Notes
Development Setup
# Install dependencies with development tools
uv sync --group dev
# Set up pre-commit hooks (recommended)
uv run pre-commit install
# Alternatively, format and lint manually
uv run ruff format .
uv run ruff check .
Making a new release
What ends up on PyPi is what really matters. Creating a release in GitHub triggers a release workflow that builds and publishes to PyPi.
To manually release, update the version in pyproject.toml, build and publish with uv:
uv build
uv publish
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file evnex-0.7.0b2.tar.gz.
File metadata
- Download URL: evnex-0.7.0b2.tar.gz
- Upload date:
- Size: 117.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6b4743368f89ded9091f5544e9b7e07b7ba997ae738dc02404cea376da2c0d4
|
|
| MD5 |
82ce9af469b19503f49ad463640d978a
|
|
| BLAKE2b-256 |
c96f0e8cfa257bbb73f274bb6e65e7192487e1f5f9a0cbbd24246c0f18533e89
|
Provenance
The following attestation bundles were made for evnex-0.7.0b2.tar.gz:
Publisher:
ci.yml on hardbyte/python-evnex
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
evnex-0.7.0b2.tar.gz -
Subject digest:
b6b4743368f89ded9091f5544e9b7e07b7ba997ae738dc02404cea376da2c0d4 - Sigstore transparency entry: 2198750047
- Sigstore integration time:
-
Permalink:
hardbyte/python-evnex@59dd14027e77bc1194895cadcad2639653308bb9 -
Branch / Tag:
refs/tags/v0.7.0b2 - Owner: https://github.com/hardbyte
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@59dd14027e77bc1194895cadcad2639653308bb9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file evnex-0.7.0b2-py3-none-any.whl.
File metadata
- Download URL: evnex-0.7.0b2-py3-none-any.whl
- Upload date:
- Size: 42.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b8c1c4173f31fc99ba772363ef11cf4f99c7d845864d5e4771b598e8629eae5
|
|
| MD5 |
d445a83c40fa4e3c521928f7b42d3a1c
|
|
| BLAKE2b-256 |
7183dfd15f7a3cea45bdc49fff321e554016aec8991615839d6bfbbca11c5848
|
Provenance
The following attestation bundles were made for evnex-0.7.0b2-py3-none-any.whl:
Publisher:
ci.yml on hardbyte/python-evnex
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
evnex-0.7.0b2-py3-none-any.whl -
Subject digest:
2b8c1c4173f31fc99ba772363ef11cf4f99c7d845864d5e4771b598e8629eae5 - Sigstore transparency entry: 2198750197
- Sigstore integration time:
-
Permalink:
hardbyte/python-evnex@59dd14027e77bc1194895cadcad2639653308bb9 -
Branch / Tag:
refs/tags/v0.7.0b2 - Owner: https://github.com/hardbyte
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@59dd14027e77bc1194895cadcad2639653308bb9 -
Trigger Event:
release
-
Statement type: