Giter Club home page Giter Club logo

saic-api-documentation's Introduction

saic-api-documentation's People

Contributors

tisoft avatar dependabot[bot] avatar reverseengineeringde avatar mschmiedel avatar

Stargazers

Sean Yem avatar HTeimue avatar  avatar Louis Erbkamm avatar  avatar Marco Hoyer avatar Víctor Uceda avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar James Smith avatar  avatar Alex avatar  avatar  avatar  avatar Domingo Martínez Núñez avatar  avatar Patrick Wadström avatar Anton Samuelsson avatar Andrew Lindsay avatar Jonathan McCrohan avatar RedRoan04 avatar  avatar  avatar Eirik Corneliussen avatar Duco Sebel avatar Thomas Salm avatar  avatar Martin Bock avatar  avatar Daniel Oldberg avatar Christian Haschek avatar Adrien DAURIAT avatar Freekers avatar  avatar  avatar Shemin A Salam avatar Andreas Stegemann avatar Thibault Ehrhart avatar Josef Burg avatar  avatar Benjamin Beichler avatar Thanatip S. avatar Markus Karlsson avatar  avatar  avatar  avatar James avatar  avatar Mathias avatar  avatar  avatar  avatar Bastian PW avatar Steffen Mahler avatar  avatar TyMi avatar  avatar

Watchers

 avatar  avatar Matthias Schonder avatar  avatar Thanatip S. avatar Domingo Martínez Núñez avatar  avatar  avatar Bastian PW avatar Alex avatar Felipe Pavanela avatar  avatar  avatar  avatar  avatar  avatar  avatar

saic-api-documentation's Issues

Project Structure Proposal

Currently we have this project which contains the reverse engineered documentation and the java api and mqtt implementation. Additionally we have https://github.com/ReverseEngineeringDE/iSmart-Gateway-Home-Assistant-Add-on which contains the HA add-on.

We have a fork from @tosate, who implemented a python integration here: https://github.com/tosate/SAIC-API-Documentation/tree/main/saic-python-mqtt-gateway

I have a fork of the OpenHAB repository, containing the OpenHab plugin here: https://github.com/tisoft/openhab2-addons/tree/saic_api

There might be other language or home automation integrations later.

I would like to propose a new structure:

  • We create a new GitHub organization (something like SAIC-Open-API, or something) with the following projects

What do you think?

Explicitly pinging @ReverseEngineeringDE, @tosate, @mschmiedel, @weidi, @Tonno87 since all of you committed or forked one of the repos.

Python implementation

Hi there,

thank you for your impressive work so far. I am currently working on a Python version of the SAIC API. I am aware of the fact that a second codebase will add more maintenance, redundancy and bugs. However, my goal is to implement the basis for a Home Assistant integration or an openWB SoC module, so that those systems no longer rely on a running docker container. As a prove-of-concept, I have re-implemented your MQTT gateway.
Whether you like the idea of another implementation or not, what I can offer you is a code review since I have spend a lot of time with your code during the last weeks.

One thing that was confusing me, is the if-condition in the handleVehicle() method of the VehicleHandler class. I would expect that the VehicleHandler updates the status and then waits for another 15 minutes before it checks the status again. But what I see in the code is that it queries the API as often as possible for 15 minutes. After that it sleeps until an event from the MessageHandler wakes it up. When I subscribe to one of the topics, I see the same. My container starts up, publishes the mileage and the SoC more than 450 times. That means it sends more than 900 requests to the SAIC API. In parallel, it checks every second for new alarms.

I have read that you did not run into limitations with this yet. However, we might get into trouble when SAIC notices that some clients run heavily on steroids.

To avoid this behaviour I have implemented my VehicleHandler slightly different. The notifyCarActivity() method updates the lastActivityTime only.

def notify_car_activity(self, last_activity_time: datetime):
    if (
            self.last_car_activity is None
            or self.last_car_activity < last_activity_time
    ):
        self.last_car_activity = last_activity_time
        self.publisher.publish_str(f'{self.vin_info.vin}/last_activity',
                                    self.last_car_activity.strftime("%Y-%m-%d, %H:%M:%S"))   

Things like forcing an update are handled in the while-loop of the handleVehicle() method.

while True:
    if (
        self.last_car_activity is None
        or self.force_update
        or self.last_car_activity < (datetime.datetime.now() - datetime.timedelta(minutes=self.configuration.query_vehicle_status_interval))
    ):
        self.force_update = False
        vehicle_status = self.update_vehicle_status()
        charge_status = self.update_charge_status()
        self.abrp_api.update_abrp(vehicle_status, charge_status)
        self.notify_car_activity(datetime.datetime.now())
    else:
        # car not active, wait a second
        print(f'sleeping {datetime.datetime.now()}, last car activity: {self.last_car_activity}')
        time.sleep(float(1))

Kind regards,
Thomas

ASN.1 File generation from compiled classes

The ASN.1 files found in the apk seem to be of an old version old the protocol.

There seem to be several versions of the binary protocol. Which can be found in the packages under com.saicmotor.telematics.tsgp.otaadapter.mp.

The classes in that package are annotated with annotations from a custom fork of https://sourceforge.net/projects/bnotes/

The annotations completely describe the ASN.1 format.

My idea is to create an annotation processor, that reads those classes and recreates the ASN.1 specification.

What do you think about that idea?

Verbingung zum mqtt Server bricht nach exact 5min ab

Hallo,

erstmal vielen Dank für diese Software. Leider wird anscheindet die MQTT Verbindung zu meinem MQTT Server nach 5min getrennt

java.util.concurrent.ExecutionException: Client is not connected (32104)
at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
at net.heberling.ismart.mqtt.SaicMqttGateway.call(SaicMqttGateway.java:293)
at net.heberling.ismart.mqtt.SaicMqttGateway.call(SaicMqttGateway.java:67)
at picocli.CommandLine.executeUserObject(CommandLine.java:2041)
at picocli.CommandLine.access$1500(CommandLine.java:148)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
at picocli.CommandLine.execute(CommandLine.java:2170)
at net.heberling.ismart.mqtt.SaicMqttGateway.main(SaicMqttGateway.java:327)
Suppressed: Client is disconnected (32101)
at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:31)
at org.eclipse.paho.client.mqttv3.internal.ClientComms.disconnect(ClientComms.java:507)
at org.eclipse.paho.client.mqttv3.MqttAsyncClient.disconnect(MqttAsyncClient.java:818)
at org.eclipse.paho.client.mqttv3.MqttAsyncClient.disconnect(MqttAsyncClient.java:779)
at org.eclipse.paho.client.mqttv3.MqttAsyncClient.disconnect(MqttAsyncClient.java:788)
at org.eclipse.paho.client.mqttv3.MqttClient.disconnect(MqttClient.java:347)
at net.heberling.ismart.mqtt.SaicMqttGateway$1.close(SaicMqttGateway.java:176)
at net.heberling.ismart.mqtt.SaicMqttGateway.call(SaicMqttGateway.java:172)
... 10 more
Caused by: Client is not connected (32104)
at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:31)
at org.eclipse.paho.client.mqttv3.internal.ClientComms.sendNoWait(ClientComms.java:205)
at org.eclipse.paho.client.mqttv3.MqttAsyncClient.publish(MqttAsyncClient.java:1375)
at org.eclipse.paho.client.mqttv3.MqttClient.publish(MqttClient.java:570)
at net.heberling.ismart.mqtt.VehicleHandler.updateChargeStatus(VehicleHandler.java:549)
at net.heberling.ismart.mqtt.VehicleHandler.handleVehicle(VehicleHandler.java:79)
at net.heberling.ismart.mqtt.SaicMqttGateway.lambda$call$2(SaicMqttGateway.java:278)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)

Mit Wireshark sind die letzten Lebenszeichen

das der Server ein Websocket PING schickt und der Client darauf sofort die Verbindung schliesst

Mixed success

Trying to use the ismart-api-cli username password I initially get a The account is not registered. response. After some looking around I notice that the app mentioned in the Getting Started section is for .europe and the app I have on my phone is .au - So I try modifying the endpoint URL to https://tap-au.soimt.com/... which gives me a different error message Incorrect password. You may have another 4 attempts of the day, please try again.

I have verified via java debugger that the password is correct (albeit complicated).

Has anyone had success with a non .europe account?
Has anyone had success with a complex password?

Cheers!

Help to read MG4 Trophy figures

Hi everyone,

This is a great project! It worked first time using the CLI - but I'm having issues reading the numbers returned.
I'm just after the current charge level. I've attached a screenshot from the MG app showing 60% charge, and the JSON returned from running the JAR. I can see "bmsPackSOCDsp":1023 but I'm unsure how that relates, or how to convert it.
Can anyone shed any light for me? Thank you :)

Adam
mg4.txt
mg4

MQTT Topic Hierarchy

Proposed structure for the MQTT topic hierarchy:

  • saic
    • email
      • messages (one subtopic for every message, currently stored on the server)
        • messageId
          • messageType
          • title
          • messageTime
          • sender
          • content
          • status (read/unread)
            • set (read/unread/delete)
          • vin
      • vehicles (one subtopic for every vehicle)
        • VIN
          • info
            • brand
            • model
            • year
            • series
            • color
            • lastMessage (read only, to delete use account topic)
              • messageId
              • messageType
              • title
              • messageTime
              • sender
              • content
              • status (read/unread)
          • refresh
            • mode (off, periodic, auto)
              • set (accepts values from above. Additionally force will trigger a single fetch, but keep the
                current mode)
            • lastChargeState
            • lastVehicleState
            • period (only used if in periodic mode)
              • active (period in seconds to query the API, if the car is active, if not set the inActive period is used)
                • set
              • inActive
                • set
          • configuration (subtopic for each entry from the modelConfigurationJsonStr field from the API)
            • code
              • name
              • value
          • location
            • position (GPOS position as JSON object)
            • heading
            • speed
          • drivetrain
            • charging
              • set
            • chargerConnected
            • chargingType (slow/fast)
            • running
            • auxiliaryBatteryVoltage
            • mileage
            • range
            • current
            • voltage
            • power
            • soc
          • climate
            • interiorTemperature
            • exteriorTemperature
            • remoteTemperature (The temperature used in remote preheat commands)
              • set
            • remoteClimateState (off, front, on)
              • set
            • backWindowHeat (off, on)
              • set
          • windows
            • driver
              • set
            • passenger
              • set
            • rearLeft
              • set
            • rearRight
              • set
            • sunRoof
              • set
          • doors
            • locked
              • set
            • driver
            • passenger
            • rearLeft
            • rearRight
            • bonnet
            • boot
          • tyres
            • frontLeftPressure
            • frontLeftPressure
            • rearLeftPressure
            • rearRightPressure
          • lights
            • mainBeam
            • dippedBeam

Topic names in Italic are placeholders for the actual content. E.g. VIN is replaced by the actual VIN from the
vehicle. Not all vehicles support all functionality, so some of the subtopics will not be available for each type of
vehicle.

[Enhancement] Werte gezielt abfragen mit Zeitintervall

Hallo Zusammen,

tolles Projekt! Danke für eure Arbeit :)

Ich würde mir wünschen das die configfile so erweitert wird das man z.B. nur den SOC abfragen kann.
Für die meisten Anwender ist dieser Wert ausreichend, der Rest ist optional.

Auch hätte ich gerne eine Möglichkeit um die Intervalle der Abfrage zu ändern. Beim laden an der Wallbox sind meiner Meinung nach Werte von 1-2 min ausreichend. Um mit 11kw 1% zu laden dauert es länger als 2 Minuten. Daher sollte EVCC damit umgehen können.
Das erzeugt zum einen weniger Datenmüll und zum anderen wird es damit unwahrscheinlicher das die API abfragen irgendwann geblockt werden. Je mehr das Gateway benutzen desto eher wird das zum Problem werden.

Was meint ihr dazu?

How to install and config the mqtt

Hello

Would it be possible to have a how-to for the mqtt if we are not using home assistant?

I installed the docker based on the link given on the GitHub but I don't find the configuration file in the etc folder. And I have no idea of what should be configured in this file.

Tx

Antoine

Getting weird numbers

Screenshot_20230103-181721.png

Shows 102 % soc and thus all other related values not plausible.

SOC at this time was 34%

Can't install last version of iSMART on Marshmallow

Hi all,
Sorry, I am a beginner with Android Virtual Device.
I managed to run an AVD with an armeabi-v7a iso of Marshmallow and push the iSMART apk with abd, but when I launch the app, it says "Update to V1.1.10, MG iSMART has some major updates, please update to the latest version.", and all I can do is to click the Update button, which launch the browser to the Google Play page of the app. But I can't download the apk from here (even if I log in with my Google account), it seems to detect that the device is not compatible (because it suggests to install the app to different devices instead). I can't find a 1.1.10 apk compatible with Marshmallow. And I failed installing Google Play Store app on Marshmallow so far.
Is everybody stuck with this app update, or am I missing something obvious to solve the issue?
Thank you for your help!

Country without iSmart

Hi, I am an owner of MG ZS EV 2022 Facelift. Currently iSmart is not available in my country. However, I was able to bind the iSmart app (UK) to my vehicle. But everything can't be loaded, probably the eSIM is not supported here.
Would like to confirm if the API provided by SOIMT can only be accessible from internet?
If my car has no internet connectivity, is that there is no way to receive the car's SOC information ?

Thanks!

Unit / Meaning of "powerUsageOfDay"

First of all! Thanks for this fantastic project. I've been playing around with the APIs for roughly 11 months (ever since I got the ZS) - yet didn't have the time to go into all details.

For the ZS I currently use the following values:
bmsPackSOCDsp (% / 10), bmsEstdElecRng (km), fuelRangeElec (km / 10), mileageOfDay (km / 10), totalBatteryCapacity (kWh / 10), mileage (km / 10)
All of those match the car's values or my expectations. My idea is (among others) to calculate and show the daily average consumption.

However for powerUsageOfDay I have no clue how to interpret it. I was expecting the unit to be kW (after diving it by 10). However that cannot be the case: according to my logged data the car should be almost empty, but is still half full. Percentage also does not work for the same reason.

Also the power usage does not seem to correspond to the daily mileage:

  • 7.12.: mileageOfDay: 18 km / powerUsageOfDay: 304
  • 8.12.: mileageOfDay: 14 km / powerUsageOfDay: 46

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.