I have the requests, and I verified that I could authenticate, retrieve information about my cars and the modules installed in them, and execute commands to lock, unlock, open the trunk, remote start, etc. The thing is, I really suck at Python (having never used it before), and I’m not sure exactly how to codify the authentication flow, as you authenticate through AWS Cognito, then use the returned token in a request to another URL to get information about the system, and then use that same token and device ID from the previous request to issue HTTP POST calls to trigger actions on another URL.
The basic idea is to send a POST request to https://cognito-idp.us-east-1.amazonaws.com/ with these headers:
and this body:
In the response, you will get an Access Token, an ID Token, and a Refresh Token. Use the ID Token in subsequent requests.
Make a GET Request to https://api.dronemobile.com/api/v1/user to get User Information, or a GET request to https://api.dronemobile.com/api/v1/vehicle?limit=100 to get vehicle information. On both requests, you need to add a bearer token to the header of the request. This token will be the ID token you received previously.
In the vehicle request, you will need to get the device key of the vehicle you want to interface with. You will this for the next calls.
Finally, make a POST request to https://accounts.dronemobile.com/api/iot/send-command In the header, you need to add “x-drone-api” as a key and your ID Token as the value.
Also, add a body to the request that looks like this (JSON):
The Device Key is the value from the previous request for vehicles. The commands that I know of are:
“trunk” - Opens the trunk
“location” - Returns Current Latitude and Longitude of the Vehicle
“remote_start” - Starts the vehicle
“remote_stop” - Stops the vehicle
“arm” - Locks/Arms alarm on vehicle
“disarm” - Unlocks/Disarms alarm on vehicle
Now, I just need help figuring out how to make this into a Home Assistant Plugin.