MG Motor Mg5 Electric Car Integration

You can create your own sensor and filter out the dodgy 87C value.
I don’t have autodiscovery of entities turned on; I only have the handful of sensors I’m interested in manually configured.

mqtt:
  sensor:
    - name: mg4_climate_temp_interior
      state_topic: "saic/[email protected]/vehicles/VIN/climate/interiorTemperature"
      value_template: "{{ '' if value == '87' else value }}"
      unit_of_measurement: "°C"

1 Like

Thanks man! I’ll look into this… seems like the reading is ok once the car is running …
Meanwhile I need to find out how to ‘force’ an update and also how do you guys use the ismart app together with the integration?

Seems like

  1. The car can be bound to just 1 app login and
  2. The login can be used only with 1 system at a time…

So if I’m logged in with HA and open my ismart app it asks me to re input the password everytime :grimacing:

1 Like

Are you using the EU version? I’m using the Legacy version due to AU origin car and getting logged out all the time… plus I need to manually type in the password (bitwarden is not working in that app nor copy/paste) =[

No, but if an entity has no use for you then sure, disable it in HA. Mine is the 64 Essence/Australia as well.

When the car is off the polling of the car stops after a short while. No point needlessly waking the car’s systems up when there is nothing new to report.

Have a look upthread over the last week where I learn about polling the car and posted the section from the integration documentation about the polling settings.

The integration automatically polls the car when on and being driven. I think it also auto polls if a charge session is initiated by the car (my charge sessions are initiated by my home charger).

You can manually poll it and I set up a couple of automations to start polling when my home charge station commences charging the car and also I trigger an automation to poll every 15 minutes if I am discharging the car with V2L (the automation turns itself off if the discharge sessions stops).

I don’t. SAIC only permit one login at a time, be it via this integration or from the iSmart app.

I built a HA dashboard suitable for the phone and that is now available to my wife and I to use if needed. Haven’t needed to open the iSmart app since.

2 Likes

Thanks man… My current issue is that the integration sometimes goes “grey” as in the switches and entities just choke up or something and eventually come back.
In the app if it fails to communicate you get a message and retry right away. So far for me it’s kind of hit or miss and my internet is definitely solid :thinking:

I also need to figure out the best way to expose my HA to the outside world… so far I’ve dabbled in Zero tier only

Just a note that AU/NZ users have to use the legacy add-ons for now.

Nice work.

Can I ask what you used to build the dashboard? Is it just YAML or an add-on?

It’s just a standard Home Assistant dashboard.

For the one intended for viewing on the phone I just selected a One Panel card then added a vertical stack card and populated that with the cards and entities.

I have another for the computer with all the entities and controls plus a few other things. It’s not meant to be pretty, just somewhere I can find most things.

2 Likes

Thanks to all on this thread I now have a fully-functional (?) integration running for my 2022 ZSEV. I’m in NZ, and once I worked out that I needed to use the legacy add-on version, it just worked ™.

The question I have now is the errors showing up in the add-in log.

e.g.
2024-04-17 19:33:30,900 [ INFO ] ID: 496653, Time: 2023-07-25 12:53:56, Type: 801, Title: Electric power steering warning, Content: Your vehicle (***675) status is abnormal, please go to vehicle status for details., Status: read, S

The thing is, If I open up the app on my phone, or start the car, everything is fine.

Any idea whether I should be concerned or not?

It looks like this is just an old event from the vehicle. The add-in is very verbose in this regards. I wouldn’t be concerned.
My log is loaded with historic tyre pressure warnings from my MG4 :slight_smile:

A-ha! Yes - I see that now. Good to know, thanks.

I’ve just been into the mobile app and deleted these old messages from there and the add-on no longer reports them.

Result!

Aside the occasional blip in the cabin temperature reading, which sometimes displays as 83°C (or something like that), I note my Range entity is now showing 2,046 km. Which would be nice but clearly that’s an error.

Restarting the add on makes no difference, while the range in the iSmart app shows 301 km.

This is one of the (minor) reasons I use manually defined sensors rather than auto discovery. You can filter out the spurious readings:

    - name: mg4_climate_temp_interior
      icon: mdi:thermometer
      state_topic: "saic/xxxx@yyyy/vehicles/LSJWxxxx/climate/interiorTemperature"
      value_template: "{{ '' if value == '87' else value }}"
      unit_of_measurement: "°C"

Yeah, thanks. It cleared itself. It’s certainly curious.

Adding in my 2c here for how I have this integrated. Using HA in a docker so add-ons was not option.

Have setup in “Container Manager” aka Docker on Synology NAS.

eclipse-mosquitto
As the broker, important piece I believe was the configuration to allow anon connections.

Make a folder for Mosquitto, and three sub folders. Volume mapping for container as below:

/docker/Mosquitto/config : /mosquitto/config
/docker/Mosquitto/data : /mosquitto/data
/docker/Mosquitto/log : /mosquitto/log

Under config folder have file mosquitto.conf with content as below:

persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log
listener 1883
allow_anonymous true
socket_domain ipv4

saic-python-mqtt-gateway
And then since I am in AU, used the specific 0.4.6 version of

Add in envrionment variables to point at the NAS
MQTT_URI : tcp://[NASIP]:1883

Then realising the the 0.4.6 version has a different evironment variable name than the latest version of add-on has (this is what took me a while to work out)
SAIC_URI : https://tap-au.soimt.com/

MQTT
Back in HA, add in MQTT integration, point it at your NAS IP. Then slowly get data. Neat.

Have not tried like unlocking doors or anything yet, as im not near the car.
Actually just tried it then, seems to work, will reconfirm later.

1 Like

Managed to get my integration setup today thanks to this fantastic guide. I have a question for you though if you don’t mind watt??

Would it be possible for you to share the raw YAML for your current dash? I want to use it as a starting point for mine as the layout is brilliant

Here’s the code for the phone dashboard. I hope it helps.

Note: In the code below I have replaced my unique vehicle’s code with a generic identifier carID, so you would need to replace those sensors with your own created by the add-on.

The phone dashboard is set up as Panel (one card) type rather than the usual Masonry dashboard. It looks weird on a computer browser but suits our iPhone screens.

I also use some Mushroom cards, so you would need to install those in order to replicate this. These are a HACS front end, refer the link above.

I’m wondering whether a Mushroom card for indicating SOC would be nicer than the gauge I set up.

type: vertical-stack
cards:
  - type: horizontal-stack
    cards:
      - type: gauge
        entity: sensor.carID_soc
        name: SOC
        needle: true
        segments:
          - from: 0
            color: '#FF0000'
          - from: 1.47
            color: '#FF0F00'
          - from: 2.94
            color: '#FF1E00'
          - from: 4.41
            color: '#FF2D00'
          - from: 5.88
            color: '#FF3C00'
          - from: 7.35
            color: '#FF4B00'
          - from: 8.82
            color: '#FF5A00'
          - from: 10.29
            color: '#FF6900'
          - from: 11.76
            color: '#FF7800'
          - from: 13.24
            color: '#FF8700'
          - from: 14.71
            color: '#FF9600'
          - from: 16.18
            color: '#FFA500'
          - from: 17.65
            color: '#FFB400'
          - from: 19.12
            color: '#FFC300'
          - from: 20.59
            color: '#FFD200'
          - from: 22.06
            color: '#FFE100'
          - from: 23.53
            color: '#FFF000'
          - from: 25
            color: '#FFFF00'
          - from: 26.57
            color: '#F7FD00'
          - from: 28.14
            color: '#F0FC00'
          - from: 29.71
            color: '#E9FA00'
          - from: 31.29
            color: '#E1F900'
          - from: 32.86
            color: '#DAF701'
          - from: 34.43
            color: '#D3F601'
          - from: 36
            color: '#CCF401'
          - from: 37.57
            color: '#C4F301'
          - from: 39.14
            color: '#BDF101'
          - from: 40.71
            color: '#B6F002'
          - from: 42.29
            color: '#AEEE02'
          - from: 43.86
            color: '#A7ED02'
          - from: 45.43
            color: '#A0EC02'
          - from: 47
            color: '#99EA02'
          - from: 48.57
            color: '#91E903'
          - from: 50.14
            color: '#8AE703'
          - from: 51.71
            color: '#83E603'
          - from: 53.29
            color: '#7BE403'
          - from: 54.86
            color: '#74E303'
          - from: 56.43
            color: '#6DE104'
          - from: 58
            color: '#66E004'
          - from: 59.57
            color: '#5EDE04'
          - from: 61.14
            color: '#57DD04'
          - from: 62.71
            color: '#50DC04'
          - from: 64.29
            color: '#48DA05'
          - from: 65.86
            color: '#41D905'
          - from: 67.43
            color: '#3AD705'
          - from: 69
            color: '#33D605'
          - from: 70.57
            color: '#2BD405'
          - from: 72.14
            color: '#24D306'
          - from: 73.71
            color: '#1DD106'
          - from: 75.29
            color: '#15D006'
          - from: 76.86
            color: '#0ECE06'
          - from: 78.43
            color: '#07CD06'
          - from: 80
            color: '#00CC07'
          - from: 81.18
            color: '#08C410'
          - from: 82.35
            color: '#10BC19'
          - from: 83.53
            color: '#18B422'
          - from: 84.71
            color: '#20AC2B'
          - from: 85.88
            color: '#28A434'
          - from: 87.06
            color: '#309C3D'
          - from: 88.24
            color: '#389446'
          - from: 89.41
            color: '#408C4F'
          - from: 90.59
            color: '#488458'
          - from: 91.76
            color: '#507C61'
          - from: 92.94
            color: '#58746A'
          - from: 94.12
            color: '#606C73'
          - from: 95.29
            color: '#68647C'
          - from: 96.47
            color: '#705C85'
          - from: 97.65
            color: '#78548E'
          - from: 98.82
            color: '#804C97'
          - from: 100
            color: '#8845A1'
        unit: '%'
      - type: tile
        entity: sensor.carID_range
        icon: mdi:map-marker-distance
        name: Range
        vertical: true
      - type: custom:mushroom-entity-card
        entity: sensor.carID_auxiliary_battery_voltage
        layout: vertical
        name: Aux Battery
  - type: horizontal-stack
    cards:
      - type: custom:mushroom-entity-card
        entity: binary_sensor.carID_charger_connected
        name: Charger
        layout: vertical
        primary_info: none
      - type: custom:mushroom-entity-card
        entity: binary_sensor.carID_battery_charging
        name: Charging?
        layout: vertical
        primary_info: none
      - type: custom:mushroom-entity-card
        entity: sensor.carID_power
        name: Power
        layout: vertical
        primary_info: none
  - type: horizontal-stack
    cards:
      - type: thermostat
        entity: climate.carID_vehicle_climate
        name: Car Aircon
        show_current_as_primary: true
        features:
          - type: climate-hvac-modes
            hvac_modes:
              - 'off'
              - auto
      - type: vertical-stack
        cards:
          - type: custom:mushroom-entity-card
            entity: counter.ev_days_since_100_soc
            name: Days Since 100% SOC
            layout: vertical
          - type: custom:mushroom-number-card
            entity: number.carID_target_soc
            layout: vertical
            name: Target SOC
  - type: horizontal-stack
    cards:
      - type: custom:mushroom-lock-card
        entity: lock.carID_doors_lock
        name: Doors
      - type: custom:mushroom-lock-card
        entity: lock.carID_boot_lock
        name: Boot
  - type: horizontal-stack
    cards:
      - type: tile
        entity: sensor.carID_mileage
        icon: mdi:counter
        name: Odometer
        show_entity_picture: false
        vertical: false
        color: accent
      - type: tile
        entity: sensor.ev_mileage_monthly
        color: accent
        name: Monthly km

I have two sensors above which are not generated natively by the add on.

They are counter.ev_days_since_100_soc and sensor.ev_mileage_monthly.

For sensor.ev_mileage_monthly I just created a Utility Meter helper based on the mileage sensor
sensor.carID_mileage. I have one for daily and monthly.

For counter.ev_days_since_100_soc I set up a counter helper which is controlled by two automations (although I probably could combine the automations into one).

The first automation increments the counter each day at midnight:

alias: EV - Increment Counter Days Since EV 100% SOC
description: Increment the days since EV 100% SOC cycle counter each day
trigger:
  - platform: time
    at: "00:00:00"
condition: []
action:
  - service: counter.increment
    data: {}
    target:
      entity_id:
        - counter.ev_days_since_100_soc
mode: single

The second resets the counter whenever SOC ever reaches 100%:

alias: EV - Reset Days Since 100% SOC
description: Reset Counter for number of days since the car was fully charged.
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.carID_soc
    above: 99
condition: []
action:
  - service: counter.reset
    target:
      entity_id: counter.ev_days_since_100_soc
    data: {}
mode: single

While functional, it’s still a fairly naive dashboard IMO.

I’m sure there are others who could make a much nicer looking dashboard, using animated images of the car for instance to highlight various things, a bit like what some clever cookies have done in this thread (way above my pay grade):

If it was ever done for the MG4 it would be super cool.

4 Likes

As a thank you for your assistance in getting this up and running I am sharing my picture elements card with you. It displays the tyre pressures in the correct locations on the car:

type: picture-elements
elements:
  - type: state-badge
    entity: sensor.lsjwh4097pn077873_tyres_front_left_pressure
    style:
      top: 17%
      left: 60%
      '--ha-label-badge-title-font-size': 0em
  - type: state-badge
    entity: sensor.lsjwh4097pn077873_tyres_front_right_pressure
    style:
      top: 80%
      left: 60%
      '--ha-label-badge-title-font-size': 0em
  - type: state-badge
    entity: sensor.lsjwh4097pn077873_tyres_rear_left_pressure
    style:
      top: 17%
      left: 30%
      '--ha-label-badge-title-font-size': 0em
  - type: state-badge
    entity: sensor.lsjwh4097pn077873_tyres_rear_right_pressure
    style:
      top: 80%
      left: 30%
      '--ha-label-badge-title-font-size': 0em
image: local/community/mg4-ext3.jpg

Use this image as the background and upload it to your HA instance under www/community

3 Likes

Wow, that’s neat, thanks! I’ve not knowingly used a picture elements card before, always good to learn something new.

If I may, where did you find the image? I’ve googled but no luck. It would be nice to get one matching our car’s colour.

Added a couple of things but gets easily cluttered.

Not sure I like the battery status with this one:

1 Like

I searched for “MG4 aerial view”

I was going to see if there was a way of setting the colour via a drop down and get one example of each available colour.

I am going to spend some time working out how best to add things like the battery status on the picture card.

1 Like