-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HyundaiBlueLinkAPIUSA Vehicle.daily_stats NOT consistent with the other region implementations #617
Comments
Relevant debug.py output for KiaUvoApiEU.py.get_driving_info responseAlltime
get_driving_info response30d for DailyStats
get_trip_info response for MonthTripInfo
get_trip_info Request for DayTripInfo
|
Relevant debug.py output for HyundaiBlueLinkAPIUSA.pyGET /ac/v2/ts/alerts/maintenance/evTripDetails
You see that the trip info is available in the output and that the daily_stats is NOT cumulative. Also it is a getter, so I do not know if it is possible to asks for months/days/tripinfo in the past? |
@DanielRussell You made the changes for daily_stats in HyundaiBlueLinkAPIUSA.py. Do you know if it is possible to ask for trip info for a specific day in the Hyundai App? And if yes, what API is called with which parameters? |
I took a look at the extract from the HyundaiBlueLinkAPIUSA.py output of debug.py that you posted above. It contains an entry for each of the four trips I took on 21Aug. Yesterday morning, I took over 6 trips. When I ran debug.py today, the output contained an entry for only the four most-recent trips. There were no entries for any of the earlier trips I took yesterday. |
@gyveri Yes, mail me the debug.py output, maybe I see different things. Can you also post here a screenshot of the USA Hyundai Bluelink App for the trip report? That gives me some insight how the Hyundai App is organized, like I did here. So there is no calendar or month statistics or something similar in the USA Hyundai Bluelink App? I also do not see the trip info in this overview of USA Hyundai Bluelink App. Otherwise the difference in daily_stats is really different than in the other Regions, like Europe. However, hyundai_kia_connect_monitor stores the daily_stats data in csv files, so has history. So could for region USA compute the cumulative data. But that means a specialized treating of the daily_stats data. |
I've sent you the debug results file and screenshots you requested. |
@gyveri Thanks for the debug.py output and screenshots. Indeed it looks like only the last 4 recent trips can be shown and retrieved. And you are right that with hyundai_kia_connect_monitor you can miss trips, if you do more than 4 trips before you ask for the latest trip values. But it is better than nothing ;-) I was also wondering why GET /ac/v2/ts/alerts/maintenance/evTripDetails is called twice in debug.output. I have to look into more detail in HyundaiBlueLinkAPIUSA.py why this is the case. Indeed hyundai_kia_connect_monitor knows the region, so can handle the daily_stats data differently.
Maybe I should start with 2. to have the daily_stats functionality handled correctly and then 1???? |
My two cents is that if corrective logic is needed for the region if possible I would love to see it added here to the API. That way it normalizes the data between regions for others who consume this. |
@cdnninja Yes, I want the API to be the same. However, there is a difference I cannot solve. The Vehicle.daily_stats is cumulative per day (one entry per day) for the other regions. Region USA it can have several entries for the same day, not cumulative (so the data is actually per trip). Also the max number of daily_stats entries is 4, whereas for the other regions it can be 30 days. Computing the cumulative for USA is not possible, because when there are more trips than 4 on one day, then the cumulative data cannot be computed. So the idea is for USA to just have the daily_stats data as is now, without the cumulative part. I think I can make the trip data consistent with the other regions, as far as I could see the necessary data is available, although also only for the last 4 trips..... |
"Computing the cumulative for USA is not possible, because when there are more trips than 4 on one day, then the cumulative data cannot be computed." |
I'll try to take a look at this in the next few days. I wrote two simple scripts to solve this use case for myself:
I'll use SQL to query the data, roll up stats, etc. I don't look at the data very often, so I haven't bothered trying to import into a spreadsheet or make a Web UI. I'm happy to share if there's interest. |
Yes, in hyundai_kia_connect_monitor this is possible, but I answered the question of @cdnninja if it was possible to solve at hyundai_kia_connect_api, but there is no history possible (hyundai_kia_connect_api is stateless). So the only way to solve the cumulative part is at the client of the hyundai_kia_connect_api. I do not think adding state to hyundai_kia_connect_api is the way to go. |
@DanielRussell This functionality is available in hyundai_kia_connect_monitor, but need to do something special for HyundaiBlueLinkAPIUSA.py to compute the cumulative data with the available history in hyundai_kia_connect_monitor. |
"Computing the cumulative for USA is not possible, because when there are more trips than 4 on one day, then the cumulative data cannot be computed." |
I took a further look at the way data is added to monitor.dailystats.csv. As noted above, data for the 4 most-recent trips is added to monitor.dailystats.csv on every update, e.g., every hour. This continues until data for a different date is received. This resets all four data slots and stores the new data. Of course, if the new data covers more than 4 trips, only data for the most-recent 4 trips is stored. The new data (for 1, 2, 3 or 4 trips) then repeats on every update unless data for one or more (n) new trips is received, in which case, data for the n oldest trips is removed and the new data is appended to the surviving older data. |
@gyveri I have a patch which will fix the miles in monitor.dailystats.csv (fix in hyundai_kia_connect_api) and also fixes the multiple adding of entries to monitor.dailystats.csv in monitor.py (I hope, please test). I updated dailystats.py to compute the cumulative day values from monitor.dailystats.csv for region USA. Best is to start with an empty monitor.dailystats.csv. Just copy the files in the zip over the existing files....... Note that if this all works, the next step would be to add support for the trip info in hyundai_kia_connect_api for HyundaiBlueLinkAPIUSA.py |
Done. |
copy of monitor.dailystats.csv attached. Timestamps are weird, as it's 11:05 as I write this. First run of the script would have been at 10:00, second run at 11:00. Car has been in garage, key off, all day today. Departing on trips soon. Will send u an update when I get home in about 4 hours. |
I've attached the version of monitor.dailystats.csv saved at 16:00 PDT. |
Ok, so it seems to work. The date/time in monitor.dailystats.csv is only meant for avoiding adding duplicate entries, actually the other regions do NOT fill a time in Vehicle.daily_stats and the csv file does contain then the time when the data was added by monitor.py. HyundaiBlueLinkAPIUSA.py does indeed fill startdate (I did not change that). This does also make sense, I think, because what happens when you start a trip before midnight and end after midnight? The associated trip data is from before midnight I expect? The call "GET /ac/v2/ts/alerts/maintenance/evTripDetails" gives startDate and duration (like other regions for tripdata). So I think it is more consistent how it is now and the trips are put on the day where it started. If you agree, I can make a pull request for the fix of miles instead of km in hyundai_kia_connect_api and the changes for hyundai_kia_connect_monitor. Thereafter I can implement the trip data for HyundaiBlueLinkAPIUSA.py |
Yes, your modifications appear to work. Thank you for doing this. And the additional rows in today's monitor.dailystats.csv contain only the data for the 4 trips I took this morning (no hangovers of yesterday's data).
|
@gyveri For 1. I see the distance-data is integer, not as float, in your debug.py output and also in my debug.py output for region Europe. Extract of one of your debug.py output (distance is always a whole number):
For 2. I still do not know how the board computer consumption matches the computed one. I introduced a setting "include_regenerate_in_consumption = False" in monitor.cfg. You can set this to True. However, I think this is also not the way to compute the consumption figures. I had good results with long trips, but short trips are really off. And it does not help that the Bluelink server only returns the distance as integer, so especially for small trips there can be a huge difference.....So only long trips should be compared for checking the consumption. I am starting to think the consumption figure in the boardcomputer is corrected with an efficiency number, like 1 kWh energy gives 0.9 kWh real energy (losses of converting battery kWh by the car). So I am thinking of introducing an efficiency configuration factor in hyundai_kia_connect_monitor, e.g. 0.9. So 10% of the energy is lost in conversion and is used in consumption calculation. |
Sorry - I identified the wrong parameter. Yes, the distance is an integer, but each block of evTripDetails also includes an odometer value that is type float. Wouldn't computing the trip distance from the odometer values in consecutive blocks of evTripDetails give a more useful result than using the pre-computed integer trip distance, especially for short trips? I agree that regeneration should not be included in the consumption calculation provided that the consumption calculation uses the total_consumption. However, I think that at least one of the other consumption values (engine, climate, electronics, battery care) is incorrect because the sum of these values should equal the sum of total consumption and regeneration, and not total consumption alone. The regeneration energy doesn't just disappear. |
Yeah, the USA server returns a combination of day stats and trip info. However, for the daily_stats for the other regions, no odometer is returned. I do not want to deviate in the hyundai_kia_connect_api for the interface, so you have to do with the distance, like the other regions, especially, because the history of daily stats is not always available in hyundai_kia_connect_api for USA, so also there the distance should not be computed, but just taken over, with, unfortunately no decimal point. I do not have a good clue about the consumption calculation in respect how the regen fits in. However, looking at my data, it seems that the reported consumption of the boardcomputer is about 10% less than the calculations. |
The revised scripts you sent me on 28 August have now been running for over a week. The revised scripts appear to have addressed the issues caused by the differences between KiaUvoApiEU and HyundaiBlueLinkAPIUSA. |
@gyveri The dailystats.py spreadsheet is for showing the dailystats and trip information received from the server. And I also show some information from summary.py, when there is dailystats data. The amount of charge received per day can be seen in summary.py spreadsheet, including current SOC%. Did you not configure/generate the summary.py spreadsheet? |
@gyveri I also made an attempt to also fill vehicle.month_trip_info and vehicle.day_trip_info, instead of only vehicle.daily_stats for HyundaiBlueLinkAPIUSA.py. Can you try out the patch? If you regularly call monitor.py it should fill the trips over time, beside the daily stats. Note that I used a trick to avoid calling GET /ac/v2/ts/alerts/maintenance/evTripDetails each time, by storing the state in vehicle.data["filled_trips"]. |
I have installed the revised HyundaiBlueLinkAPIUSA. I'll let you know the results later in the day. monitor.py runs hourly during the day. |
@gyveri Currently I loop over the monitor.dailystats.csv data and search some data from the other csv files. For me it seems not logical to display all empty day data with no trips, just to show only the charge info in dailystats spreadsheet. Besides that, implementing this is not easy. So for the charge info you have to look at the summary spreadsheet...... |
Back from taking 4 trips. Where might I find files named vehicle.month_trip_info, vehicle.day_trip_info, and vehicle.daily_stats? I've been unable to find files with these names in my hyundai_kia_connect_monitor folder. |
That are not the files, but the variables inside Vehicle.py which monitor.py uses, monitor.py calls method VehicleManager.update_month_trip_info() and VehicleManager.update_day_trip_info() and thereafter writes new trip data to monitor.tripinfo.csv. This csv file is read by dailystats.py and the trips should appear in the dailystats spreadsheet (if all works). Note that when you run debug.py on a day when there are trips made, it should also show trip information from that day in the output (if it works). |
Many thanks for the explanation. |
@gyveri That is really strange, because the dailystats spreadsheet does use the trip information inside monitor.tripinfo.csv. So if the trip information is not in there, it would not show this information in the dailystats spreadsheet. Can you post a screenshot of the dailystats spreadsheet? Note that I received the email with title "debug.py results 20240907", but there was no attachment in it? |
Thanks for the testing and debug.py output. In the latest debug.py output I see that the vehicle._month_trip_info is filled, but vehicle_day_trip_info not. So apparently I have done something wrong in the patch. I have to look carefully at the provided patch again, to see where I did something wrong with the programming....especially because I cannot test. Note that in the dailystats spreadsheet some cumulative trip data is shown, but NOT all the trips per day, because of the problem above. |
@gyveri I looked at the code and could not find the problem. I added debug statements, so if you can run debug.py again on the same day you did some trips and mail me the output logging? Maybe that gives me a clue.....just overwrite the two files in the zip. |
@gyveri I did receive the debug.py output and mailed you back. This is what I mailed. Hmmm, the day results are now filled:
Question is if monitor.tripinfo.csv is now filled or not? If yes, are those 3 trips showing in the dailystats spreadsheet? If still no trips appear, can you run monitor.py on a day with trips with debug output via the command:
And mail me the standard output and error output? Thanks, |
This morning, I deleted the only-headings monitor.tripinfo.csv and went for a short (but >1 mile) drive. Now monitor.tripinfo.csv has info for the trips I took Friday afternoon, yesterday and today. |
Ah, good to hear that it is now working and monitor.tripinfo.csv is now containing the trips. So apparently the monitor.tripinfo.csv must be empty before adding the first trip. Actually this is a small problem in monitor.py, but this is only a rare case, when tripinfo was not working the first time the header was added to monitor.tripinfo.csv. Strange that the hyundai-kia-connect-monitor spreadsheet was not updated. Is the standard output and error output (in run_monitor_once.summary.log) also not up-to-date? Sometimes, in Android, you have to refresh the whole spreadsheet, because there are to many updates. But it can also be that something else. Can you have a look into the redirected output:
|
Description
Region Europe was the first one (by me) implementing Vehicle._daily_stats, Vehicle.month_trip_info and Vehicle.day_trip_info.
Later on, also implementations followed for region Australia and China. Also HyundaiBlueLinkAPIUSA has partly implemented Vehicle.daily_stats, however the implementation is NOT consistent with the other region implementations.
The Bluelink API is very different for HyundaiBlueLinkAPIUSA, see also this discussion in hyundai_kia_connect_monitor.
What I Did
See next posts for the API for getting daily_stats, month_trip_info, Vehicle.day_trip_info from the debug.py output.
The text was updated successfully, but these errors were encountered: