Skip to main content

MG iSMART India Client

Python client for the MG iSMART India TAP/gateway API.

This package contains the protocol/client layer used by the MG iSMART India Home Assistant work. It is intentionally separate from Home Assistant so it can be tested and released independently.

Install

pip install mg-ismart-india-client

Basic use

import aiohttp
from mg_ismart_india_client import MgIndiaClient, hash_control_pin

async with aiohttp.ClientSession() as session:
    client = MgIndiaClient(
        session,
        phone="9876543210",
        password="your-password",
        vin="YOURVINHERE",
        pin_hash=hash_control_pin("1234"),
    )

    await client.login()
    vehicles = await client.vehicles()
    status = await client.status()

    # On an EV, ask the same poll for the charging frame too: it lands on
    # status.charge (None when none arrived -- routine, not an error), and
    # saves the second round trip a separate charge_status() would cost.
    #
    # Only set this where a charging frame is expected. The loop waits for one,
    # so a vehicle that never sends it spends the full poll budget on every call.
    status = await client.status(include_charge=True)
    print(status.charge)

Control methods require a configured PIN hash. The raw 4-digit control PIN is not stored by the client.

Account notes

  • Multi-factor login (the SMS code) isn't supported yet. If it's switched on for the account, login() raises MgIndiaMfaRequired. Switching it off in the MG app's security settings lets the client log in.
  • MG India allows one login session per account. Logging in with the client signs the MG app out on the phone.

Development

python -m venv .venv
. .venv/bin/activate
pip install -e '.[dev]'
pytest -q
ruff check src tests

Release notes

0.3.0

  • Add Vehicle.is_electric.
  • Add Snapshot.battery_soc, using the charge frame's SOC or falling back to the status fuel level for EVs.
  • Add ChargeStatus.charging_power_kw.
  • Add MgIndiaMfaRequired, a subclass of MgIndiaLoginRejected, raised when the account has multi-factor login turned on.

0.2.1

  • Reject malformed responses, mismatched vehicle identities and invalid charge values.
  • Avoid resending commands when their completion is uncertain.
  • Improve session recovery and verify lock outcomes against fresh vehicle status.

License

MIT License. Copyright (c) 2026 John Lazarus.

Metadata

Release files for mg-ismart-india-client 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mg-ismart-india-client 0.3.1
File Size Uploaded Provenance Actions
mg_ismart_india_client-0.3.1.tar.gz 38.3 kB With provenance Details for mg_ismart_india_client-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mg-ismart-india-client 0.3.1
File Interpreter ABI Platform Actions
mg_ismart_india_client-0.3.1-py3-none-any.whl Python 3 none any Details for mg_ismart_india_client-0.3.1-py3-none-any.whl

Total release size: 67.1 kB

Release files / mg_ismart_india_client-0.3.1.tar.gz

Download URL mg_ismart_india_client-0.3.1.tar.gz
Size 38.3 kB
Tags Source
SHA-256 checksum
How to use checksums
7c5f19b50c6bb8fa318e81ae1e44f2d28f31b97c3bfd6f9c38c973380b5f465a
BLAKE2b-256 checksum
How to use checksums
f903a5a987f080deaf668d4dd97a4e5a047f0b2a72e650d5fbefe38c8bca28ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / mg_ismart_india_client-0.3.1-py3-none-any.whl

Download URL mg_ismart_india_client-0.3.1-py3-none-any.whl
Size 28.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3d38d0df1671e77cb83d0bfd7a200705b35ed466be0e1351d4d8dbd76ae60b6a
BLAKE2b-256 checksum
How to use checksums
7460b1e570f055f24b0e78da9ff5ea437287a1e62b0e320d5ead1e0efb65893d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Security for mg-ismart-india-client 0.3.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mg_ismart_india_client-0.3.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page