Fault finding
Symptom first, then cause and fix. Most problems with this integration fall into a small number of groups, and its own diagnostic entities are the fastest way to tell them apart — see Diagnostics.
Most entities are unknown
Symptoms: the credentials are valid, renewal works, the car is plainly bound to the account — and most entities sit at unknown, flapping between roughly 20 and all of them, with a steady trickle of this in the log:
XPENG MQTT connection refused: rc=Not authorized (rc_str=Not authorized)Cause: two MQTT clients for the same account, competing. Each carries a different clientId (xmart:app:<uid>:<deviceId>), so the broker authorises one and refuses the other; every refusal triggers a credential refresh and a client rebuild, and every rebuild resets the entities — so values appear, vanish, and the counts flap around instead of settling.
The usual way in is changing device_id on an install that already had one. That changes the MQTT client id, and the client still using the old one is not always torn down — so two clients for one account end up fighting. The code already guards against stacking clients with the same id; a changed id slips past it.
Fix: restart Home Assistant. A config-entry reload does not clear it. The fix in the integration (0.4.6) stops a previous client when an entry is set up again, but if you are already in this state, only a restart clears the one that is loose.
Measured on a live install, before and after a restart:
| before | after | |
|---|---|---|
| live paho clients | 2 | 1 |
entities unknown | 97 / 124 | 20 / 124 |
last_data_update | A timestamp plus a small age_seconds | unknown (no vehicle data yet since start) |
polling_status | Reconnecting | Parked |
Once it has settled it stays healthy — headless, with the phone app signed out, which is the point: this has nothing to do with the app.
Keep one device id per install. If you must change it, expect to restart Home Assistant afterwards.
Measurement traps
Two things reliably mislead when you are debugging this:
sensor.xpeng_<vehicle>_mqtt_listenerreadsNo messageson a perfectly healthy install, because vehicle data arrives over the REST poll rather than that topic. Do not read it as "MQTT is dead, so there is no data".- Counting client ids in the log tells you about history, not about now. To see which client is live, compare the newest timestamp per client id instead of how many appear.
- Log levels differ per host, so counting INFO/DEBUG lines across two installs proves nothing unless both are set to the same level. Counts like "0 MQTT accounts obtained" are an artifact of a
warninglevel, not evidence.
What this is not
Ruled out by measurement, so it is not worth re-treading:
- not a user or session cap — switching another Home Assistant for the same car off entirely, and signing a phone out of the app, both changed nothing;
- not the app needing to be signed in — the healthy state above was measured with the app signed out. A churning install produces intermittent good windows (19/124, 34/124 and 84/124 were all observed, both before and after an app login), so an app login that appears to help most likely landed in one of them;
- not the credentials or the vehicle binding — the API returns the car for the account.
Silent and parked
sensor.xpeng_<vehicle>_polling_status is the one-word answer to "what is the connection doing?".
Two attributes answer "when was this actually measured?", which the state word cannot: seconds_since_data is the age of the last state that carried something, and energy_data_age_seconds is the age of the last state that carried a changed SOC or odometer. A fan-out replaying the same snapshot keeps the first short and lets the second climb — that gap is what a stalled cloud looks like from here.
The status values are:
| Value | Meaning |
|---|---|
Active | Charging or driving: a force-upload is sent on the scan_interval cadence. |
Parked | Parked and quiet: one passive query per parked_scan_interval. The normal quiet state. |
Silent | Connected, but nothing has arrived for longer than the silence threshold (300 s). This is the state the watchdog reconnects for. |
Reconnecting | The socket is down and is being re-established. |
Escalated | The watchdog has already sent a force-upload after 30 minutes of silence; at most once every 12 hours. A stall where the last accepted state said the car was moving bypasses that 12-hour budget — one per 10 minutes, one per episode of motion — because a moving car cannot be woken. |
Silent is not the same as Parked. Because the parked poll interval is measured in hours while the silence threshold is minutes, a parked car can sit in Silent and have the watchdog reconnect between polls — a value that returns to Parked is not a problem in itself, it is designed behaviour. If a car you know is awake stays Silent alongside Not authorized refusals, treat it as the case above.
A wedged fan-out must not hide a moving car. The REST widget fallback keeps being polled while the push stream is quiet, so since 0.6.27 its snapshot also counts as motion evidence: an odometer ahead of the last accepted push, or a drive/gear state that is not P, lets the watchdog spend its one bounded force-upload (one per 10 minutes, one per episode of motion) instead of waiting out the 12-hour sleeping-car budget. Since 0.6.38 the widget alone is polled every rest_scan_interval while the stream is silent, so that evidence arrives within a few minutes instead of at the next hourly REST poll — the 2026-10-27 capture showed detections 6–9 minutes after set-off only because the hourly poll's phase happened to land there, with a worst case of about an hour. A Standby vehicle mode is not movement — the car is parked, so the normal budget still applies. Issue #3's 2026-10-23 capture is the case this closes: 426 minutes without meaningful data while the REST odometer advanced 67 km and the last accepted state still said parked.
The car is being driven, but the state says parked
Issue #35 (P7+, 0.6.50) showed the parked verdict reading a block that had stopped arriving: the odometer and SoC kept updating every few minutes from the push (496 → 508 km), while instant.drive stayed at P — so polling_status said Parked for the whole drive, the timer kept asking passively once an hour, and the location, gear, plug and charging entities that read the same frames never refreshed. The official app was current throughout.
The cadence now has a third signal: an odometer that advanced is movement, whatever the drive block still claims, and it makes the integration Active for fifteen minutes (force-uploading on scan_interval) so the sections the pushes stopped carrying get refreshed. The parked verdict itself is deliberately not rewritten — the energy guards key on it, and a cadence fix must not loosen them.
The same evidence now also decides the reconnect backoff, which is the part that actually recovers a wedged fan-out: a force-upload cannot punch through a stalled session, but a reconnect can — and with a frozen P the watchdog was waiting out the 30-minute parked-car backoff. A moving car now reconnects on the 10-minute active cycle.
One reading that misleads: polling_status shows Silent while nothing is arriving even if the cadence is active, because the state word ranks "no data" above "what cadence am I on". The cadence attribute is the one to watch for that question.
If you see this, the useful capture is a debug log of custom_components.xpeng.mqtt_client for a minute of driving: the Partial state (… keys=[…]) lines name exactly which instant sections the car is sending, which is the difference between "the cloud withheld drive" and "the car stopped sending it".
The car's location is stale after parking — or after a drive
The tracker only knows where the car last told it. Position arrives in the car's own telemetry (interval.drive.latitude/longitude) — never from the REST poll — and a car that has gone to sleep stops sending it. A parked car is deliberately never force-woken on a schedule, so the last position is kept until something makes the car report again:
- The car wakes by itself (a charge, a command, its own schedule) and the position updates.
- Press
Wake vehicle— that request makes the car upload a full state.Force updatewill not help: it asks passively, and a sleeping car answers with a stub. - The silence watchdog does it once automatically after 30 minutes without data, capped at one force-upload per 12 hours (0.6.20+ adds a second allowance while the car was moving). If that budget was spent earlier, a stalled session can leave the map stale until you wake it.
Two attributes on the tracker answer "is this position real?": coord_valid is the car's own GPS-validity flag, and fix_age_s is the age of the last position that was an actual fix. Since 0.6.24, a frame whose coordinates are the car's last known position (coordValid false) no longer moves the car — the last valid position is kept and flagged, instead of a stale coordinate being published as a live one.
If the position did not move even while driving, the frames were not arriving at all: XPENG's cloud push fan-out stalls while the socket still looks healthy, and Last data update will be stale too. Enable debug logging for custom_components.xpeng and look for Drive evidence: lines — gps= says whether a frame carried coordinates and coord_valid= whether the car considered them a current fix.
The battery percentage flips between two values
A sawtooth on the battery (or range) history — alternating by a percent or two on a fixed rhythm — is a data artefact, not the pack. State of charge is reported to whole percent, and while the push stream is quiet two readings of it exist: the last one a push carried, and the live one from the REST widget fallback.
Before 0.6.25, a charge-less MQTT frame — a door ping, or one of the car's own short acks — merged onto the MQTT client's own copy of the last push and re-broadcast it, undoing the fallback's fresher merge. The sensors ping-ponged every parked_scan_interval for as long as the wedge lasted. Now:
- the fallback merge is what the MQTT client's partial-merge baseline holds, so a later ping cannot undo it;
- a state whose SoC is more than one percent above what is held, while the car is parked and not charging and nothing is plugged in, is refused as an older snapshot — a parked, idle, unplugged car's charge can only fall — and refused as data, so a fan-out that only resends it still ages into the watchdog's force-upload.
In the log that refusal reads:
Ignoring a vehicle state from the push fanout: SOC 97% is above the 94% already
held while the car is parked and not charging - it is a snapshot from before the
drain; keeping the newer dataWhat is left on the graph is the real trend at whole-percent resolution. A rise of more than one percent while parked, idle and unplugged does not happen — if one appears, that line names it.
A frozen SOC that the fallback never corrected (before 0.6.51)
Issue #34 is the fallback's own version of that trap. A wedged fan-out does not only fall silent — it replays the last snapshot. A partial replay was always dropped ("nothing new"), but a full replay reached the coordinator, and "this frame carried charge/odometer fields" was being read as "this frame carried energy data". The fallback's staleness clock was re-stamped every few minutes, so mqtt_energy_stale() never opened: the widget was never asked, nothing else could correct the reading, and Home Assistant showed 48 % for hours while the official app already had 43–45 % and force_update fixed it instantly.
From 0.6.51 the clock moves only when the energy values change, so a replayed snapshot ages the gate open and the REST fallback takes over within rest_scan_interval. A frame whose sections are identical to the held state is not freshness either way, which is exactly what makes a replay distinguishable.
When the widget itself is the stale one, no merge can help: the follow-up on #34 showed it returning 14 488 km against 15 158 km held, 218 times, while the car charged. That observation is now recorded as evidence for the watchdog, which may spend one force-upload outside the 12-hour parked budget when the fallback's widget has come back behind the held state — at most once per 30 minutes, and only while the fallback is actually being polled. The log line names it:
Watchdog: 51min without fresh vehicle data and the REST fallback's widget is
behind the state we hold (4min ago) — sending ONE force-uploadThe first such opportunity in a stall is spent on something cheaper: a reconnect plus a passive query, which costs the car nothing and is what re-routes a wedged session. Only if that produces nothing does the next tick spend the wake. That ordering comes from the 2026-12-02 capture, where the reconnect got a 283-byte stub and a force-upload a minute later got the full state — both were needed, but only one of them wakes a car.
A scheduled charge that nobody watched, and the SOC that froze (before 0.6.40)
"A parked car's charge can only fall" has one other exception, and issue #23 found it the hard way. A charge plan that starts and finishes between two live frames never appears as charging in either one: the frame held before the night still reads Scheduled, and the frame that arrives afterwards reads Connected with zero power because the session is already over. The whole 24 % → 70 % overnight charge was invisible, so the rise looked exactly like a replayed snapshot — and because a refused frame is also kept out of the watchdog's data clock, the force-upload that had produced the right answer healed nothing, and with one escalation per 12 hours the battery sensor sat at 24 % until the config entry was reloaded by hand.
From 0.6.40 a cable in the port counts as the second legitimate reason for a parked car's SoC to rise, read from the incoming frame. That is deliberate: while a plan is armed and the car is asleep, its own payload is byte-for-byte identical whether or not a cable is in, so the held state cannot answer the question and the frame that just woke the car can.
One gap is recorded rather than guessed at: a car that reports a finished session as Idle (charging_state 8) with an empty gun reading has no cable evidence either, so that combination is still refused. No capture shows a car doing this. If your battery percentage freezes at a pre-charge value after an overnight scheduled charge, check sensor.xpeng_<vehicle>_charging_state for what the car said when it finally reported, and say so on #23.
Range and Range type flipping between Dynamic and NEDC while parked (before 0.6.44)
In issue #28, a parked car's sensor.<vehicle>_range and sensor.<vehicle>_range_type alternated between the car's configured in-car preference (for example Dynamic, ~206 km) and NEDC (~305 km).
This occurred because the REST widget fallback (/biz/v5/widget/vehicle/state), merged when the push stream is quiet for over 5 minutes, reports range using a cloud-fixed standard (NEDC), whereas the vehicle's live MQTT stream reports the driver's configured in-car preference (Dynamic, WLTP, or CLTC). From 0.6.44, the REST fallback merge preserves the car's configured range standard and reading whenever the widget reports a different standard, while still updating the vehicle's odometer (total_mileage).
Impossible telemetry readings (sentinel placeholders)
XPENG cloud payloads encode "this sensor has not answered" as sentinel placeholder numbers rather than omitting the field:
- Cabin temperature at 87.5 °C (#25): The wake frame emitted by the vehicle just before sleeping carries
87.5°C as a placeholder until the HVAC sensor answers. If the car sleeps immediately, that placeholder became the held state for hours. - Tyre pressure at 0 kPa or ~700 kPa (#25): Wake-frame placeholders (0 kPa) and sensor placeholder spikes (~701 kPa).
- Battery SoC or charge rate at -1 (#24): Emitted when energy subsystems enter sleep mode while parked.
From 0.6.42, these sentinel values are guarded on both the MQTT push and REST fallback ingest paths: impossible readings are treated as "not reported", carrying forward the last valid reading (or reporting unknown if no reading was ever received). Tyre pressures are bounded to 1–450 kPa, cabin temperature strictly below 87.5 °C, and battery SoC / charge rate non-negative.
Nothing is updating
Read these in order:
/config/xpeng-secrets-last-run.log— the renewal app records the whole onboarding run, every step, plus whatever the browser or the API said, rewritten on every run. It sits next to the app'spair_dir(the second slot writes/config/xpeng-secrets-2-last-run.log). It is the first place to look, and it describes the account's login attempts, so treat it as sensitive.GET http://<your-ha-host>:8090/healthz— renewals, failures and the last outcome, including whatxpeng.import_credentialsreturned.- The Home Assistant log —
homeassistant.components.rest_commanderrors name the status the renewal app answered with. - The entity list — Developer Tools → States. A healthy, quiet install still has some
unknownvalues (the fields the car or the account does not report), but it settles rather than flapping. If they flap, go back to Most entities are unknown.
INFO
Home Assistant 2026.10 no longer exposes persistent notifications as persistent_notification.* entities, so a template that watches for the renewal app's failure notification will not find it — look in the notifications panel in the UI.
The values are old but last_updated is not
Home Assistant's own last_updated says when an entity was written, not when the car last said anything, and after a restart or a re-onboarding it is written with a cache from disk. Read sensor.xpeng_<vehicle>_last_data_update instead — it carries the timestamp of the last state the car actually delivered — and check state_restored on the polling-status sensor: true means what you are looking at came from the cache, not from this session.
Issue #36 is that trap in its worst form: a newly onboarded G6 restored an eleven-day-old cache (the state store is keyed by VIN, so a previous entry for the same car leaves it behind), and the integration then waited its normal 30 minutes before asking the car anything. A restored state older than the 12-hour escalation budget now seeds the "data arrived" clock, so the first watchdog tick is allowed to wake the car, and seconds_since_data reports the cache's real age instead of counting from setup.
The energy sensor reads zero
That is usually not zero consumption but a restricted endpoint on a shared account. XPENG returns different data depending on the account's relationship to the car, and it does not always say so:
| Data | Behaviour on a secondary (shared) account |
|---|---|
| Energy consumption | Endpoint returns HTTP 200 with 0.0 — no error at all |
| Location | Still delivered — the app hides it, the API does not |
| Some endpoints | 5000000 用户无权限 / 用户不可见 ("no permission" / "not visible") |
So a 0.0 on sensor.xpeng_<vehicle>_energy_consumption_7_day_avg is not proof of zero consumption. That sensor carries a zero_may_mean_restricted attribute when the value is zero, saying so explicitly. If you care about consumption figures, onboard with the owner account.
Worth knowing in the other direction too: location is not gated by the API, so this integration shows the car's position even when the app shows it only to the owner. That is a deliberate consequence of using the API rather than the UI, not a bug — but be aware of it if the car is shared.
Is the install healthy?
A short checklist. Everything here is visible in Home Assistant except the two log rows, and the staged-credentials line is logged at debug level.
| Check | Healthy | Not healthy |
|---|---|---|
binary_sensor.xpeng_<vehicle>_credentials_valid | on, attribute reason: ok | off with no successful refresh yet (never worked since start — points at onboarding), N consecutive failures (the broker refused), or no successful refresh for Ns (stale) |
sensor.xpeng_<vehicle>_credential_age | Small just after a reconnect; it may climb while a session stays up, because credentials are minted on demand and not rotated on a timer | An age that never resets together with credentials_valid off: the loop cannot mint at all |
| Debug log, mints | One MQTT account obtained per reconnect, and none while a session is healthy | A mint on every cycle with no healthy session in between, or a rotating clientId with a reconnect each time |
binary_sensor.xpeng_<vehicle>_mqtt_connected | on | off: the paho session to XPENG's broker is down |
sensor.xpeng_<vehicle>_polling_status | Parked for a quiet car, Active while charging or driving | Stuck Reconnecting, or Silent on a car you know is awake |
unknown / unavailable counts | Settled, with a stable handful of unknown fields the car does not report (20 of 124 in the measurement) | Flapping between a handful and nearly all of them |
Account signed in elsewhere - expecting a credential import lines | One per renewal (about every 100 min): that is the renewal app logging in, and the import follows within seconds. Not a fault | A takeover with no import after it, or a re-auth card appearing for it |
| Login-expired lines in the log | Occasional warnings such as Login token refresh failed: or Tokens still expired after refresh — triggering reauth, each followed by a successful refresh | A steady stream of warnings with no success in between: the pair is dead and the Repairs card is the way back. The codes behind them are 12010101, 12010104 and 12010202 |
| Distinct MQTT client ids | One live id: count distinct xmart:app:... ids in the log and compare their newest timestamps | Two with recent timestamps — the competing-client case above. Restart Home Assistant |
A control is missing
An entity that simply is not there - no unlock button, no OTA switch, no charge-limit number - is usually Command permissions, not a fault. Since 0.4.20 every command belongs to a capability group that is Full, Read only or Disabled: Disabled means the entity is never created, and Read only keeps it reporting state but refuses its commands. A new install starts at Safe Plus, which leaves unlocking, the trunk and windows, OTA and raw commands out on purpose.
Open Settings → Devices & services → XPENG → Configure: the first field shows the preset, and choosing Custom opens the per-group matrix. Widen the group you want and submit - the entry reloads and the entities come back, keeping their entity ids and their history. Command permissions lists which service and entity lives in each group.
A refused command is different from a missing one, and says so. It raises with the group and the setting:
'xpeng.unlock' is blocked by this integration's command permissions: the 'Access
actions' group is set to disabled in this integration's command permissions (mode:
safe).Every refusal also fires an xpeng_command_denied event and writes one warning to the log, so grep Refused /config/home-assistant.log answers "did something try?". Neither is a credentials problem: if the log shows Login token refresh failed as well, that is the separate case below.
Window closing and charge-port controls
The window open/vent action moves the windows to the ventilation position. Closing uses the official app's service-12 command. A P7+ owner physically confirmed ventilation and closing on 22 October 2026. Neither full opening nor arbitrary positions are advertised.
Charge-port motor actions are unavailable when Motorized charge-port controls is off or model configuration identifies a manual flap. The port's measured state remains available.
That measured state is per-model, and issue #37 is the case where the same number means two things. On the reference G6 the port field reads 0 with the flap shut, 1 with it open and 2 with a cable in it; on a G6 Facelift (vehicleTypeCode FF) a successful open is answered with 0 and a successful close with 2, so the port read "Closed" in every state. The integration now decodes that field against the car's own vehicle type where one has been measured to disagree, and Unknown (n) for a value that car has never reported — it never borrows another model's guess. If your port claims a state it is not in, the port_state attribute on cover.xpeng_<vehicle>_charge_port plus a debug log of the open and close commands (the service_type=4 response carries the port field) is what identifies your model's encoding. Charging start/stop is a different operation: it needs a connected cable and a ready station. Vehicle code 10401 is a charging-start failure, not evidence that the charge flap is unsupported.
Getting back to a working login
If the credentials really are dead, the integration raises a Repairs card named after the vehicle, with a Fix button that opens the import form directly. Re-run the onboarding tool and paste the new pair — and only that one. Every successful refresh rotates the refresh token, so any older xpeng_tokens.json is already retired; re-importing it does not bring the old session back, it evicts the live one, which looks exactly like "the fix did not work". One run of the tool, imported once.
The in-app email/password re-auth cannot work, because it hits the same captcha. If the Repairs card is not there — it is deleted when a fix is submitted, and an update does not put it back — use Home Assistant's own Authentication expired prompt, which opens the same import form for an entry created by Import tokens. Both routes update the existing entry; there is no need to delete and re-add it.
See Getting Started for the command, and Unattended renewal if you would rather the apps did this for you. The certificates from Certificates do not need redoing unless XPENG rotates them, which shows up as a TLS or broker authentication failure rather than a login failure.
"It is asking me to import the tokens again"
The import screen says what it found, and where it looked, at the bottom of the description. Read that line before anything else:
- "Found an existing pair in …" — the paths below it are filled in, and submitting the form unchanged imports that pair.
- "No token + tenant pair was found in …" — the credential is not on the host, and the certificates being in place does not change that. The three
.pemfiles are the device's mTLS identity; the token + tenant pair is the login. A pair is only ever somewhere the integration can read it if the renewal app published it to/config/xpeng-secrets, or the onboarding tool was told to write there.
A pair that was written inside the integration directory is the usual way to end up here: HACS replaces that directory on install, update and reinstall, so a pair saved next to the component is gone the next time HACS touches it — and re-downloading the integration restores code, not credentials. Removing the HACS download as a troubleshooting step does the same thing deliberately. The onboarding tool now writes the pair to /config/xpeng-secrets/ whenever the component it finds is Home Assistant's own, and takes --out-dir otherwise.
Nothing on disk can bring a deleted pair back, and an expired session cannot be revived: re-mint it. The renewal app does that on its own and creates the entry, and the manual route is one run of the onboarding tool plus a paste. Certificates kept in /config/xpeng-certs are reused either way.