Skip to content

Instantly share code, notes, and snippets.

@malys
Last active April 26, 2024 14:26
Show Gist options
  • Save malys/5203cdf15000bd64d1da800a005bab55 to your computer and use it in GitHub Desktop.
Save malys/5203cdf15000bd64d1da800a005bab55 to your computer and use it in GitHub Desktop.
Dashboard for SAIC Electrical Vehicles (MG4)
/check.sh
/export.sh
/node_modules/
/scripts/
/package-lock.json
/dashboardTmp.png
/dashboardTmp2.png

Please visit github repository for the lastest updates.

Goals

My main goal is to integrate my MG4 in Node-red to use car's data with my automation workflow. Moreover, SAIC's ISmart mobile app is limited that why I have developed this dashboard.

Features

Dash-MG4: flow.json

  • Support of Multi-language supported (default: French)
  • Dashboard with car's components status
  • Localization of my car on a map (daily, weekly, monthly and custom journeys)
  • Compute charge cost and duration using electricity pricing limplementation (EDF in France)
  • Override Saic MQTT gateway configuration
  • Charts for:
    • Tyres pressure
    • Battery voltage
    • Consumption + cost
    • Temperature
    • Battery capacity
    • Charge calendar
  • Remote actions
    • set remote temperature, A/C mode, target SOC
    • enable A/C, lock, boot ...

MG4 Gateway: flow_gateway.json

  • Manage MQTT SAIC Gateway instance.

Miscellaneous

These features are not includes in theses flows but they have been integrated:

  • Alerting (opened windows or doors at night, tyres pressure ...)
  • Closing automatically car at night
  • Starting automatically A/C
  • Integration with Google Home Ok Google MG4 -> Your car is in the avenue Champs-Elyseés, 7 near Mc Donalds restaurant ...

Dependencies

I use Saic MQTT gateway project to query data from MG's car.

Dashboard integrates:

  • MQTT input to query data from local Moquitto
  • nodered-dashboard-ui providing ui components
  • node-red-contrib-web-worldmap as map provider
  • node-red-contrib-ui-svg to integrate MG top view from official MG website
  • EDF pricing data file to compute cost
  • Persistance in SQLite database (in beta, to remove for production)

Installation guide

No warrantly, No support, No security requirements

Schema

main

Raspberry Pie

# Slow process
https://raw.githubusercontent.com/tvdsluijs/sh-python-installer/main/python.sh | sudo bash -s 3.xx.x
# Default folder: /home/dietpi/.node-red/saic/
mkdir /home/dietpi/.node-red/
git clone --depth 1 https://github.com/SAIC-iSmart-API/saic-python-mqtt-gateway.git
mv saic-python-mqtt-gateway saic
cd saic
pip3 install -r requirements.txt
  • Launch manually SAIC Gateway for testing
# Launch gateway
python mqtt_gateway.py -m tcp://localhost:1883 -u "${saic email}" -p "${saic password}" --mqtt-user "mosquitto"  --mqtt-password "${mqtt password}"
  • Use MQTT Explorer to get path of data (ex: saic/xxx/vehicles/yyy)
    • xxx: account ID
    • yyy: vehicule ID

NodeRed

dietpi-software install 9
# or
dietpi-software reinstall 9
  • Install NodeRed
  • Enable Saving context data to the file-system
  • Import flow.json: Dash-MG4
  • Import flow_gateway.json: MG4 Gateway to manage SAIC Gateway instance in NodeRed
  • Modify Dash-MG4 to insert your configuration (replace '_to_change_xxx' variables, and see TO SETnode )
  • Modify MG4 Gateway to insert your configuration (see TO SETnode )
  • Deploy them
  • Watch Saic MQTT gateway outputs & see debug trace in Nodered
    • you have to see before MQTT gateway events
    • after that MQTT input in NodeRed will integrates data
  • Open http://${ip}:1880/ui/

Contribution

This flow is provided as it.

Feel free:

  • to improve it
  • to fix some bugs
  • to share your work ;)

Disseminating knowledge is the human duty, sharing it about so that all can benefit.

Translation

  • Edit saicInternationalFx subflow
  • Duplicate actionFR and rename actionXX
  • Translate everything in XX
  • Implement electricity functions
  • Edit label node and add XX in global.get("saic").language_supported (ex: XX=ES for spanish)
In Action

  • Test, test and test

  • Share with me actionXX && global.get("saic").language_supported contents

  • I will release a new version of this dashboard and you are the official maintainer of this language

  • Well done !

License

GNU GPLv3

Thanks

"Buy Me A Coffee"

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

@malys
Copy link
Author

malys commented Oct 26, 2023

Hi @bujiero,
I have improved readme.md to help you to understand what is happening and which parameters are useful?
Flow is also updated to fix some bugs about data transformation.

Si quieres traducir la interfaz en castellano, no seria mal de externalizar las traduccionnes de *saicActionFx", dejar el frances por defecto y anadir un parametro "LANGUAGE" para selectionar el idioma querido.
Animo !

@bujiero
Copy link

bujiero commented Oct 27, 2023

Hi
Thanks for your answerd.
Its possibly to find a guide to install Sait mqtt gateway.
Thanks

@rsenden
Copy link

rsenden commented Feb 3, 2024

Many thanks for this dashboard! Two questions:

  • The dashboard shows that the windows are open, but I checked and they are closed ;). Any idea why it's giving incorrect window status? According to image shown on the dashboard, it's an MG 2022 EH32 X3 NFZ/PBC
  • Any chance the dashboard could be shown in English, or support multiple languages?

Thanks!

@malys
Copy link
Author

malys commented Feb 3, 2024

Hi @rsenden
"The dashboard shows that the windows are open, but I checked and they are closed ;). Any idea why it's giving incorrect window status"
Excluding bugs in dashboard, sometimes downloaded data from API is temporaly false. After a new event, data has been fixed.
Try to compare vehicule state in ISmart and my dashboard.
In my case, some

"According to image shown on the dashboard, it's an MG 2022 EH32 X3 NFZ/PBC" MG4 but API is common for all SAIC cars but not tested

"Any chance the dashboard could be shown in English, or support multiple languages?"
I have spent many hours on it to cover my use case. I don't have time to develop extra features.
I'm opened about conversation to integrate multilanguage pull request.
If you want, we can open a conversation about it. I would freeze my dashboard a couple of days and share the last version to make easier internationalization integration.
To my mind, It could be interesting to:

  • Stay french by default in source code but to refactorize code to tokenize text (JSON data structure) => no behaviour change
  • Externalize JSON english, german ... translations in files hosted in this Github repository and add mechanism to download translation on start depending a parameter or env variable
  • Create override system for electricity pricing

@malys
Copy link
Author

malys commented Feb 23, 2024

@rsenden not interested anymore?

@Purclewan
Copy link

Purclewan commented Feb 24, 2024

Hi Malys.

First, thank you for this excellent piece of work. I have spent some time looking at your project and presently have it sort of running on a stand-alone Raspberry Pi in Node-Red.

It is a bit of a mash-up as the only way I could figure out how to get the Saic MQTT gateway working was to use another Pi on my network on which I have HA running. I could see how to install the Saic MQTT gateway software on HA using the Add Ons Store so I used that. Now with your flow running on one Pi and the Saic MQTT gateway running in HA and using my Mosquitto broker which runs on a further PI, I can connect to my car and get some data back. Not all the data is accurate and interaction with the car is flaky but I think that might have to do with the way I have got it set up on my network on multiple Pi's.

I have worked my way through your flow but still have not yet understood everything you are doing. What I have done is translate (with help from my French daughter-in-law) all the French descriptions into English and altered the flows accordingly although I think your suggested approach to a multi-ligual version would be more sensible.

What I now need to figure out is how to install the Saic MQTT gateway as a stand-alone system. I'm assuming it can be installed on the same Pi as my Node-Red installation but I have zero experience with Python, don't use Docker and can't make sense of the installation instructions. What I really need is a step-by-step guide. Any advice would be appreciated. Once again, thanks for your efforts.

Purclewan.

@malys
Copy link
Author

malys commented Feb 25, 2024

Hi @Purclewan
Regarding your last comment , I have changed documentation and flows:

  • Huge improvements of Readme (command lines, how to ...). Please give me your feedback and feel free to improve it
  • Sharing new flow to manage Saic gateway in NodeRed on same RPI (great for you)
  • Refactoring flows to add comments and to be more pleasant to read
    ....

@Purclewan
Copy link

Thanks for the prompt answer, I'm away for a few day but will take a look at the documentation when I get back.

Thanks from sunny but cold Scotland.

@rsenden
Copy link

rsenden commented Feb 25, 2024

Hi @malys, sorry for the delay; too busy with other things. As for the window status, indeed this was a temporary issue; later on they correctly showed as closed. I did however decide to uninstall the dashboard for now as MG doesn't support multiple connections; if I enable the Nodered dashboard (or actually the saic-mqtt-gateway) , I need to re-login every time I want to use the official MG app on my phone. Although the Nodered dashboard can do the same/more, I can't (easily) reach this dashboard when away from home, so for now it's just easier to stick to the official app.

@malys
Copy link
Author

malys commented Feb 26, 2024

@Purclewan (FYI @rsenden @bujiero ).
This rainy weekend, I implemented a strategy to translate this dahsboard.
I tested at home and it seems working well but it's an huge refactoring.
Could you read contribution chapter in readme file? tanslate , test and share your english translation.

With this changes, people could add easily translation.

@Purclewan
Copy link

Hi malys,

Hope you had a good Easter weekend.

I have followed your instructions with a fresh install on a new Pi and seem to have most things working and heading in the right direction (except for the sqlite database which I still need to look at and the screen formatting on my monitor which is a bit screwed up).

I have started work on the English translation and have it largely done but have gotten a bit stuck at the point where I need to modify the label node. In your installation instructions I'm not clear on what is meant by "Edit label node and add XX in global.get("saic").language_supported".

Do I add a new line in this Lable node and how is it formatted or, do I add the letters EN into the existing line "msg.options = global.get("saic").language_supported" and if so how is it expected to be formatted?

Sorry if I am being a bit stupid but my Node Red programming skills and knowledge don't match yours.

Many thanks for your great work here.

Purclewan

@malys
Copy link
Author

malys commented Apr 2, 2024

@Purclewan
See your message in mgevs.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment