API integration

I got stuck on the first point:
Install Moquitto.

What is Moquitto?

I have SAIC MQTT Gateway installed in home assistant. But I don't know what to set up there...
 

Attachments

  • Saic.png
    Saic.png
    2.7 MB · Views: 98
I got stuck on the first point:
Install Moquitto.

What is Moquitto?

I have SAIC MQTT Gateway installed in home assistant. But I don't know what to set up there...
Could be Mosquitto - which is an open-source MQTT "message broker"
 
I got stuck on the first point:
Install Moquitto.

What is Moquitto?

I have SAIC MQTT Gateway installed in home assistant. But I don't know what to set up there...
FYI: There is a Mosquitto intergration available for home-assistant - it's called MQTT
 
But that's only to connect to to the broker not an actual MQTT broker itself
Mosquitto broker is an addon you can install in Home Assistant to have your own broker. Simply add an account in HA and only allow local connections, then connect the SAIC to that MQTT broker (it's the default so you only need to add the username/password you setup in HA).

I have a Tesla and a MG4 Standard setup and now have this working with range, soc, AC, charging stats :cool:
Screenshot-20231216-222203-Home-Assistant hosted at ImgBB
 
That looks fantastic. I would be very grateful if you could provide a step by step guide on how to connect MG4 with Home Assistant.

Today I've made the wallbox work via OCPP protocol with Home Assistant, but having vehicle entities would be great. Thank you very much.
 
1. Install the add-on Mosquitto broker (no configuration needed, default is ok)
2. Create a user (not person) in HA for MQTT-SAIC updates (I set only allow local logins)
3. Install the add-on SAIC MQTT Gateway (Python). I used this guide GitHub - SAIC-iSmart-API/saic-home-assistant-addon: SAIC-iSmart-API repository for Home Assistant OS (HASS.IO)
4. Follow documentation, basically enter mqtt-user, mqtt-password (according to your created user in step 2 above. Enter mqtt-topic as the name of destination in HA. Enter saic-user and saic-password as your user/password to the iSmart app (I had it connected to phone login but that does not work so I had to disconnect the vehicle from that account and create a new one with email and then connect the vehicle to that). And that's it for settings in SAIC add-on.
5. Install MQTT integration in HA (defaults ok)
6. Start broker, start SAIC
7. Wait a minute
8. Your vehicle should pop up as a device under the MQTT integration.
 
I have a question for those that use the SAIC MQTT. The mg4 that I bought, is the one with 64 kWh.
In home assistant, when I charged the car at 100%, the max measurement I got for the soc_kwh sensor, was maximum 52.2.
Isn't that strange? Shouldn't the soc_kwh be around 64 when the car is fully charged?
1000016781.jpg
 
Last edited:
I have a question for those that use the SAIC MQTT. The mg4 that I bought, is the one with 64 kWh.
In home assistant, when I charged the car at 100%, the max measurement I got for the soc_kwh sensor, was maximum 52.2.
Isn't that strange? Shouldn't the soc_kwh be around 64 when the car is fully charged?View attachment 22289
anyone with the 64kwh that can tell me if they face the same issue?
 
interesting stuff - I've got the MQTT streaming data, is that actually querying the car every minute by default? Won't that stop it "going to sleep"?

edit - looks like it doesn't query the car that often while its powered down.
 
Last edited:
interesting stuff - I've got the MQTT streaming data, is that actually querying the car every minute by default? Won't that stop it "going to sleep"?

edit - looks like it doesn't query the car that often while its powered down.

"Alexa, turn on car heating" - OMG, that could make life a bit easier, although there seems to be no easy way of checking it actually worked without opening the app which seems a bit pointless :D (although if I say it in the kitchen I'll see if the lights come on)
 
"Alexa, turn on car heating" - OMG, that could make life a bit easier, although there seems to be no easy way of checking it actually worked without opening the app which seems a bit pointless :D (although if I say it in the kitchen I'll see if the lights come on)
Just look out the window for the DLRs being on
 
I managed to integrate MG4 into Home Assistant. I used here the MQTT and SAIC MQTT Gateway (Python) instructions.

The vehicle sensors are loaded. But I have the problem that most of the time the commands to control them don't work. For example, the command to turn on the air conditioning does not start. Sometimes it does, but 90% of the time the command doesn't execute and the A/C doesn't turn on. Yet the data from the vehicle is updated correctly. Someone advised to add this to configuration.yaml, but it doesn't help:


mqtt:
switch:
- name: "MG4 remote climate"
unique_id: 1d200c71-7e7e-4afd-94d2-e38933731bcf
command_topic: "saic/MY_EMAIL/vehicles/MY_VIN/climate/remoteClimateState/set"
payload_on: "on"
payload_off: "off"
state_topic: "saic/MY_EMAIL//vehicles/MY_VIN/climate/remoteClimateState"
state_on: "on"
state_off: "off"


Does anyone please know why the commands don't work?
 
I managed to integrate MG4 into Home Assistant. I used here the MQTT and SAIC MQTT Gateway (Python) instructions.

The vehicle sensors are loaded. But I have the problem that most of the time the commands to control them don't work. For example, the command to turn on the air conditioning does not start. Sometimes it does, but 90% of the time the command doesn't execute and the A/C doesn't turn on. Yet the data from the vehicle is updated correctly. Someone advised to add this to configuration.yaml, but it doesn't help:


mqtt:
switch:
- name: "MG4 remote climate"
unique_id: 1d200c71-7e7e-4afd-94d2-e38933731bcf
command_topic: "saic/MY_EMAIL/vehicles/MY_VIN/climate/remoteClimateState/set"
payload_on: "on"
payload_off: "off"
state_topic: "saic/MY_EMAIL//vehicles/MY_VIN/climate/remoteClimateState"
state_on: "on"
state_off: "off"


Does anyone please know why the commands don't work?
Hi,

I am using the python version too and the mqtt entities for MG were autodiscovered by Home Assistant on my server. If this is also the case at your installation than you should be able to add a switch to the desktop allowing off or auto plus setting of the temperature. So no need to add anything in configuration.yaml

Anyway I tested it successfully with mqtt explorer but used "saic/MY_EMAIL/vehicles/MY_VIN/climate/remoteClimateState" without "/set" at the and and sent "on" as payload.
 
Hi, I have developed a full featured nodered dashboard for my Mg4. It is in french but It could be easy to translate it. I hope that it can be helpful.
Hi Rockstar,
As a fan of Node-Red I was interested to see your project, it looks pretty thorough. Nice work.

Can you tell me if this is intended to run on Node-Red inside HA or on a standalone instance of Node-Red.

I have both available to me and run a mosquito client on both although I have loaded my first attempt at understanding your Node -Red flow on a stand alone Raspberry Pi.

I have no experience of using the GitHub - SAIC-iSmart-API/saic-python-mqtt-gateway, particularly with Node-Red and to be honest am facing a bit of a steep learning curve trying to understand it.

At present, I am still trying to figure out how to use it and enter the necessary data to access the SAIC-iSmart-API. Are there any pointers or advice you can offer?
 
Yes, the sensors load fine and display the current vehicle information. This is fine.

The problem is that the commands don't work when the air conditioning is on. Sometimes they do, but 99% of the time the command doesn't execute and the air conditioner doesn't start. The same is true when the seat heating is switched on. I'm disappointed and I don't know why it doesn't work...

1000130567.jpg
 
Last edited:
Hi Rockstar,
As a fan of Node-Red I was interested to see your project, it looks pretty thorough. Nice work.

Can you tell me if this is intended to run on Node-Red inside HA or on a standalone instance of Node-Red.

I have both available to me and run a mosquito client on both although I have loaded my first attempt at understanding your Node -Red flow on a stand alone Raspberry Pi.

I have no experience of using the GitHub - SAIC-iSmart-API/saic-python-mqtt-gateway, particularly with Node-Red and to be honest am facing a bit of a steep learning curve trying to understand it.

At present, I am still trying to figure out how to use it and enter the necessary data to access the SAIC-iSmart-API. Are there any pointers or advice you can offer?
I have updated Readme with some links to help people add added the support of multi-language.
If you want to contact me please use @ like @Purclewan otherwise I can't see your message in this flow.
Currently, it's possible to translate easily this dashboard.
 
Last edited:

Are you enjoying your MG4?

  • Yes

    Votes: 508 79.3%
  • I'm in the middle

    Votes: 86 13.4%
  • No

    Votes: 47 7.3%
Support us by becoming a Premium Member

Latest MG EVs video

MG3 Hybrid+ & Cyberster Configurator News + hot topics from the MG EVs forums
Subscribe to our YouTube channel
Back
Top Bottom