Access the NIU cloud via command line interface. It is based on the niu-cloud-connector.
A project originated from an article in the Elektroroller-Forum [German].
- Installation
- Show all commands and parameters
- Example
- Token
- KML output for google earth or google maps
- Filter output
- Issues, Ideas and bugs
- License
The niu-cloud-connector libray is included as git submodule. Therefore the "--recursive" option is important, because otherwise the niu-cloud-connector is not included.
$ git clone --recursive https://github.com/BlueAndi/niu-cloud-cli.git
$ cd niu-cloud-cli
$ npm install
$ node niu-cloud-cli.js --help
First create a session token with your NIU cloud account. This token is necessary for all further requests. You need your user account/password and additional your contry code, like e.g. 49 for germany.
$ node niu-cloud-cli.js create-token <account> <password> <country-code>
Get a list of your vehicles. Each vehicle has a serial number, which is necessary to get vehicle specific informations.
$ node niu-cloud-cli.js get-vehicles --token <token>
Note, a token can be stored in a file in JSON format:
{
"token": "..."
}
Use the option --tokenFile <filename>
to save (create-token command) and load (all other commands) the token.
Generate a KML file including the last known position of your NIU e-scooter with the following call:
$ node niu-cloud-cli.js get-vehicle-pos --token <token> --sn <serial-number> --kml > pos.kml
Load the generated pos.kml file in google earth or google map.
First get e.g. the last recorded track.
$ node niu-cloud-cli.js get-tracks --token <token> --sn <serial-number> --num 1
Track #1
Track id : 1558023845684dBO79fv:1
Track date : 20190516
Track start time: 2019-5-16 18:24:05
Track end time : 2019-5-16 18:38:04
Distance : 13147 m
Average speed : 57.1 km/h
Riding time : 838 min.
Start point :
Latitude : xx.xxxxxx
Longitude: xx.xxxxxx
End point :
Latitude : xx.xxxxxx
Longitude: xx.xxxxxx
There you will find the track id and the track date, which are necessay to retrieve the full detail. Now generate a KML file from a complete recorded track of your NIU e-scooter with the following call:
node niu-cloud-cli.js get-track-detail --token <token> --sn <serial-number> --trackId <track-id> --trackDate <track-date> --kml > track.kml
Load the generated track.kml file in google earth or google map and voila!
For further processing of data on the command line or via CSV, you can filter data to get a dedicated output.
First check what kind of data is available by takeing a look to the documentation or just output all data in JSON format.
node niu-cloud-cli.js get-battery-info --token <token> --sn <serial-number> --json
Next step is to filter for some data, e.g. the estimatedMileage.
node niu-cloud-cli.js get-battery-info --token <token> --sn <serial-number> --filter estimatedMileage
This will output only the estimatedMileage value! Add more filters and the output will be value by value, separated with a ";".
If you have further ideas or you found some bugs, great! Create a issue or if you are able and willing to fix it by yourself, clone the repository and create a pull request.
The whole source code is published under the MIT license.