ElectricMotorcycleForum.com

  • November 25, 2024, 05:42:29 PM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

Electric Motorcycle Forum is live!

Pages: 1 [2] 3 4 ... 8

Author Topic: SR/F App (NextGen) - API  (Read 10825 times)

Hans2183

  • Sr. Member
  • ****
  • Posts: 468
    • View Profile
Re: SR/F App (NextGen) - API
« Reply #15 on: November 05, 2019, 04:24:59 AM »

Also found one more commands

Code: [Select]
get_userinfo
With response mostly blank for my account

Code: [Select]
[{"fullname":"my-email","phone":"","email":"my-email","country":"","utcdifference":0,"timezone":"","language":"en","speedunits":0,"distanceunits":0,"dateformat":0,"timeformat":0,"allowstatus":0,"allowcommands":false,"allowstop":0,"allowlogic":0,"allowclearfleet":0,"template":"Starcom Online","maptype":0,"allowhistoryreport":1,"addunitsbycode":0,"logourl":"https:\/\/mongol.brono.com\/mongol\/fiona\/templates\/logo_starcom.gif","logotag":"1"}]
Code: [Select]
get_commands
Is also a valid one but returns an empty set for my account. I know it's valid since others get clearly marked with an error like

Code: [Select]
{"error":"602 Command unknown (get_state)"}
« Last Edit: November 05, 2019, 04:35:52 AM by Hans2183 »
Logged
2021 Energica SS9+ 21.5kWh
--- Belgium ---

BrianTRice@gmail.com

  • Unofficial Zero Manual Editor
  • Hero Member
  • *****
  • Posts: 4014
  • Nerdy Adventurer
    • View Profile
    • Personal site
Re: SR/F App (NextGen) - API
« Reply #16 on: November 05, 2019, 01:35:47 PM »

The version in the repo now has fingerprint configured to safely store that password. Still plain text over the network though... not my fault, thats the API.

Have you tried performing a POST with parameters as form data? There’s also GET with form data, which browsers won’t do but is valid.
Logged
Current: 2020 DSR, 2012 Suzuki V-Strom
Former: 2016 DSR, 2013 DS

stevenh

  • Sr. Member
  • ****
  • Posts: 398
  • Newington NH
    • View Profile
Re: SR/F App (NextGen) - API
« Reply #17 on: November 05, 2019, 09:06:32 PM »

Nice Find on the API Settings :

These are the values i get with my bike (some numbers altered for obvious reasons)

[
{"unitnumber":"123456",
"name":"538ZFAZ76LCK00000",
"unittype":"5",
"unitmodel":"6",
"mileage":"4382.46",
"software_version":"190430",
"logic_state":"2"
,"reason":"2",
"response":"0",
"driver":"0",
"longitude":"4.5000",
"latitude":"51.5000",
"altitude":"0",
"gps_valid":"0",
"gps_connected":"1",
"satellites":"0",
"velocity":"1",
"heading":"344",
"emergency":"0",
"shock":"",
"ignition":"0",
"door":"0",
"hood":"0",
"volume":"0",
"water_temp":"",
"oil_pressure":"0",
"main_voltage":13.08,
"analog1":"0.09",
"siren":"0",
"lock":"0",
"int_lights":"0",
"datetime_utc":"20191030162309",
"datetime_actual":"20191102113548"
,"address":"YourCity, YourStreet",
"perimeter":"",
"color":2,
"soc":91,
"tipover":0,
"charging":1,
"chargecomplete":0,
"pluggedin":1,
"chargingtimeleft":0}
]

So I guess this info could be used to wite either an app or a webpage where this info is presented in a more clear way. I'm ok with arduino programming but website and Json is not my expertise.
Maybe someone could have a quick go at this and write some (HTML???) code so everyone can enter their data (unitnumber, username and password) and get all the data from the API.

By the way. The Api calls the starcomsystems.com website and if you go to home and then products and then the page for vehicle tracking you see the following page  :

https://www.starcomsystems.com/helios/

And the Helios TT or advanced device looks a lot like the device that I saw when i had my tank plastics off. It is mounted just behind the ignition key on top of the DCDC converter and has the same rubber cover as shown on the webpage. On the attached picture you can just about spot it.The picture is from when i had my rapid charger installed (seperate topic)

Interesting that my mileage does not match the mileage value returned by the call.  Not sure what's up there.  Does your's match?  Clearly a data set from a standard vehicle package (door, oil pressure :))...

My actual mileage is a little over 4K, and the request returned 5856.51.

Steve
Logged
2020 SR/F Premium
2022 Ioniq 5 SEL

remmie

  • Sr. Member
  • ****
  • Posts: 318
    • View Profile
Re: SR/F App (NextGen) - API
« Reply #18 on: November 05, 2019, 09:14:58 PM »

I think it is not the bike mileage but the ‘mileage’ of the gps unit.

Did you (or the dealer) transport the bike on a trailer to get it home?
Logged
Current : Red Premium Zero SR/F (ordered May 25, delivered August 23 2019) with Rapid charger for 12kW charging
Former : White Zero SR 2018 ZF14.4 kWh (17.500 km)
Former : Black Zero SR 2014 ZF11.4 kWh (25.000 km)
SR's outfitted with Homemade "Supercharger" 6x eltek Flatpack S (12 kW)

stevenh

  • Sr. Member
  • ****
  • Posts: 398
  • Newington NH
    • View Profile
Re: SR/F App (NextGen) - API
« Reply #19 on: November 05, 2019, 09:29:31 PM »

I think it is not the bike mileage but the ‘mileage’ of the gps unit.

Did you (or the dealer) transport the bike on a trailer to get it home?

I did not, but it was a demo bike, so it may have moved around a bit.  1800 miles is a bit of travel though!

Steve
Logged
2020 SR/F Premium
2022 Ioniq 5 SEL

remmie

  • Sr. Member
  • ****
  • Posts: 318
    • View Profile
Re: SR/F App (NextGen) - API
« Reply #20 on: November 05, 2019, 11:22:22 PM »

The version in the repo now has fingerprint configured to safely store that password. Still plain text over the network though... not my fault, thats the API.

Btw @remmie you're right about the helios resemblance, check this pdf https://www.starcomsystems.com/wp-content/uploads/2019/05/The-Worlds-First-Connected-Motorcycle.pdf

some more info from starcom systems and their Helios GPS tracker on the SR/F on their blog

https://www.starcomsystems.com/2019/03/28/the-first-smart-connected-motorcycle-effortless-connection/

this was posted back in March, I haven't seen it before.

Logged
Current : Red Premium Zero SR/F (ordered May 25, delivered August 23 2019) with Rapid charger for 12kW charging
Former : White Zero SR 2018 ZF14.4 kWh (17.500 km)
Former : Black Zero SR 2014 ZF11.4 kWh (25.000 km)
SR's outfitted with Homemade "Supercharger" 6x eltek Flatpack S (12 kW)

gadgetgirl

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
Re: SR/F App (NextGen) - API
« Reply #21 on: November 06, 2019, 01:03:28 AM »

It sounds like a fun side project to write a web app for this API. Every attempt I've made to hit those endpoints results in {"error":"601 Unauthorized user (MYUSER)"}, even though I'm able to use the NextGen app just fine (and I have the right password, since it came from my password manager). I'm hesitant to log out of the app to see if my account is borked somewhere, in case it won't let me back in, but I'll suck it up and try it soon. What I'd really like to attempt is to aggregate the data from the Helios tracker with a makeshift sentry mode (cameras, raspberry pi, something), like Tesla offers.
Logged
Current: 2020 SR/F Premium Seabright Blue (J1772)
Former: 2011 VRSCDX Sedona Orange

Hans2183

  • Sr. Member
  • ****
  • Posts: 468
    • View Profile
Re: SR/F App (NextGen) - API
« Reply #22 on: November 06, 2019, 01:39:42 AM »

If you have Android you can try with this implementation https://play.google.com/store/apps/details?id=be.hcpl.android.zeronextgen

Edit: For me mileage is close to actual mileage on the bike. Bike has around 4400 km, API shows around 200km less. I noticed once that the SoC was returning 0% while parked indoors. Not sure why, actual charge was 95%.

This is while not charging but plugged in with soc at 21%


This is while charging


I'll start on the iOS app first and then get back to this to get some data logging working.
« Last Edit: November 06, 2019, 03:03:57 AM by Hans2183 »
Logged
2021 Energica SS9+ 21.5kWh
--- Belgium ---

Hans2183

  • Sr. Member
  • ****
  • Posts: 468
    • View Profile
Re: SR/F App (NextGen) - API
« Reply #23 on: November 06, 2019, 03:08:23 PM »

Found another command `get_history` but requires some more input (like start date) that I can't find the right format/parametername for.

From the zero nextgen app itself this is how the data is stored in a table with this structure

Code: [Select]
supportSQLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS `RideData` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `odometer` INTEGER NOT NULL, `totalEnergyUsed` INTEGER NOT NULL, `averageEfficiency` INTEGER NOT NULL, `speed` INTEGER NOT NULL, `leanAngle` INTEGER NOT NULL, `power` INTEGER NOT NULL, `torque` INTEGER NOT NULL, `coastRegen` INTEGER NOT NULL, `brakeRegen` INTEGER NOT NULL, `longitude` REAL NOT NULL, `latitude` REAL NOT NULL, `stateOfCharge` INTEGER NOT NULL, `timestamp` INTEGER NOT NULL)");
                supportSQLiteDatabase.execSQL(RoomMasterTable.CREATE_QUERY);
                supportSQLiteDatabase.execSQL("INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"2b8213d2b0f5caa844e59ff8c1081127\")");

And then several queries exist for useful data

Code: [Select]
@Query("SELECT avg(speed) FROM RideData")
    int getAverageSpeed();

    @Query("SELECT odometer FROM RideData ORDER BY timestamp DESC LIMIT 1")
    long getEndingOdometer();

    @Query("SELECT MAX(speed) FROM RideData")
    int getMaxSpeed();

    @Query("SELECT longitude, latitude FROM RideData")
    @NotNull
    List<Coordinates> getRideCoordinates();

    @Query("SELECT * FROM RideData")
    @NotNull
    List<RideData> getRideData();

    @Query("SELECT * FROM RideData ORDER BY brakeRegen ASC LIMIT 1")
    @NotNull
    RideData getRideDataWithMaxBrakeRegen();

    @Query("SELECT * FROM RideData ORDER BY coastRegen ASC LIMIT 1")
    @NotNull
    RideData getRideDataWithMaxCoastRegen();

    @Query("SELECT * FROM RideData ORDER BY leanAngle ASC LIMIT 1")
    @NotNull
    RideData getRideDataWithMaxLeanAngleLeft();

    @Query("SELECT * FROM RideData ORDER BY leanAngle DESC LIMIT 1")
    @NotNull
    RideData getRideDataWithMaxLeanAngleRight();

    @Query("SELECT * FROM RideData ORDER BY power DESC LIMIT 1")
    @NotNull
    RideData getRideDataWithMaxPower();

    @Query("SELECT * FROM RideData ORDER BY speed DESC LIMIT 1")
    @NotNull
    RideData getRideDataWithMaxSpeed();

    @Query("SELECT * FROM RideData ORDER BY torque DESC LIMIT 1")
    @NotNull
    RideData getRideDataWithMaxTorque();

    @Query("SELECT odometer FROM RideData ORDER BY timestamp ASC LIMIT 1")
    long getStartingOdometer();

    @Query("SELECT SUM(brakeRegen) FROM RideData")
    int getTotalBrakeRegen();

    @Query("SELECT SUM(coastRegen) FROM RideData")
    int getTotalCoastRegen();

    @Insert(onConflict = 1)
    void insertRideData(@NotNull RideData rideData);

    @Insert(onConflict = 1)
    void insertRideDataList(@NotNull List<RideData> list);

    @Query("DELETE FROM RideData")
    void nukeData();
Logged
2021 Energica SS9+ 21.5kWh
--- Belgium ---

remmie

  • Sr. Member
  • ****
  • Posts: 318
    • View Profile
Re: SR/F App (NextGen) - API
« Reply #24 on: November 06, 2019, 04:09:34 PM »

Wow!! Excellent progress. Looks very very nice.
Logged
Current : Red Premium Zero SR/F (ordered May 25, delivered August 23 2019) with Rapid charger for 12kW charging
Former : White Zero SR 2018 ZF14.4 kWh (17.500 km)
Former : Black Zero SR 2014 ZF11.4 kWh (25.000 km)
SR's outfitted with Homemade "Supercharger" 6x eltek Flatpack S (12 kW)

Hans2183

  • Sr. Member
  • ****
  • Posts: 468
    • View Profile
Re: SR/F App (NextGen) - API
« Reply #25 on: November 06, 2019, 04:59:54 PM »

allright, that `get_history` command works as follow

https://mongol.brono.com/mongol/api.php?commandname=get_history&format=json&user=your_username&pass=your_password&unitnumber=your_unit&start=20190821&end=20190824

with a max of 2 days span. The data I get seems identical to that from last_transmit (only analog2 field is new)
Logged
2021 Energica SS9+ 21.5kWh
--- Belgium ---

bigmadf

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: SR/F App (NextGen) - API
« Reply #26 on: November 06, 2019, 05:32:00 PM »

Awesome work guys!
This was exactly what I wanted to trigger.
Logged
Zero SR/F Premium
Buell XB9R
Tesla Model X 100D
--Switzerland--

BrianTRice@gmail.com

  • Unofficial Zero Manual Editor
  • Hero Member
  • *****
  • Posts: 4014
  • Nerdy Adventurer
    • View Profile
    • Personal site
Re: SR/F App (NextGen) - API
« Reply #27 on: November 06, 2019, 10:08:21 PM »

It’s possible that get_history can pull earlier data with a url parameter.

This is really great progress.

I’ve heard some indication that Zero isn’t jealous of or even greedy with this data, and clearly this is about users getting more power and access to their own data, so I wouldn’t expect too much trouble.

Plus if anyone at Zero makes a stink, we have data protection laws like GDPR that now apply in the EU which provide standing in court.
Logged
Current: 2020 DSR, 2012 Suzuki V-Strom
Former: 2016 DSR, 2013 DS

stevenh

  • Sr. Member
  • ****
  • Posts: 398
  • Newington NH
    • View Profile
Re: SR/F App (NextGen) - API
« Reply #28 on: November 06, 2019, 11:22:40 PM »

It’s possible that get_history can pull earlier data with a url parameter.

This is really great progress.

I’ve heard some indication that Zero isn’t jealous of or even greedy with this data, and clearly this is about users getting more power and access to their own data, so I wouldn’t expect too much trouble.

Plus if anyone at Zero makes a stink, we have data protection laws like GDPR that now apply in the EU which provide standing in court.

Yep, it works.  I pulled all the data from before I got the bike to present and put the mileage, latitude and longitude into a CSV by date.  I was bummed to see there was no location data other than the bikes birth in california and the data since I got the bike in early July.  None of the data between those times seemed to exist.  I pulled the Lat/Long data into Google Maps, pretty cool.  Thanks for the reverse engineering!  I have a simple c# console app to query and parse data by date over a longer period of time and save it to a CSV if anyone is interested.

Steve
Logged
2020 SR/F Premium
2022 Ioniq 5 SEL

remmie

  • Sr. Member
  • ****
  • Posts: 318
    • View Profile
Re: SR/F App (NextGen) - API
« Reply #29 on: November 07, 2019, 03:58:09 AM »

Definitely interested :)

I also pulled all the logs 2 days at a atime and got about the same info as you. A few locations in california and then the next is from my dealers location.
Would have been cool to have seen the travel across the ocean (to the NL)
But they disconnect the 12V lithium battery during transport so that means also no location updates during that time.

Very cool to see all the locations where the bike has been. I use GPS visualiser to generate maps from the csv data. (see attached)
Also elevation profiles can be made with this piece of SW
Logged
Current : Red Premium Zero SR/F (ordered May 25, delivered August 23 2019) with Rapid charger for 12kW charging
Former : White Zero SR 2018 ZF14.4 kWh (17.500 km)
Former : Black Zero SR 2014 ZF11.4 kWh (25.000 km)
SR's outfitted with Homemade "Supercharger" 6x eltek Flatpack S (12 kW)
Pages: 1 [2] 3 4 ... 8