MG Motor Mg5 Electric Car Integration

Ah, OK, thanks.

I have uninstalled that version and installed the legacy version, although I think at present the MG servers are offline as people across the country haven’t been able to connect to their cars with with their iSmart app.

No matter, as long as I can see the MQTT topics appear in Home Assistant is what I’m looking for.

I can see them in MQTT Explorer:

Screen Shot 2024-03-22 at 6.20.19 pm

where it just reports
lwt = offline

Not sure what lwt is but I am at least seeing an SAIC topic which suggest I have part of the set up right.

But I can’t see anything in the Home Assistant MQTT integration, just my Solar Assistant data:

Not really sure what I am missing?

I can only guess that with MG’s API being down, there’s no values to publish, hence no entities to auto discover ?

Unless there are some clues in the add on’s log, we won’t know too much more until the API comes back online.

Also thanks - just did that and restarted, I see many more topics in MQTT Explorer now (I blanked out my SAIC log in email address):

Screen Shot 2024-03-22 at 6.31.42 pm

But still not sure how I get access to these into Home Assistant.

Take another look at your MQTT integration and see if your MG now appears as a device

It should look like this:

Unfortunately not. It’s just showing my Solar Assistant MQTT feed.

I think there is something about MQTT integration which only allows one MQTT connection. Which seems rather odd.

Hey @wattmatters, I recognise you from the MG owners Aussie thread!
As you mentioned, there’s an issue with the API so this addon isn’t updating at the moment.
Your MQTT topics look similar to mine:
image

Here’s my settings from the SAIC MQTT Gateway (Python) (legacy) integration in HA. I have HA_DISCOVERY_ENABLED turned off, but if you enabled this and use “homeassistant” as the HA_DISCOVERY_PREFIX you should get auto discovered entities for MQTT.


1 Like

Thanks!

This is what I have (and is what was already there):

I get nothing from SAIC in the MQTT integration.

I only see my Solar Assistant topic feed.

Hmm, if you go to your integrations page and pick MQTT, do you have discovery enabled there? You’ll need to expand the options next to configure and select ‘System Options’

Yep.

The thing to note is where yours says “Mosquitto broker”, mine shows an IP address (192.168.0.160) which is not HA, but rather my Solar Assistant.

I was wondering about that address.
You may need to go into the configure option for that entry in your screenshot, then “re-configure mqtt”. Turn on the ‘advanced options’ toggle and work you way though the menus. Double check discovery is enabled and the prefix is set.

In MQTT explorer you don’t seem to have the ‘homeassistant’ topic present which suggests it’s not looking for discovery.

If you don’t care about discovery, you can setup manually (this is actually how my deployment works as I have MQTT discovery turned off).

In /configuration.yaml

mqtt:
  sensor:
    - name: mg4_soc_percent
      state_topic: "saic/[email protected]/vehicles/VIN/drivetrain/soc"
      value_template: "{{ value }}"
      unit_of_measurement: "%"
    - name: mg4_soc_kwh
      state_topic: "saic/[email protected]/vehicles/VIN/drivetrain/soc_kwh"
      value_template: "{{ value |round(1) }}"
      unit_of_measurement: "kWh"
    - name: mg4_range
      state_topic: "saic/[email protected]/vehicles/VIN/drivetrain/range"
      value_template: "{{ value |round(0) }}"
      unit_of_measurement: "km"

… and so-on. Definitely not as friendly as discovery though!

Edit: I just looked at your screenshots again.
You have two MQTT brokers? 192.168.0.139 used by SAIC, and 192.168.0.160 used by Solar Assistant?
I think you want to settle on a single broker. You could try and bridge with mosquitto but I’m not sure it’s worth the complexity. I’ve never tried it.

It would appear so. I don’t fully understand how/why but it seems I can’t have both at the same time.

I’ve had the MQTT connection with Solar Assistant for some years, and that’s the IP address for Solar Assistant.

I’m not sure how though.

OK, I went thorugh reconfigure and put in the IP address and login details for the Home Assistant MQTT broker.

Now MQTT integration is showing two devices:


However the original MQTT for the Solar Assistant (showing as Axpert Max) is no longer being populated.

It’s dead as a door nail:

That one matters as it’s my home’s energy systems, so I’ll need to revert back to that unless/until I can work out how to make it work with the HA MQTT.

But it is showing the SAIC data:

Two steps forward, one step back!

And after reverting to the Solar Assistant MQTT I have my energy system data back but the SAIC data is not available.

This might help:

Thanks, good find. Going through it, it shows a customise config option needs to set as true.

I cannot see that option when I go through the MQTT reconfigure menus. Perhaps I need to uninstall it (gulp) and reinstall MQTT, and start over with this process.

Will have to look at it more tomorrow, have run out of puff tonight. Thanks again.

Ah, that option isn’t under the integrations area.
You need to go into Settings > Addons > Mosquitto broker and configure from there.
It’s a broker (server) setting, not an integration setting.
Don’t forget to take some backups (or ideally a snapshot if you have a VM) before getting to deep into this.

Yeah I think that’s a limitation of the MQTT integration. It won’t talk to two brokers at once, hence the need for a bridge.

If you can use the Solar MQTT broker for everything (assuming it supports non-Solar Assistant topics) then that’s probably the easiest way to avoid lots of reconfiguration. You could point HA and the SAIC add-on to that broker (0.160) and let it do everything.
You’d need to confirm it will support this scenario though.

Thanks, yes I see that now.

I run HA on a Proxmox VM (thanks to major help from WP member curto), so I can take a snapshot and rollback as needed. It’s now my normal process before major updates. Backups are automated.

I admit to not understanding the difference between an MQTT broker and an MQTT bridge, only that what I have doesn’t work and I need to try this instead.

While it’s a good suggestion (and I don’t know whether it would or would not work) but I think I’d rather not do this and will attempt to set up the bridge. I may need to come back to it if I fail with the bridge approach.

I have no idea what, if any, breaking changes the Solar Assistant developer might introduce in future, and since they went to the trouble of outlining how to set up an MQTT bridge in HA as a way to resolve this problem it would seem sensible to go down this path.

Also I want my Solar Assistant Raspberry Pi to just focus on doing the job of managing the interface with my off-grid energy system. I’d rather not be reliant on it managing other stuff from a hardware/uptime standpoint. Better those other tasks be on my HA hardware which is more robust and is automatically backed up (there are no auto backups with Solar Assistant). Unfortunately there is no option to run Solar Assistant on different hardware.

If I understood these things better I’d probably work out it was better to have an MQTT bridge/broker running on it’s own VM, but that’s way past my pay grade!

I will give this a go, hopefully today, and will report back.

Thanks to you and others for all the tips, pointers and encouragement.

Looks like the MG server is still down nationwide in any case.

1 Like

Time for an update.
EDIT: ISSUED RESOLVED - SEE FOLLOWING POST FOR DETAILS

I installed the MQTT bridge as described in the Solar Assistant documentation. That is working with my Solar Assistant. All sensors reading as normal and control going the other direction are working too. So it is a relief that part works.

So what I now need to do is work out how to add the SAIC/MG stuff.

The MQTT custom config file looks like this:

/share/mosquitto/solar_assistant.conf

connection SolarAssistant
#remote_username solar-assistant
#remote_password solar123
address 192.168.0.160
topic # in
topic solar_assistant/# out

The username and password are un-used placeholders in my instance.

I’m now assuming I need to set up a similar config file for the SAIC MQTT feed but not I’m entirely sure about that.