feat(india): expose EV charging status sensors - #302
Conversation
…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>
9f231ad to
f0171c4
Compare
john-lazarus
left a comment
There was a problem hiding this comment.
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.
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>
|
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. |
What
Wires MG iSMART India EV vehicles into the existing charging sensors. The
India backend's
get_charging_infonow fetches the decoded charging frame fromthe client and maps it onto the
chrgMgmtData/rvsChargeStatusshapes theshared 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.
rvsChargeStatusis built field by field, so everyvalue a sensor reads has a named source and a stated scale assumption.
is_charging/is_plugged_in→bmsChrgSts(charging / plugged-in / unplugged)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.
Nonewhen the vehicle sends no charging frame (coordinator handlesit); session/protocol errors propagate so they're logged, not silently
reported as "not charging".
Dependency
(
charge_status()→ChargeStatus). Merge + release that, then bump the pinnedclient in
manifest.jsonbefore this lands. Draft until then.Scope
Diff is two files (
backends/india.py,backends/__init__.py). Branch is behindbeta; will rebase before un-drafting.