SAIC-iSmart-API / saic-python-mqtt-gateway

MIT License
67 stars 20 forks source link

Q: Log-pulls per minute - is this correct? #39

Closed michpas closed 1 year ago

michpas commented 1 year ago

In the logfile of the SAIC MQTT Gateway I see every minute an entry; even while the car has been parked (with charge cable) for some hourse . See below. I was wondering, does this mean the gateway is logging into the app every minute? Doesn't this drain the battery? I have actively pushed the refresh mode to 'periodic', but I still get a logbook entry every minute.

... 2023-07-18 09:06:19,842 0 messages received 2023-07-18 09:07:20,025 0 messages received 2023-07-18 09:08:20,241 0 messages received 2023-07-18 09:09:20,416 0 messages received 2023-07-18 09:10:20,711 The SAIC user has been logged out. Waiting 900 seconds before attempting another login 2023-07-18 09:23:52,310 Setting vehicle handler mode for VIN XXXXXXX to refresh mode: 2023-07-18 09:25:21,348 0 messages received 2023-07-18 09:26:21,551 0 messages received 2023-07-18 09:27:21,738 0 messages received 2023-07-18 09:28:22,056 0 messages received 2023-07-18 09:29:22,254 0 messages received ... 2023-07-18 09:59:23,375 Setting vehicle handler mode for VIN XXXXX to refresh mode: periodic 2023-07-18 09:59:24,754 0 messages received 2023-07-18 10:00:24,937 0 messages received

tosate commented 1 year ago

Every minute the messages are queried to detect the motor start message. This is essential to know when to start the status polling. These messages are probably stored on the SAIC server to provide the information to the iSMART app. Retrieving the messages does not drain the battery.

With version 0.3.0 the message polling will be deactivated when the refresh mode is set to the value off.

michpas commented 1 year ago

Ah. So if I understand correctly When the car starts, the car sends an updated message to the SAIC Server. And the only thing you do is query the SAIC Server; which will just give us cached data.

As a suggestion: Do you know if the car does the same when starting charging? Eg. let the SAIC server know? If so, would it be possible to pull the status of the car, let say every 5 minutes; this untill the charging stops? Eg. an 'Active_Charging' refreh count. This information helps to monitor how far the car has charged.; Easy for phone notification and knowing when there is enough chrgre in the car.

nanomad commented 1 year ago

Unfortunately there's no such message. The next version has some improvements in that area and there's at least one more strategy that can be implemented (https://github.com/SAIC-iSmart-API/saic-python-mqtt-gateway/issues/41)

tosate commented 1 year ago

Ah. So if I understand correctly When the car starts, the car sends an updated message to the SAIC Server. And the only thing you do is query the SAIC Server; which will just give us cached data.

No, that's not correct. The car sends the notification about the motor start to the server. No additional data. When we query the vehicle- or charging-status, we directly communicate with the car. There is no data caching on the server involved as far as I know. The first approach was to request the data from the car every 5 minutes or so. But this quickly drains the battery because the car needs to boot-up the system every time from a hibernate mode. Whenever the high-voltage battery is active, it is save to request the status. To save the 12V battery, we need to rely on other strategies. The motor start notification helps a lot. For charging we need apply heuristic methods.

As @nanomad already mentioned, there is no start charging notification. This would facilitate our job a lot .

michpas commented 1 year ago

Thanks. Helpful. To track load/charging status I am now experimenting with the following:

A solution to track charging @ home.

This should work in giving me 5 mins increments. I'll update how this goes.

nanomad commented 1 year ago

Thanks. Helpful. To track load/charging status I am now experimenting with the following:

  • In addition, I'll check every 5 mins this MQTT SAIC-charging mode and do a force a update whilst so

There's no need to force update. Once it's charging the gateway should switch into a fast polling mode by itself (every 30s)

cybersmart-eu commented 1 year ago

Hi, just implemented the docker container and it is awsome. Just need to understand the challange here with charging. When plugging the car to a charger with motor off and >30 seconds passed the gateway will not recognize the new (sharging" status as polling every 30 seconds stops to protect the 12V battery from discharge, correct? But when the gateway knows the "charging" status the polling interval is the same as for motor running (30 seconds) as the 12V battery will not drain while charing (although motor is off / high voltage battery not running)?

So @home I could trigger a force when I know that charging started and then the gateway will deliver data every 30 seconds during charging, correct? When remote this will fail unless I manage to start charging within 30 seconds after motor switched off.

Are those assumptions correct?

Thx,

CyberSmart

nanomad commented 1 year ago

The upcoming release will work as follows:

  1. Car driving: 30s polling as the 12V battery is protected by the HV battery
  2. After the car switches off it checks every 2 minutes for the next 10 minutes to see if the HV battery is on or the car starts charging
  3. If the car is charging or HV battery on (e.g. AC running) then it switches back to 30s polling
  4. Otherwise it switches to 1 poll/day until it gets the notification that the car is being driven
cybersmart-eu commented 1 year ago

Just found the info in 0.3.0rc1 - great news. I am very new to docker, py etc. so need to wait for the docker image to be released for 0.3.0 then - can't wait to test it.

I will integrate API data from the car with my home KNX system and also influxDB. Just thinking about different use-cases now. Greetings from Munich.