Skip to content

feat(india): expose EV charging status sensors - #302

Draft
Dr-Blank wants to merge 7 commits into
townsmcp:betafrom
Dr-Blank:feat/india-charging
Draft

feat(india): expose EV charging status sensors#302
Dr-Blank wants to merge 7 commits into
townsmcp:betafrom
Dr-Blank:feat/india-charging

Conversation

@Dr-Blank

@Dr-Blank Dr-Blank commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

What

Wires MG iSMART India EV vehicles into the existing charging sensors. The
India backend's get_charging_info now fetches the decoded charging frame from
the client and maps it onto the chrgMgmtData / rvsChargeStatus shapes the
shared charging sensors already read — so India EVs get charging state, SOC,
voltage, current, power, range, session duration and odometer with no new
sensor code.

How it maps

The client returns charging values in declared real units (volts, amps,
percent, km). This backend re-encodes them onto the global SAIC raw scales
the shared sensors decode (CHARGING_VOLTAGE_FACTOR, CHARGING_CURRENT_FACTOR,
tenths), rather than assuming the India protocol's raw field values happen to
share the global scale. rvsChargeStatus is built field by field, so every
value a sensor reads has a named source and a stated scale assumption.

  • is_charging / is_plugged_inbmsChrgSts (charging / plugged-in / unplugged)
  • Fields with no confirmed India scale (total battery capacity, mileage/energy
    since last charge) are forwarded as the vehicle's own integer, flagged in a
    comment as the line to correct if a sensor reads wrong.
  • Returns None when the vehicle sends no charging frame (coordinator handles
    it); session/protocol errors propagate so they're logged, not silently
    reported as "not charging".

Dependency

Scope

Diff is two files (backends/india.py, backends/__init__.py). Branch is behind
beta; will rebase before un-drafting.

Dr-Blank and others added 2 commits August 19, 2026 09:49
…o method for India backend

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… conversion

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Resolve conflict in india.py: purely additive, both charging-current/
duration helpers (ours) and GPS-position mapping (upstream) kept.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Dr-Blank
Dr-Blank force-pushed the feat/india-charging branch from 9f231ad to f0171c4 Compare August 19, 2026 06:06

@john-lazarus john-lazarus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't approve this yet. The unit job currently has four failures.

More importantly, beta still pins mg-ismart-india-client==0.1.5, and that published package doesn't contain charge_status(), so this code cannot run from the declared dependency. Please wait for the client change to land in a release, update the pin, and add coverage for this mapping.

powerUsageSinceLastCharge also needs a confirmed India scale before we expose it. Leave that field out until it is confirmed.

Please mark this as draft for now. Once the released dependency is in place and the full unit suite is green, re-request the review.

Dr-Blank and others added 3 commits August 27, 2026 10:11
Beta's townsmcp#322 gates PHEV/HEV SOC on CHARGING_DATA, relying on a comment that India does not advertise it. India does now — charging telemetry landed earlier in this branch — and India repurposes basicVehicleStatus.extendedData1 to carry fuel level, so a PHEV/HEV there would have shown litres of petrol as battery percent. Three of beta's own India tests caught it.

STATE_OF_CHARGE_NON_BEV carries that meaning on its own, leaving CHARGING_DATA to mean only "has a charging endpoint". India omits the new feature, global keeps it, global behaviour unchanged.

India BEVs also gain a Total Battery Capacity entity, gated on CHARGING_DATA like every other charging sensor. The charging frame omits totalBatteryCapacity in every capture so far, so it reads unknown rather than a fabricated number.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Swap the string-matched "not available after polling" check for the typed ChargingStatusUnavailable the client now exports (john-lazarus/mg-ismart-india-client@511884c). An exhausted poll budget is still translated to None; every other MgIndiaApiError now propagates instead of being caught by an incidental message match.

The India test stubs gain ChargingStatusUnavailable, or india.py fails to import under them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Dr-Blank

Copy link
Copy Markdown
Contributor Author

keeping this as draft even though new lib is released as I just found out that charge status and regular status are being call from the same endpoint. so we can improve it by only calling the endpoint once and save an api call. working on it the india lib side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants