lsiddiquee / com.rexwel.bmwconnected

GNU General Public License v3.0
2 stars 3 forks source link

Driver log #7

Closed JohanKSE closed 2 years ago

JohanKSE commented 3 years ago

Hi,

First of all, I'm so happy with this app, helps me a lot already. Currently I'm logging mileage every morning into an Google spreadsheet to keep track of the driving (using IFTTT) but I'm trying to figure out how to log every drive separately.

At first it seemed quite simple, just keep track of every time the car is locked/unlocked but I've just realised that doesn't work that good since there is a delay in the reporting from the car to the the BMW connected site (i.e. not in your app). So what can happen is that I get two unlock events before an lock event (which messes up the structure). Currently I'm trying i'm testing to use a flag that keeps track of the status of the car...but that got me thinking and I figured I would ask you: Do you know an easier way to do this (i.e. log every drive with start and stop-point, distance etc)?

And as an request for future developments: if possible it would be great if there would be a property/tag where i could get the location in a complete address rather than the Long/lat.

Again, thanks for the app!

JOhan

lsiddiquee commented 2 years ago

@JohanKSE thanks for the feedback. I might be incorporating some of this into the app in the upcoming release. Will update here once done. For the tracking, do you think if I add a start driving stop driving trigger flow it would help? This would still be relying on the BMW services which has delays, so we might miss some very short stops. However, on an overall situation it would in general work. Update: There is already an existing trigger which triggered when the app thought a driving session was completed, however, it only logged the new location, for convenience I am adding a new trigger "Drive session completed" which has both start and end location, including start and end odometer reading.

JohanKSE commented 2 years ago

Thanks for responding, I think a drive session end event would be perfect.

FYI I tried saving the start position in a variable and then log both start and stop once stopped...but due to the delay in the BMW connected site quite often there wouldn't be any difference so: Start 48501 end 48501...but when I then started the next drive it would show the correct mileage...48940 so now I only log the start and then use the next start as the previous stop...it sort of works.

Rgds/J

lsiddiquee commented 2 years ago

Previously the mileage was logged/updated after the locked flow was fired, depending upon the delay in execution you might/not get the new mileage. However, part of this change, I am currently ensuring that the mileage is updated prior to triggering lock/location_changes/drive_session_completed(new) flow triggers. Hopefully now you should be getting better and accurate info. Will update once the app is pushed to test, and hopefully you can help me test and validate the changes as well.

lsiddiquee commented 2 years ago

Just pushed a new version test. https://homey.app/nl-nl/app/com.rexwel.bmwconnected/BMW-Connected/test/

JohanKSE commented 2 years ago

Awesome, I will give this a try tomorrow and let you know how it works out.

Again, thanks!

Den sön 2 jan. 2022 kl 09:02 skrev Likhan Siddiquee < @.***>:

Just pushed a new version test. https://homey.app/nl-nl/app/com.rexwel.bmwconnected/BMW-Connected/test/

— Reply to this email directly, view it on GitHub https://github.com/lsiddiquee/com.rexwel.bmwconnected/issues/7#issuecomment-1003677922, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADMB6JNPKEXI2LEZFKXBADTUUABABANCNFSM5FXZ442Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

lsiddiquee commented 2 years ago

Please do not install the test version. seems like the retreiving login is an issue now, My app was working as soon as I reinstalled new one, login no longer works.

JohanKSE commented 2 years ago

Ohps, I was a bit to quick, I will uninstall it for now.

Attached pls find the flow I will test out.

image

lsiddiquee commented 2 years ago

pushed new update 0.0.14 auth seems to be fine and added the missing start and end km. you can also replace your custom tags with the flow tags: (Start/End)Mileage, (Start/End)Address, (Start/End)Label, (Start/End)Latitude and (Start/End)Longitude

JohanKSE commented 2 years ago

Ah thanks, will update and test tomorrow. Just one thought, although not necessary but would make it a bit easier if there was any way you also could incorporate reverse geocoding in future releases.  (ex https://developers.google.com/maps/documentation/geocoding/overview).

Will get back to you once i tried it...again great support, thanks!/J

JohanKSE commented 2 years ago

Another thought while at it....for a future release: would also be great if you could add an event when refuling (how many liters and when and where).

lsiddiquee commented 2 years ago

Reverse geocoding was already there. In this release have added that as a tag in location changed and as well as a general tag on the device. Hmm ok will most likely include refueling as well.

JohanKSE commented 2 years ago

Dear Isidddiquee,

Hi,

I think I should explain how it works here in Sweden, then I think it will be easier for you to understand the request.

First of all I drive a company car and are therefore required to keep a driver journal with certain information as: Date and time, distance, start and stop mileage, purpose (business/private/between work-home). I also need to keep track of refueling (when, where and how much).

My car is a hybrid so most of my driving to-from work will be done on battery. If I can show the actual consumtion on each trip I only have to pay tax for that part...and to be able to show that I will need to keep track of every refueling.

But this is really a deluxe-request, what you've done is already more than I can achieve with any other solution. The fueling is more of a deluxe request.

I will get back to you tomorrow after I've tested it.

JohanKSE commented 2 years ago

Good morning,

Drove to work this morning but it doesn't seem to work. Not sure if it has anything to do with your app though since when I look in the BMW Connected app the data in there is not updated (at least battery info and mileage is incorrect).

I will simplify the flow so that I will log just if the event is triggered (below you can see my current flow) and have a second flow logging some more info.

FYI I run a log at 5 o'clock every morning with all data and that went fine.

image

lsiddiquee commented 2 years ago

I cannot test yet as the old login mechanism does not work anymore for me. So trying to reverse engineer it. Once that is fixed i will be able to look further. Today is workday so need to find the next availability.

JohanKSE commented 2 years ago

No worries, I will rollback to the old version in the meantime. Let me know when you've have had a chance to look at it.

Any again; thanks :)

lsiddiquee commented 2 years ago

Just fixed it and now going for a test drive. If successfull will push out a new test version. I also added the refuelled flow trigger. I also drive a 530e, hence do not know when I will be able to test it. Hopefully you refuel more frequently than I do then you can validate that one as well. UPDATE: Just came back from the test drive the Drive session completed flow is working. The app is available at test currently, once get a few verification it is working will push to release. https://homey.app/nl-nl/app/com.rexwel.bmwconnected/BMW-Connected/test/

JohanKSE commented 2 years ago

Great, I just installed 0.16 and will test it tomorrow...will most likely fill up the car then too so added a flow for fuelling.

I'll keep my fingers crossed and let you know how it goes.

JohanKSE commented 2 years ago

A first feedback; did a quick drive down to the grocery store. It logged the first trip perfectly but for some reason it didn't react to the return drive (was in the shop for about 5 mins). Could be that I was in homey and edited but will test again tomorrow.

Have a nice evening,

lsiddiquee commented 2 years ago

I saw something very similar thought it was a glitch. Will review the code further.

lsiddiquee commented 2 years ago

FYI I still haven't analyzed the code. However i had multiple action one was to send notification to my phone another was to log in google  sheets using ifttt. I did not get all the notifications however all the actions were logged in the google sheef.

lsiddiquee commented 2 years ago

@JohanKSE please use the updated version 0.0.18 which was pushed just a while back, there was an issue with token caching.

JohanKSE commented 2 years ago

Thanks, i will update in the morning before testing again.

Mvh/Johan

Den mån 3 jan. 2022 21:22Likhan Siddiquee @.***> skrev:

@JohanKSE https://github.com/JohanKSE please use the updated version 0.0.18 which was pushed just a while back, there was an issue with token caching.

— Reply to this email directly, view it on GitHub https://github.com/lsiddiquee/com.rexwel.bmwconnected/issues/7#issuecomment-1004336668, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADMB6JPIUHFFFW4IUPVZUDDUUIARXANCNFSM5FXZ442Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

JohanKSE commented 2 years ago

Hi Lashan,

It looks really great, did a trip with 5 different stops between 2-30 min and they logged them all correctly. Will fill up the car in the afternoon and let you know after that.

JohanKSE commented 2 years ago

It works great, all trips logged and also logged when I filled up the gas.

A couple of minor issues, not really important for my usage but since I noticed them I figured I should tell you:

I got a "ghost" drive where start and stop was the same address although the mileage increased by 1 km. Also I filled up the car with 31,47 l but it seems it only reported 31 (logged with simpleLog to the timeline so it could be a limitiation within that app).

But I'm really happy how it works now, thanks a lot!!!

Should you ever need any further help with testing etc pls don't hesitate to ask me, I owe you!

lsiddiquee commented 2 years ago

No problem. Glad that i could help. And regarding the fraction missing in refueling, it is a limitation on BMW ConnectedDrive api. It does not report fraction. I guess the liter is also an approximation as the only have a tank fuel level sensor which it uses to approximate in fuel in liters. Also the ghost drive is most likely a change in minor longitude and latitude. I will close this issue then.

JohanKSE commented 2 years ago

Good morning,

Sorry to have to bother you again but it seems the DriveSessionCompleted triggers more times than one during a drive. I have a flow that logs the drive to Google spreadsheet once the event is triggered so I drove to work this morning, a drive of 48 km. At the end of the drive I dropped of my son and wife but before that I had 17 entries that really can't be explained. I didn't have to stop at any point, only shifted drive mode twice.

Altogether I had 21 entries with two stops (with engine running).

Rgds/J

lsiddiquee commented 2 years ago

@JohanKSE apologies, have been super busy, keep forgetting to respond. This might happen if your doors are locked. Currently there is default polling interval of 60 seconds, which you can change on the device's settings page. It triggers a location update and drive completed event when on a poll it sees that the door is locked. There is no better way to detect if a car is being driven or not. I might change the drive complete event to trigger on an alarm armed/however, that is also not very reliable. As you can have doors locked with alarms disabled. I do that quiet a lot, when I have my dogs in the car and the pre-conditioning is running.

JohanKSE commented 2 years ago

I know that this is a side project for you so no worries, if/when I find stuff I'll report back to you and then you can look at it when you have time. As for the door locking issue that makes perfect sense. I've set the car to lock once the car is moving. I will test to modify the flow so that it only logs if the alarm is on.

Thanks!/J

Den tors 20 jan. 2022 kl 21:05 skrev Likhan Siddiquee < @.***>:

@JohanKSE https://github.com/JohanKSE apologies, have been super busy, keep forgetting to respond. This might happen if your doors are locked. Currently there is default polling interval of 60 seconds, which you can change on the device's settings page. It triggers a location update and drive completed event when on a poll it sees that the door is locked. There is no better way to detect if a car is being driven or not. I might change the drive complete event to trigger on an alarm armed/however, that is also not very reliable. As you can have doors locked with alarms disabled. I do that quiet a lot, when I have my dogs in the car and the pre-conditioning is running.

— Reply to this email directly, view it on GitHub https://github.com/lsiddiquee/com.rexwel.bmwconnected/issues/7#issuecomment-1017875967, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADMB6JNTUE3CUHY5FCEBLR3UXBTJ5ANCNFSM5FXZ442Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

JohanKSE commented 2 years ago

Hi again,

A quick feedback; I did test today to have to parallel flows, one that only triggers DriveSession completed and one with drivesession completed and the generic alarm is off and it seems that the second one (with generic alarm) triggers only once the car stopped (but of course the start location is currently wrong ...could just ust the end data every time and then use previous drive's end data as start data :).

Message ID: <lsiddiquee/com.rexwel.bmwconnected/issues/7/1017875967@ github.com>