# Zeekr 7X (China) — Home Assistant integration > 🇺🇦 [Українська версія нижче](#українською) ![Zeekr 7X dashboard](assets/dashboard.png) ![Zeekr 7X dashboard](assets/dashboard-2.png) A native Home Assistant integration for the **China-market Zeekr 7X** (grey import / mainland car, paired with the Chinese Zeekr app `com.zeekrlife.mobile`, phone + SMS login). It talks to Zeekr's TSP cloud directly — **no phone, no root, no bridge** — and gives you live telemetry **and** remote control. > **Scope:** developed and verified on a **Zeekr 7X with the China-mainland app and TSP > backend**. Other Zeekr models on the same Chinese backend (001, 009, X, 007) will probably > work, since the gateway and service IDs are shared — but they are untested here. The > **European/global Zeekr app is a different backend entirely and is not supported.** > Unofficial and reverse-engineered: it may break when Zeekr updates their app or backend. > Use at your own risk. ## Features - **Config flow**: phone number → SMS code → done (no password; tokens stored in the entry). - **Live telemetry** (cloud polling): battery, range, odometer, cabin temp, charging figures, 4× tyre pressure **and** temperature, 12 V battery, trips, service intervals, GPS location. - **Closures**: 4 doors + 4 door locks, 4 windows (state **and** position), trunk + trunk lock, frunk, sunroof, central lock, charge-lid. - **Remote control**: climate with target temp, rapid heat/cool, defrost, steering-wheel heat, seat heat ×4 / vent ×2, windows, sunshade, charging, charge limit, charge schedules, sentry, V2L, battery preconditioning, lock/unlock, flash, horn & flash. ## Entities **110 entities** across 11 platforms. Names follow your Home Assistant language (`en`, `uk` shipped), so you do not need to label cards by hand. Rows marked **◦** are *disabled by default* — enable them under the device page if your car reports them. ### Sensors (46) | Name | Key | Unit | | |---|---|---|---| | 12V Battery | `battery_12v` | V | | | Battery Health | `battery_soh` | % | ◦ | | Cabin Temperature | `cabin_temp` | °C | | | Charge Complete | `charge_complete_time` | — | | | Charging Current | `charge_current` | A | | | Charge Limit | `charge_limit` | % | | | Charging Power | `charge_power` | kW | | | Charging Speed | `charge_speed` | km/h | | | Charging Voltage | `charge_voltage` | V | | | Charger State | `charger_state` | — | | | Charging State | `charging_state` | — | | | Battery Temperature Level | `cold_battery` | — | | | Avg Consumption | `consumption` | kWh/100km | | | Days to Service | `days_to_service` | d | | | DC Station Current | `dc_pile_current` | A | ◦ | | DC Station Voltage | `dc_pile_voltage` | V | ◦ | | Distance to Service | `distance_to_service` | km | | | Gear | `gear` | — | | | Last Update | `last_update` | — | | | Odometer | `odometer` | km | | | Power Status | `power_status` | — | | | Range | `range` | km | | | Range at 100% | `range_100soc` | km | ◦ | | Range to 20% | `range_20soc` | km | ◦ | | Battery | `soc` | % | | | Speed | `speed` | km/h | | | Time to Full | `time_to_full` | min | | | Trip A | `trip_a` | km | | | Trip Since Parking | `trip_b` | km | | | Tyre Pressure FL | `tyre_fl` | kPa | | | Tyre Pressure FR | `tyre_fr` | kPa | | | Tyre Pressure RL | `tyre_rl` | kPa | | | Tyre Pressure RR | `tyre_rr` | kPa | | | Tyre Temperature FL | `tyre_t_fl` | °C | | | Tyre Temperature FR | `tyre_t_fr` | °C | | | Tyre Temperature RL | `tyre_t_rl` | °C | | | Tyre Temperature RR | `tyre_t_rr` | °C | | | Usage Mode | `usage_mode` | — | | | V2L Current | `v2l_current` | A | ◦ | | V2L Power | `v2l_power` | W | | | V2L Time to Limit | `v2l_time_to_limit` | min | ◦ | | V2L Voltage | `v2l_voltage` | V | ◦ | | Window Position Front-Left | `window_pos_fl` | % | ◦ | | Window Position Front-Right | `window_pos_fr` | % | ◦ | | Window Position Rear-Left | `window_pos_rl` | % | ◦ | | Window Position Rear-Right | `window_pos_rr` | % | ◦ | ### Binary sensors (29) | Name | Key | |---|---| | Awake | `awake` | | Battery Preconditioning | `battery_preheating` | | Charge Cable | `charge_cable` | | Charge Port Lid | `charge_port_lid` | | Charging | `charging` | | Door Front-Left | `door_fl` | | Door Front-Right | `door_fr` | | Door Lock Front-Left | `door_lock_fl` | | Door Lock Front-Right | `door_lock_fr` | | Door Lock Rear-Left | `door_lock_rl` | | Door Lock Rear-Right | `door_lock_rr` | | Door Rear-Left | `door_rl` | | Door Rear-Right | `door_rr` | | Frunk | `frunk` | | High Beam | `high_beam` | | Unlocked | `locked` | | Low Beam | `low_beam` | | Parking Brake | `parking_brake` | | Plugged In | `plugged_in` | | Scheduled Charging | `scheduled_charging` | | Sunroof | `sunroof` | | Trunk | `trunk` | | Trunk Lock | `trunk_lock` | | Tyre Warning | `tyre_warning` | | V2L Delivering | `v2l_delivering` | | Window Front-Left | `window_fl` | | Window Front-Right | `window_fr` | | Window Rear-Left | `window_rl` | | Window Rear-Right | `window_rr` | ### Buttons (9) | Name | Key | |---|---| | Flash Lights | `flash` | | Horn & Flash | `honk_flash` | | Parking Comfort Off | `parking_comfort_off` | | Rapid Cool-Down | `rapid_cool` | | Rapid Warm-Up | `rapid_warm` | | Refresh | `refresh` | | Unlock Driver Door | `unlock_driver` | | Unlock Trunk | `unlock_trunk` | | Windows Ventilation | `windows_vent` | ### Switches (8) | Name | Key | |---|---| | Battery Preconditioning | `battery_preconditioning` | | Charge Schedule 1 | `charge_schedule_1` | | Charge Schedule 2 | `charge_schedule_2` | | Charging | `charging_switch` | | Defrost | `defrost` | | Sentry Mode | `sentry` | | Steering Wheel Heat | `steering_wheel_heat` | | V2L | `v2l` | ### Selects (6) | Name | Key | |---|---| | Seat Heat Front-Left | `seat_heat_fl` | | Seat Heat Front-Right | `seat_heat_fr` | | Seat Heat Rear-Left | `seat_heat_rl` | | Seat Heat Rear-Right | `seat_heat_rr` | | Seat Vent Front-Left | `seat_vent_fl` | | Seat Vent Front-Right | `seat_vent_fr` | ### Numbers (2) | Name | Key | |---|---| | Charge Limit | `charge_limit` | | V2L Discharge Limit | `v2l_discharge_limit` | ### Time (4) | Name | Key | |---|---| | Schedule 1 End | `schedule_1_end` | | Schedule 1 Start | `schedule_1_start` | | Schedule 2 End | `schedule_2_end` | | Schedule 2 Start | `schedule_2_start` | ### Locks (2) | Name | Key | |---|---| | Charge Lid | `charge_lid` | | Doors | `doors` | ### Covers (2) | Name | Key | |---|---| | Sunshade | `sunshade` | | Windows | `windows` | ### Climate (1) | Name | Key | |---|---| | Climate | `climate` | ### Device tracker (1) | Name | Key | |---|---| | Location | `location` | ### Climate — ranges and modes Target temperature **16–32 °C**, HVAC modes `off` / `heat_cool`. The `Rapid Warm-Up` and `Rapid Cool-Down` buttons are presets on the same ZAF service. ### Select options Seat heat (×4) and seat vent (×2) all take `off` / `low` / `medium` / `high`. ### Number ranges `charge_limit` accepts **50–100 %**, `v2l_discharge_limit` **20–90 %**, step 1. ### Charge schedules Two schedules: each has a switch (`charge_schedule_1/2`) plus start and end `time` entities. Times are set and shown in **local time**. ### Events Every command fires a `zeekr_7x_cn_command` event on the HA bus carrying the service id and the verdict, so you can trigger automations off command success or failure. ### Status-less controls Sentry, charge-lid, seat heat/vent and a few others have no read-back in the TSP status payload, so they act **optimistically**: the entity reflects the command you sent, not a confirmed state. ## How it works (short) Login mints a JWT on the zeekrlife gateway, which is then exchanged through a 3-gateway chain into a TSP session that reads status and sends commands. All three request signatures are reproduced in pure Python. The gory details (and how to re-derive everything when the app updates) are in [`docs/`](docs/): - [`docs/GATEWAY_SIGN_SOLVED.md`](docs/GATEWAY_SIGN_SOLVED.md) — the auth-gateway signature - [`docs/TSP_SOLVED.md`](docs/TSP_SOLVED.md) — the TSP token exchange + vehicle endpoints - [`docs/RE_PLAYBOOK.md`](docs/RE_PLAYBOOK.md) — re-decompile playbook for future app versions ## Install ### HACS (custom repository) 1. HACS → ⋮ → *Custom repositories* → add `https://github.com/Nick-Most/ha-zeekr-7x-cn`, category **Integration**. 2. Install **Zeekr 7X (China)**, restart Home Assistant. 3. Settings → Devices & Services → **Add Integration** → *Zeekr 7X (China)* → enter phone (digits only) and region (`86`), then the SMS code. ### Manual Copy `custom_components/zeekr_7x_cn/` into your HA `config/custom_components/`, restart, then add the integration from the UI. `pycryptodome` is installed automatically from the manifest. ### Upgrading from `zeekr_cn` (≤ 0.4.0) The integration domain changed from `zeekr_cn` to `zeekr_7x_cn`. Remove the integration from *Devices & Services*, delete `config/custom_components/zeekr_cn/`, install this version and add it again. Entity IDs are rebuilt under the new domain, so dashboards and automations that reference the old IDs need updating, and you log in again by SMS. ## Authentication — two gateways When you add the integration you pick one: ### 1. Phone + SMS (SNC gateway) — easiest Enter your phone number and the SMS code. The integration mints a JWT and exchanges it into a TSP session. Zeekr allows roughly one app session per account, so this can sign the phone app out — for a headless setup, share the car to a **second account** and use that (reads of a shared car work; some commands may require the **owner** account). The TSP login returns an **access token (~7 days) and a refresh token (~30 days)**, and both are persisted to the config entry. From then on the integration resumes from that pair: it refreshes when under a day is left, and refreshes-and-retries once on a `401/403` or a token code (`4010101` failed, `4010103` expired, `4010201` kicked by another device, `4010202` off). The refresh token **rotates on every refresh**, so the new one is saved immediately — including when the request that followed it failed. Refresh keeps working even after the phone app kicks the gateway JWT, so SMS is normally needed only once. If the refresh token itself expires or is rejected, re-add the entry. ### 2. GRIC refreshToken (the gateway the official app uses) No SMS. You paste two values captured from the official app, and the integration talks to GRIC (`gric-*.geely.com`) — which serves shared cars without the SNC `079001` refusals: - **refreshToken** — an RS256 JWT. It is the seed for everything; the server **rotates** it on each refresh and the integration persists the new one automatically. Capture it from the app's traffic (e.g. an HTTPS proxy on `/ms-midground-user/.../user/auth/refresh/token`) or app storage. - **x-vehicle-identifier** — a per-car, ~44-char base64 capability token the gateway decrypts. It is **not derivable offline** — copy it from a captured per-vehicle request header. Without it, the vehicle list still loads but status/commands return `00A06`. You can add it later in *Options*. **How to capture these two values:** see [`docs/GRIC_CAPTURE.md`](docs/GRIC_CAPTURE.md) (Reqable on a rooted phone + SSL-pinning bypass, or reading them from app storage). The signing scheme (HMAC-SHA256 v2.1) and endpoints are in [`docs/RE_PLAYBOOK.md`](docs/RE_PLAYBOOK.md); the work is cross-checked against [`RexzeLu/zeekr_ha`](https://github.com/RexzeLu/zeekr_ha). ## Development ```bash python3 -m venv .venv .venv/bin/pip install -r requirements_test.txt .venv/bin/pytest ``` `tests/` covers the GW3 token lifecycle (refresh request shape, signing, auto-refresh and retry, rotation) and the coordinator's config-entry persistence. Home Assistant is stubbed in `tests/conftest.py`, so no HA install is needed and no test touches the network. ## Credits Signing constants and the GRIC path were cross-checked against the MIT project [`RexzeLu/zeekr_ha`](https://github.com/RexzeLu/zeekr_ha). Thanks to that project. ## License MIT — see [LICENSE](LICENSE). --- ## Українською **Zeekr 7X (Китай) — інтеграція для Home Assistant** > 🇬🇧 [English version above](#zeekr-7x-china--home-assistant-integration) Нативна інтеграція Home Assistant для **Zeekr 7X китайського ринку** (сірий імпорт / материкове авто, працює з китайським застосунком Zeekr `com.zeekrlife.mobile`, вхід за телефоном + SMS). Вона звертається напряму до хмари TSP Zeekr — **без телефона, без root, без містків** — і дає живу телеметрію **та** дистанційне керування. > **Область застосування:** розроблено й перевірено на **Zeekr 7X із китайським > застосунком і бекендом TSP**. Інші моделі Zeekr на тому самому китайському бекенді > (001, 009, X, 007) імовірно працюватимуть, бо шлюзи й ID сервісів спільні — але тут вони > не перевірялися. **Європейський/глобальний застосунок Zeekr — це зовсім інший бекенд, > він не підтримується.** > Неофіційна інтеграція, зроблена реверс-інжинірингом: вона може зламатися, коли Zeekr > оновить застосунок або бекенд. Користуєтеся на власний ризик. ## Можливості - **Майстер налаштування**: номер телефона → код із SMS → готово (без пароля; токени зберігаються в записі інтеграції). - **Жива телеметрія** (опитування хмари): заряд, запас ходу, одометр, температура в салоні, показники зарядки, тиск **і** температура 4× шин, акумулятор 12 В, поїздки, інтервали ТО, GPS-розташування. - **Отвори та замки**: 4 двері + 4 замки дверей, 4 вікна (стан **і** положення), багажник + його замок, передній багажник, люк, центральний замок, лючок зарядки. - **Дистанційне керування**: клімат із цільовою температурою, швидкий обігрів/охолодження, обдув скла, підігрів керма, підігрів сидінь ×4 / вентиляція ×2, вікна, шторка, зарядка, ліміт заряду, розклади зарядки, вартовий режим, V2L, підігрів АКБ, замикання/відмикання, моргання фарами, сигнал і фари. ## Сутності **110 сутностей** на 11 платформах. Назви беруться з мови Home Assistant (у комплекті `en` та `uk`), тому підписувати картки руками не треба. Рядки з **◦** вимкнені за замовчуванням — увімкніть їх на сторінці пристрою, якщо ваше авто їх віддає. ### Сенсори (46) | Назва | Ключ | Од. | | |---|---|---|---| | Акумулятор 12 В | `battery_12v` | V | | | Ресурс батареї | `battery_soh` | % | ◦ | | Температура в салоні | `cabin_temp` | °C | | | Зарядиться о | `charge_complete_time` | — | | | Струм зарядки | `charge_current` | A | | | Ліміт заряду | `charge_limit` | % | | | Потужність зарядки | `charge_power` | kW | | | Швидкість зарядки | `charge_speed` | km/h | | | Напруга зарядки | `charge_voltage` | V | | | Код стану зарядки | `charger_state` | — | | | Стан зарядки | `charging_state` | — | | | Холодна батарея | `cold_battery` | — | | | Середня витрата | `consumption` | kWh/100km | | | До ТО, днів | `days_to_service` | d | | | Струм станції | `dc_pile_current` | A | ◦ | | Напруга станції | `dc_pile_voltage` | V | ◦ | | До ТО, км | `distance_to_service` | km | | | Передача | `gear` | — | | | Оновлено | `last_update` | — | | | Одометр | `odometer` | km | | | Стан живлення | `power_status` | — | | | Запас ходу | `range` | km | | | Запас ходу при 100 % | `range_100soc` | km | ◦ | | Запас ходу до 20 % | `range_20soc` | km | ◦ | | Заряд батареї | `soc` | % | | | Швидкість | `speed` | km/h | | | До кінця зарядки | `time_to_full` | min | | | Проміжна поїздка | `trip_a` | km | | | Після паркування | `trip_b` | km | | | Тиск шини ПЛ | `tyre_fl` | kPa | | | Тиск шини ПП | `tyre_fr` | kPa | | | Тиск шини ЗЛ | `tyre_rl` | kPa | | | Тиск шини ЗП | `tyre_rr` | kPa | | | Температура шини ПЛ | `tyre_t_fl` | °C | | | Температура шини ПП | `tyre_t_fr` | °C | | | Температура шини ЗЛ | `tyre_t_rl` | °C | | | Температура шини ЗП | `tyre_t_rr` | °C | | | Режим | `usage_mode` | — | | | Струм V2L | `v2l_current` | A | ◦ | | Потужність V2L | `v2l_power` | W | | | V2L до ліміту | `v2l_time_to_limit` | min | ◦ | | Напруга V2L | `v2l_voltage` | V | ◦ | | Положення вікна ПЛ | `window_pos_fl` | % | ◦ | | Положення вікна ПП | `window_pos_fr` | % | ◦ | | Положення вікна ЗЛ | `window_pos_rl` | % | ◦ | | Положення вікна ЗП | `window_pos_rr` | % | ◦ | ### Бінарні сенсори (29) | Назва | Ключ | |---|---| | Авто не спить | `awake` | | Підігрів АКБ | `battery_preheating` | | Кабель зарядки | `charge_cable` | | Лючок зарядки | `charge_port_lid` | | Заряджається | `charging` | | Двері ПЛ | `door_fl` | | Двері ПП | `door_fr` | | Замок дверей ПЛ | `door_lock_fl` | | Замок дверей ПП | `door_lock_fr` | | Замок дверей ЗЛ | `door_lock_rl` | | Замок дверей ЗП | `door_lock_rr` | | Двері ЗЛ | `door_rl` | | Двері ЗП | `door_rr` | | Передній багажник | `frunk` | | Дальнє світло | `high_beam` | | Відімкнено | `locked` | | Ближнє світло | `low_beam` | | Ручник | `parking_brake` | | Кабель під'єднано | `plugged_in` | | За розкладом | `scheduled_charging` | | Люк | `sunroof` | | Багажник | `trunk` | | Замок багажника | `trunk_lock` | | Попередження шин | `tyre_warning` | | V2L віддає | `v2l_delivering` | | Вікно ПЛ | `window_fl` | | Вікно ПП | `window_fr` | | Вікно ЗЛ | `window_rl` | | Вікно ЗП | `window_rr` | ### Кнопки (9) | Назва | Ключ | |---|---| | Моргнути фарами | `flash` | | Сигнал і фари | `honk_flash` | | Вимкнути комфорт | `parking_comfort_off` | | Швидке охолодження | `rapid_cool` | | Швидкий обігрів | `rapid_warm` | | Оновити | `refresh` | | Двері водія | `unlock_driver` | | Відімкнути багажник | `unlock_trunk` | | Провітрювання вікон | `windows_vent` | ### Перемикачі (8) | Назва | Ключ | |---|---| | Підігрів АКБ | `battery_preconditioning` | | Розклад 1 | `charge_schedule_1` | | Розклад 2 | `charge_schedule_2` | | Зарядка | `charging_switch` | | Обдув скла | `defrost` | | Вартовий режим | `sentry` | | Підігрів керма | `steering_wheel_heat` | | V2L | `v2l` | ### Списки (6) | Назва | Ключ | |---|---| | Підігрів сидіння ПЛ | `seat_heat_fl` | | Підігрів сидіння ПП | `seat_heat_fr` | | Підігрів сидіння ЗЛ | `seat_heat_rl` | | Підігрів сидіння ЗП | `seat_heat_rr` | | Вентиляція ПЛ | `seat_vent_fl` | | Вентиляція ПП | `seat_vent_fr` | ### Числа (2) | Назва | Ключ | |---|---| | Ліміт заряду | `charge_limit` | | Ліміт розряду V2L | `v2l_discharge_limit` | ### Час (4) | Назва | Ключ | |---|---| | Розклад 1 — кінець | `schedule_1_end` | | Розклад 1 — початок | `schedule_1_start` | | Розклад 2 — кінець | `schedule_2_end` | | Розклад 2 — початок | `schedule_2_start` | ### Замки (2) | Назва | Ключ | |---|---| | Лючок зарядки | `charge_lid` | | Двері | `doors` | ### Штори/вікна (2) | Назва | Ключ | |---|---| | Шторка | `sunshade` | | Вікна | `windows` | ### Клімат (1) | Назва | Ключ | |---|---| | Клімат | `climate` | ### Трекер (1) | Назва | Ключ | |---|---| | Розташування | `location` | ### Клімат — діапазони та режими Цільова температура **16–32 °C**, режими `off` / `heat_cool`. Кнопки «Швидкий обігрів» та «Швидке охолодження» — пресети того самого сервісу ZAF. ### Варіанти списків Підігрів сидінь (×4) і вентиляція сидінь (×2) приймають `off` / `low` / `medium` / `high`. ### Діапазони чисел «Ліміт заряду» — **50–100 %**, «Ліміт розряду V2L» — **20–90 %**, крок 1. ### Розклади зарядки Два розклади: у кожного є перемикач (`charge_schedule_1/2`) плюс сутності `time` для початку й кінця. Час задається й показується **за місцевим часом**. ### Події Кожна команда кидає на шину HA подію `zeekr_7x_cn_command` з id сервісу та вердиктом — тож можна робити автоматизації на успіх або помилку команди. ### Контроли без зворотного звʼязку Вартовий режим, лючок зарядки, підігрів/вентиляція сидінь та деякі інші не мають читання стану у відповіді TSP, тому працюють **оптимістично**: сутність показує надіслану команду, а не підтверджений стан. ## Як це працює (коротко) Вхід створює JWT на шлюзі zeekrlife, який далі обмінюється через ланцюг із 3 шлюзів на сесію TSP — вона читає статус і надсилає команди. Усі три підписи запитів відтворені чистим Python. Подробиці (і як усе перевивести, коли застосунок оновиться) — у [`docs/`](docs/): - [`docs/GATEWAY_SIGN_SOLVED.md`](docs/GATEWAY_SIGN_SOLVED.md) — підпис шлюзу автентифікації - [`docs/TSP_SOLVED.md`](docs/TSP_SOLVED.md) — обмін токенів TSP + ендпоїнти авто - [`docs/RE_PLAYBOOK.md`](docs/RE_PLAYBOOK.md) — інструкція з повторної декомпіляції для майбутніх версій застосунку ## Встановлення ### HACS (власний репозиторій) 1. HACS → ⋮ → *Custom repositories* → додайте `https://github.com/Nick-Most/ha-zeekr-7x-cn`, категорія **Integration**. 2. Встановіть **Zeekr 7X (China)**, перезапустіть Home Assistant. 3. Налаштування → Пристрої та служби → **Додати інтеграцію** → *Zeekr 7X (China)* → введіть телефон (лише цифри) і регіон (`86`), далі код із SMS. ### Вручну Скопіюйте `custom_components/zeekr_7x_cn/` до вашого `config/custom_components/` у HA, перезапустіть, далі додайте інтеграцію через інтерфейс. `pycryptodome` встановлюється автоматично з маніфесту. ### Оновлення з `zeekr_cn` (≤ 0.4.0) Домен інтеграції змінився з `zeekr_cn` на `zeekr_7x_cn`. Видаліть інтеграцію в *Пристрої та служби*, видаліть `config/custom_components/zeekr_cn/`, встановіть цю версію й додайте знову. ID сутностей будуть створені наново під новим доменом, тож дашборди та автоматизації зі старими ID доведеться оновити, і вхід по SMS потрібен буде ще раз. ## Автентифікація — два шлюзи Коли додаєте інтеграцію, ви обираєте один із них: ### 1. Телефон + SMS (шлюз SNC) — найпростіше Введіть номер телефона й код із SMS. Інтеграція створює JWT і обмінює його на сесію TSP. Zeekr дозволяє приблизно одну сесію застосунку на акаунт, тож це може розлогінити застосунок на телефоні — для headless-установки поділіться авто на **другий акаунт** і використовуйте його (читання спільного авто працює; деякі команди можуть вимагати акаунт **власника**). Вхід у TSP повертає **токен доступу (~7 днів) і токен оновлення (~30 днів)**, обидва зберігаються в записі інтеграції. Далі інтеграція продовжує з цієї пари: оновлює, коли лишається менше доби, і один раз оновлює-та-повторює запит на `401/403` чи код токена (`4010101` невдалий, `4010103` протермінований, `4010201` витіснений іншим пристроєм, `4010202` вимкнений). Токен оновлення **ротується при кожному оновленні**, тож новий зберігається одразу — зокрема й тоді, коли наступний запит впав. Оновлення працює навіть після того, як застосунок на телефоні витіснив JWT шлюзу, тому SMS зазвичай потрібен лише один раз. Якщо ж сам токен оновлення протермінувався або відхилений — додайте запис наново. ### 2. GRIC refreshToken (шлюз, яким користується офіційний застосунок) Без SMS. Ви вставляєте два значення, перехоплені з офіційного застосунку, і інтеграція працює з GRIC (`gric-*.geely.com`) — він віддає спільні авто без відмов SNC `079001`: - **refreshToken** — JWT із підписом RS256. Це насіння для всього; сервер **ротує** його при кожному оновленні, і інтеграція зберігає новий автоматично. Перехопіть його з трафіку застосунку (напр. HTTPS-проксі на `/ms-midground-user/.../user/auth/refresh/token`) або зі сховища застосунку. - **x-vehicle-identifier** — токен можливостей для конкретного авто, ~44 символи base64, який шлюз розшифровує. Його **неможливо вивести офлайн** — скопіюйте із заголовка перехопленого запиту для цього авто. Без нього список авто все одно завантажиться, але статус і команди повертатимуть `00A06`. Його можна додати пізніше в *Параметрах*. **Як перехопити ці два значення:** див. [`docs/GRIC_CAPTURE.md`](docs/GRIC_CAPTURE.md) (Reqable на root-телефоні + обхід SSL-pinning, або читання зі сховища застосунку). Схема підпису (HMAC-SHA256 v2.1) та ендпоїнти — у [`docs/RE_PLAYBOOK.md`](docs/RE_PLAYBOOK.md); роботу звірено з [`RexzeLu/zeekr_ha`](https://github.com/RexzeLu/zeekr_ha). ## Розробка ```bash python3 -m venv .venv .venv/bin/pip install -r requirements_test.txt .venv/bin/pytest ``` `tests/` покриває життєвий цикл токенів GW3 (форма запиту оновлення, підпис, автооновлення та повтор, ротація) і збереження координатором даних у записі інтеграції. Home Assistant підмінений заглушками у `tests/conftest.py`, тож встановлений HA не потрібен і жоден тест не звертається до мережі. ## Подяки Константи підпису та шлях GRIC звірено з MIT-проєктом [`RexzeLu/zeekr_ha`](https://github.com/RexzeLu/zeekr_ha). Дякуємо цьому проєкту. ## Ліцензія MIT — див. [LICENSE](LICENSE).