Integrate MG into Smart Home

Introduction
For my MG electric car, the manufacturer offers an interface that can be used to retrieve data. For this purpose, there is a bridge that allows you to write the retrieved data to an MQTT broker so that it can be displayed in a smart home display.
MQTT
A popular standard for the smart homes is MQTT. MQTT Clients send data to a MQTT Broker, which provides them for other MQTT Clients. Often smart home systems support access to MQTT for visualization of data and to send commands to the devices.
iSmart Secondary User
To access the vehicle data, you need a second profile in the MG iSmart app. Otherwise, it will
always log in to the device that was last used and log you out of the other one. First, log out of
the iSmart app under Profile ▸ Settings ▸ Log out. Then register a new account on the
login screen. Once the second user has been created, log out again and log in with the main user in
the iSmart app. Then click on Profile ▸ Secondary account ▸ + and create a
permanent Family Card with the previously used mobile phone number. Under
Code, select the area code for Germany and enter the mobile phone number without
the leading zero.
Connection
To
connect the MG electric vehicle with MQTT, there is a project on GitHub
called
SAIC Python MQTT Gateway.
I installed this as a
Docker Image
on my Synology NAS. The installation is described in the images, and the
values for the advanced settings are described again below.
ENV Variables
| Variable | Example Value | Description |
|---|---|---|
| MQTT_URI | tcp://192.168.1.21:1883 | URL of MQTT Server with port number |
| MQTT_TOPIC | cyberster | Topic under which the values appear |
| SAIC_USER | 1721234567 | Login of secondary user (phone number without area code) |
| SAIC_PASSWORD | totallySecret | Password of secondary user |
| SAIC_PHONE_COUNTRY_CODE | 49 | Country code |
| BATTERY_CAPACITY_MAPPING | ABCDE00SN000123=77.0 | VIN of Cyberster with battery capacity |
| HA_DISCOVERY_ENABLED | FALSE | Home Assistant discovery disabled if unused |
Traccar
| Variable | Example Value | Description |
|---|---|---|
| OSMAND_SERVER_URI | http://192.168.1.21:5055 | IP-Address with port, where Traccar runs locally |
If you want to track the position of the MG car live, you can transmit it to a GPS tracking software, such as Traccar. When setting up the saic2mqtt bridge and Traccar in both containers, it is important to set the network to host and not to bridge. This is required for both to communicate with each other and for the data to arrive in Traccar. If Traccar is used on a server accessible via the Internet, this does not matter.
Available Data
The
data available via MQTT can be viewed in
MQTT Explorer.
MQTT Broker
This page describes how to set up an MG electric car as an MQTT client via bridge. It requires a running MQTT broker. This is a server that receives data from MQTT clients and stores the status until it changes. Mosquitto is a suitable MQTT broker for Synology.


