Add EMEA charge-schedule support (read from v3 status, write via v2 CPPLUS) - #13
Open
815rx1 wants to merge 2 commits into
Open
Add EMEA charge-schedule support (read from v3 status, write via v2 CPPLUS)#13815rx1 wants to merge 2 commits into
815rx1 wants to merge 2 commits into
Conversation
Updated charge level preference to use integers and added support for EMEA charge schedules.
Introduced a new method to set EV charge schedules specifically for EMEA vehicles, addressing issues with the existing method and ensuring compatibility with EMEA models.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
EMEA EVs such as the Fiat New 500e do not use the North-American
/v4/accounts/{uid}/vehicles/{vin}/ev/schedule/endpoint. That endpointreturns HTTP 500 for these cars. Instead:
the v3 vehicle status under
evInfo.schedules. No extra request is needed.POST /v2/.../ev/schedule/carrying aCPPLUScommand envelope ({command, pinAuth, schedules[]}).This PR adds a typed representation of those schedules to
Vehicle, parsesthem from the v3 status, and adds read-modify-write support via a new
Client.set_charge_schedule_emea()/API.set_charge_schedule_emea().Everything is additive - no existing behaviour changes, the NA
set_charge_schedule(v4) path is untouched.Confirmed working
Verified live against a 2022 Fiat New 500e (soldRegion=EMEA, sdp=IGNITE,
market=DE, service CPPLUS serviceEnabled=true):
Setting slot 1 to "Mon-Fri 01:00-05:00" was reflected both in the subsequent
v3 status read and in the official Fiat app; disabling it again worked the
same way.
ChargeSchedule.to_api()reproduces the confirmed 200 payloadbyte-for-byte (verified in a unit test against the real status payload).
Fixes the read/write gap reported downstream in hass-uconnect#110
(Fiat 500e EU/EMEA schedule charging).
Changes
client.py
@dataclass_jsonclassesScheduledDaysandChargeSchedulewithfrom_api()/to_api()converters (API <-> snake_case).Vehicle.charge_schedules: list[ChargeSchedule]._update_vehicle()now parsesevInfo.schedulesinto that field.Client.set_charge_schedule_emea(vin, schedules, verify=False)- takes thefull slot list, serialises, POSTs, optionally polls the correlation id.
CHARGING_LEVELSextended withLEVEL_4/LEVEL_5and the EMEA word-formkeys
LEVEL_ONE..LEVEL_FIVE.charging_level_preferenceis now mapped throughCHARGING_LEVELSto anint (1..5) instead of being left as the raw string, matching the README
example (
"charging_level_preference": 5) andcharging_level. Type hintchanged
str -> int.api.py
API.set_charge_schedule_emea(vin, schedules)- thePOST /v2/.../ev/schedule/with theCPPLUSenvelope. Raises on missingcorrelationId, mirroring the existingset_charge_schedule.Important behavioural note (documented in the docstring)
The backend replaces the entire schedule list on every write. Sending a
single slot silently resets the others to defaults. Callers must therefore
read
vehicle.charge_schedules, modify the slot(s) they need, and pass thewhole list back -
set_charge_schedule_emeais designed around exactly thisread-modify-write pattern.
Possible breaking change to flag for the maintainer
charging_level_preferencechanges type fromstr("LEVEL_FIVE") toint(5). This matches the documented README output andcharging_level,but any downstream consumer comparing the raw string would need updating.
Happy to keep it as a string if you prefer - just say the word.
Not included / out of scope
ECOCOACHING20/TRIPREPORTareserviceEnabled=false, the eco-coaching endpoints return nothing usable.
coexist). A follow-up could switch on
soldRegion.