py-nissan-leaf-obd-ble
Python hardware API for Nissan Leaf OBD-II over BLE dongles.
This library encapsulates the low-level BLE, ELM327 and CAN protocol handling
used by the Home Assistant nissan_leaf_obd_ble integration, and exposes a
simple async API for querying vehicle data from a BLEDevice.
It has no Home Assistant dependency and can be used in other Python applications that talk to the same BLE OBD dongle.
Installation
Once published on PyPI:
pip install py-nissan-leaf-obd-ble
Quickstart
import asyncio
from bleak import BleakScanner
from py_nissan_leaf_obd_ble import NissanLeafObdBleApiClient
async def main() -> None:
# Discover your OBDBLE device with bleak, or obtain a BLEDevice from elsewhere
device = await BleakScanner.find_device_by_address("AA:BB:CC:DD:EE:FF", timeout=10.0)
if device is None:
raise RuntimeError("Could not find OBDBLE device")
client = NissanLeafObdBleApiClient(device)
data = await client.async_get_data()
print(data)
if __name__ == "__main__":
asyncio.run(main())
Configurable BLE UUIDs
The default GATT service and characteristic UUIDs match the LeLink OBD BLE dongle. When used with the Home Assistant integration, the service and read/write characteristic UUIDs are configurable per device in the UI. For custom use, async_get_data(options=None) accepts an optional options dict with keys service_uuid, characteristic_uuid_read, and characteristic_uuid_write; omit keys to use the library defaults.
Custom commands
async_get_data() accepts two optional parameters for adapting to different Leaf generations or adding new PIDs without modifying this package:
extra_commands— adict[str, OBDCommand]that is merged with the defaultleaf_commands. Keys matching existing commands replace them; new keys are appended.disabled_commands— aset[str]of command names to skip entirely.
from py_nissan_leaf_obd_ble import NissanLeafObdBleApiClient
from py_nissan_leaf_obd_ble.OBDCommand import OBDCommand
def my_decoder(messages):
d = messages[0].data
return {"ambient_temp": (d[3] - 40) * 0.5}
custom = {
"ambient_temp": OBDCommand(
"ambient_temp", "Ambient temperature", b"0322115e", 4, my_decoder, header=b"797"
)
}
data = await client.async_get_data(extra_commands=custom, disabled_commands={"unknown"})
When called from the Home Assistant integration, extra_commands and disabled_commands are populated automatically from the user's overrides.yaml; see the integration README for details.
License
This package includes code derived from python-OBD (a derivative of pyOBD), licensed under the GNU General Public License, version 2 or later.
See LICENSE for full terms.
Metadata
Release files for py-nissan-leaf-obd-ble 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| py_nissan_leaf_obd_ble-0.1.2.tar.gz | 26.7 kB | Without provenance | Details for py_nissan_leaf_obd_ble-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py_nissan_leaf_obd_ble-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for py_nissan_leaf_obd_ble-0.1.2-py3-none-any.whl |
Total release size: 61.7 kB
Release files / py_nissan_leaf_obd_ble-0.1.2.tar.gz
| Download URL | py_nissan_leaf_obd_ble-0.1.2.tar.gz |
|---|---|
| Size | 26.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
604af73c7faa6e1173dce7f0ec61ea8730dd15528bb36d435a8d0e6a726d7ef8
|
|
BLAKE2b-256 checksum How to use checksums |
d237cac8d0f61a43a762f6b0d40f5cb139edfcb8e88baa913319b2873f8682bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.11.1 Darwin/25.3.0
|
Release files / py_nissan_leaf_obd_ble-0.1.2-py3-none-any.whl
| Download URL | py_nissan_leaf_obd_ble-0.1.2-py3-none-any.whl |
|---|---|
| Size | 35.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
12369f55d8a97e36b19828835bfbb4034a79fc0990a23a25794596afb6603b29
|
|
BLAKE2b-256 checksum How to use checksums |
8ba3efaa59fddd45d31bad88273ffa8e821a5cc2ad9c383acdc5c841286b0402
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.11.1 Darwin/25.3.0
|
Security for py-nissan-leaf-obd-ble 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.