Giter Club home page Giter Club logo

mymazda-relay's Introduction

Mazda Connected Service Relay

Mazda Connected Service API wrapper based on pymazda and Flask.

Deployment

Docker can be used to deploy the project locally, simply do docker-compose up -d.

This installs the requirements and launchs the flask server behind a gunicorn reverse proxy running on port 5001 in a docker container.

Usage

Make POST calls to https://mymazda.herokuapp.com/{endpoint}, where endpoint could be something like startEngine. To make a valid request, you will need to attach a JSON payload with the following fields:

{
  "username": your_mazda_email,
  "password": your_mazda_password,
  "vid": internal_vehicle_id,
  "region": your_region
}
  • vid: To obtain the vid for your vehicle, you can first make a POST call to https://mymazda.herokuapp.com/vehicles with just the username and password as the JSON payload. After getting a list of vehicles, find id associated with it. It will be the vid of your future API requests.
  • region: If you are living in the US, you can omit this field or fill in MNAO. Otherwise, it should be MME for EU, and MJO for Japan.

Below are some examples of API usage. To see a full list of API endpoints, see app.py.

Example: Start / Stop Engine

POST the above JSON to https://mymazda.herokuapp.com/startEngine or https://mymazda.herokuapp.com/stopEngine to start / stop the engine.

Example: Send navigation destination to infortainment

Send the following JSON to https://mymazda.herokuapp.com/sendPOI. Note that you need the navigation SD card for it to work.

{
  "username": your_mazda_email,
  "password": your_mazda_password,
  "vid": internal_vehicle_id,
  "longitude": longitude_float,
  "latitude": latitude_float,
  "name": name
}

iOS Shortcuts Example

mymazda-relay's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

mymazda-relay's Issues

Error getting server response

Hi,

I'm getting this very strange error in my forked Heroku instance. Functions like start the engine works fine but the return value causes a 500 error. I tried deploying the same code on my local machine but it doesn't give any error.

Any ideas?

Thank you

2022-01-23T05:27:08.823853+00:00 heroku[router]: at=info method=POST path="/vehiclesStatus" host=mazda-xxx.herokuapp.com request_id=d55bdac6-4930-4b49-ba60-06ab7273ea26 fwd="76.121.172.145" dyno=web.1 connect=0ms service=79ms status=500 bytes=463 protocol=https
2022-01-23T05:27:08.821795+00:00 app[web.1]: [2022-01-23 05:27:08,821] ERROR in app: Exception on /vehiclesStatus [POST]
2022-01-23T05:27:08.821800+00:00 app[web.1]: Traceback (most recent call last):
2022-01-23T05:27:08.821801+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/flask/app.py", line 2073, in wsgi_app
2022-01-23T05:27:08.821801+00:00 app[web.1]:     response = self.full_dispatch_request()
2022-01-23T05:27:08.821809+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/flask/app.py", line 1518, in full_dispatch_request
2022-01-23T05:27:08.821810+00:00 app[web.1]:     rv = self.handle_user_exception(e)
2022-01-23T05:27:08.821810+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/flask/app.py", line 1516, in full_dispatch_request
2022-01-23T05:27:08.821810+00:00 app[web.1]:     rv = self.dispatch_request()
2022-01-23T05:27:08.821811+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/flask/app.py", line 1502, in dispatch_request
2022-01-23T05:27:08.821811+00:00 app[web.1]:     return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
2022-01-23T05:27:08.821812+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/asgiref/sync.py", line 204, in __call__
2022-01-23T05:27:08.821813+00:00 app[web.1]:     return call_result.result()
2022-01-23T05:27:08.821813+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.9/concurrent/futures/_base.py", line 439, in result
2022-01-23T05:27:08.821813+00:00 app[web.1]:     return self.__get_result()
2022-01-23T05:27:08.821814+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.9/concurrent/futures/_base.py", line 391, in __get_result
2022-01-23T05:27:08.821814+00:00 app[web.1]:     raise self._exception
2022-01-23T05:27:08.821814+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/asgiref/sync.py", line 270, in main_wrap
2022-01-23T05:27:08.821815+00:00 app[web.1]:     result = await self.awaitable(*args, **kwargs)
2022-01-23T05:27:08.821815+00:00 app[web.1]:   File "/app/app.py", line 44, in getStatus
2022-01-23T05:27:08.821816+00:00 app[web.1]:     status = await client.get_vehicle_status(vid)
2022-01-23T05:27:08.821816+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/pymazda/client.py", line 65, in get_vehicle_status
2022-01-23T05:27:08.821816+00:00 app[web.1]:     vehicle_status_response = await self.controller.get_vehicle_status(vehicle_id)
2022-01-23T05:27:08.821817+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/pymazda/controller.py", line 31, in get_vehicle_status
2022-01-23T05:27:08.821817+00:00 app[web.1]:     response = await self.connection.api_request("POST", "remoteServices/getVehicleStatus/v4", body_dict=post_body, needs_keys=True, needs_auth=True)
2022-01-23T05:27:08.821818+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/pymazda/connection.py", line 158, in api_request
2022-01-23T05:27:08.821818+00:00 app[web.1]:     return await self.__api_request_retry(method, uri, query_dict, body_dict, needs_keys, needs_auth, num_retries=0)
2022-01-23T05:27:08.821819+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/pymazda/connection.py", line 165, in __api_request_retry
2022-01-23T05:27:08.821819+00:00 app[web.1]:     await self.__ensure_keys_present()
2022-01-23T05:27:08.821819+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/pymazda/connection.py", line 253, in __ensure_keys_present
2022-01-23T05:27:08.821820+00:00 app[web.1]:     await self.__retrieve_keys()
2022-01-23T05:27:08.821820+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/pymazda/connection.py", line 268, in __retrieve_keys
2022-01-23T05:27:08.821820+00:00 app[web.1]:     response = await self.api_request("POST", "service/checkVersion", needs_keys=False, needs_auth=False)
2022-01-23T05:27:08.821820+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/pymazda/connection.py", line 158, in api_request
2022-01-23T05:27:08.821820+00:00 app[web.1]:     return await self.__api_request_retry(method, uri, query_dict, body_dict, needs_keys, needs_auth, num_retries=0)
2022-01-23T05:27:08.821821+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/pymazda/connection.py", line 173, in __api_request_retry
2022-01-23T05:27:08.821822+00:00 app[web.1]:     return await self.__send_api_request(method, uri, query_dict, body_dict, needs_keys, needs_auth)
2022-01-23T05:27:08.821822+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/pymazda/connection.py", line 229, in __send_api_request
2022-01-23T05:27:08.821822+00:00 app[web.1]:     response_json = await response.json()
2022-01-23T05:27:08.821822+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 1103, in json
2022-01-23T05:27:08.821823+00:00 app[web.1]:     raise ContentTypeError(
2022-01-23T05:27:08.821824+00:00 app[web.1]: aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html', url=URL('https://0cxo7m58.mazda.com/prod/service/checkVersion')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.