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.2

  • Re-login when the gateway reports the session was taken over by another login (code 2).

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.2

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.2
File Size Uploaded Provenance Actions
mg_ismart_india_client-0.3.2.tar.gz 38.6 kB With provenance Details for mg_ismart_india_client-0.3.2.tar.gz

Built distribution (wheel)

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

Total release size: 67.5 kB

Release files / mg_ismart_india_client-0.3.2.tar.gz

Download URL mg_ismart_india_client-0.3.2.tar.gz
Size 38.6 kB
Tags Source
SHA-256 checksum
How to use checksums
85e9376d67d29e4aa392467335e91324d1f9480373ddd4337a67562b5ddb7f67
BLAKE2b-256 checksum
How to use checksums
b548e85b39815f23328b6214e63c8dec3e00c22623e64ba57e58af67c6d37545
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.2-py3-none-any.whl

Download URL mg_ismart_india_client-0.3.2-py3-none-any.whl
Size 28.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
df84ae01c7826acbf5414f1b75e491f586ae0f505ca5d3517ad88a02e9455845
BLAKE2b-256 checksum
How to use checksums
e1d217512bde06acbcabc63575525637e51439a2d39063eb090093b351b99d2e
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.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.

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.2.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