Skip to main content

Python client library for EV-Meter electric vehicle chargers via MQTT

Project description

EV-Meter Client

A Python client library for EV-Meter electric vehicle chargers that communicate via MQTT using the BLEWIFI protocol.

PyPI version Python versions License: MIT

Features

  • Async MQTT client for EV-Meter chargers
  • Binary protocol parsing for BLEWIFI messages
  • Comprehensive data models with 25+ fields
  • Real-time monitoring of charging sessions
  • 3-phase electrical measurements (voltage, current, power)
  • Energy tracking (session and lifetime totals)
  • Diagnostic information (warnings, errors, WiFi status)

Installation

pip install evmeter-client

Quick Start

import asyncio
from evmeter_client import EVMeterClient, EVMeterConfig

async def main():
    # Configure with your charger details
    config = EVMeterConfig(
        user_id="your-user-id-hex-string"
    )
    
    # Create client and connect
    client = EVMeterClient(config)
    await client.connect()
    
    try:
        # Get charger status
        status = await client.get_charger_status("YOUR_CHARGER_ID")
        print(f"Charger Status: {status.charger_state}")
        print(f"EV Status: {status.ev_status}")
        print(f"Power: {status.power_kw} kW")
        
        # Get detailed metrics
        metrics = await client.get_charger_metrics("YOUR_CHARGER_ID")
        print(f"Session Energy: {metrics.session_energy_kwh} kWh")
        print(f"Voltage L1: {metrics.voltage_l1} V")
        print(f"Current L1: {metrics.current_l1} A")
        
    finally:
        await client.disconnect()

# Run the example
asyncio.run(main())

Configuration

The library connects to the EV-Meter MQTT broker with hardcoded settings:

config = EVMeterConfig(
    user_id="your-hex-user-id",  # Required: Your unique user ID
    mqtt_host="mqtt.evmeter.com",  # Fixed
    mqtt_port=1883,  # Fixed
    mqtt_username="deviceEV",  # Fixed
    mqtt_password="ng4GycjMmuvpSJU6"  # Fixed
)

Only the user_id needs to be configured - get this from your EV-Meter app or MQTT logs.

Data Models

ChargerStatus

  • charger_state: Current charger state (IDLE, CHARGING, ERROR, etc.)
  • ev_status: EV connection status (NOT_CONNECTED, CONNECTED, WANTS_TO_CHARGE, etc.)
  • charging_state: Detailed charging state (1_PHASE, 3_PHASE, WAITING, etc.)
  • power_kw: Real-time power consumption
  • session_energy_kwh: Current session energy
  • total_energy_kwh: Lifetime energy total
  • warnings: Warning count
  • errors: Error count

ChargerMetrics

  • 3-Phase Electrical: Individual and average voltage/current for all phases
  • Energy: Session and total energy with precise measurements
  • Configuration: Set current limit, circuit breaker rating
  • System: Temperature, WiFi RSSI, firmware versions
  • Diagnostics: EVSE status, ping latency, peer serial number

Protocol

The library implements the BLEWIFI protocol used by EV-Meter chargers:

  • Command Topic: /BLEWIFI/Chargers/{charger_id}
  • Response Topic: /BLEWIFI/users/{user_id}
  • Binary Payloads: Custom binary format with comprehensive working info

MQTT Monitoring Utility

The package includes a command-line utility for monitoring all MQTT traffic on the EV-Meter broker:

# After installing the package
evmeter-monitor

This utility will:

  • Connect to the EV-Meter MQTT broker
  • Subscribe to all topics (# wildcard)
  • Display all messages with timestamps
  • Attempt to parse payloads and show both raw and parsed data
  • Show parsing failures for non-BLEWIFI messages

Example output:

[2025-11-08 13:06:29.608] Topic: /device/state/0000000000208348
Raw payload: Text: left
✗ Parsing failed: fromhex() argument must be str, not bytes
------------------------------------------------------------

[2025-11-08 13:06:30.123] Topic: /BLEWIFI/users/1234567890abcdef
Raw payload: Hex: aa 55 17 00 01 02 03 04 05 06 07 08 09 0a 0b 0c (24 bytes)
✓ Parsing succeeded!
Parsed data:
{
  "charger_state": "CHARGING",
  "ev_status": "CONNECTED",
  "power_kw": 7.2,
  "session_energy_kwh": 12.5
}
------------------------------------------------------------

You can also run the standalone script:

python mqtt_monitor.py

Error Handling

from evmeter_client.exceptions import EVMeterError, EVMeterTimeoutError

try:
    status = await client.get_charger_status("CHARGER_ID")
except EVMeterTimeoutError:
    print("Charger didn't respond in time")
except EVMeterError as e:
    print(f"EV-Meter error: {e}")

Development

# Clone the repository
git clone https://github.com/yourusername/evmeter-client.git
cd evmeter-client

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Format code
black .
ruff check .

Home Assistant Integration

This library is used by the EV-Meter Home Assistant integration to provide comprehensive monitoring of EV-Meter chargers in Home Assistant.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Changelog

v1.0.0

  • Initial release
  • Full BLEWIFI protocol support
  • Comprehensive data models
  • Async MQTT client
  • Real-time monitoring capabilities

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

evmeter_client-1.2.1.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

evmeter_client-1.2.1-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file evmeter_client-1.2.1.tar.gz.

File metadata

  • Download URL: evmeter_client-1.2.1.tar.gz
  • Upload date:
  • Size: 21.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for evmeter_client-1.2.1.tar.gz
Algorithm Hash digest
SHA256 9c7f00e0494af41532a10a748f2c7445a60991ccc238b9aacb835fff0fb3392a
MD5 2e3f9f0a4a0b8679fa2fcc1612a654e2
BLAKE2b-256 c13ab14fff27e93f09b6084f663e69bf750ded1bdb1280ba306148b0953867c0

See more details on using hashes here.

File details

Details for the file evmeter_client-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: evmeter_client-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for evmeter_client-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5dbc4eb2decddc6c9d9b96e1dfd613e137aaddb76e8bdfcf82d74affbb2a80ee
MD5 92ab4ba4e689a097d82ab10e816526f8
BLAKE2b-256 5ee2e180b58ea6cb2d2fd889d1301423a667dfe5bb33a34c8a722740224c35e7

See more details on using hashes here.

Supported by

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