-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
22 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
[![GitHub Workflow Status][workflow-shield]][workflow] | ||
[![GitHub Release][releases-shield]][releases] | ||
[![GitHub Activity][commits-shield]][commits] | ||
![GitHub Workflow](https://img.shields.io/github/actions/workflow/status/DurgNomis-drol/mytoyota/build.yml) | ||
![Codecov](https://img.shields.io/codecov/c/github/DurgNomis-drol/mytoyota) | ||
![Commit activity](https://img.shields.io/github/commit-activity/y/DurgNomis-drol/mytoyota) | ||
![GitHub Release](https://img.shields.io/github/release/DurgNomis-drol/mytoyota.svg) | ||
![PyPI - Downloads](https://img.shields.io/pypi/dm/mytoyota) | ||
|
||
# Toyota Connected Services Europe Python module | ||
|
||
### [!] **This is still in beta** | ||
<b><p align=center> 🚨 Breaking changes ahead 🚨 </p></b> | ||
|
||
### [!] **Only EU is supported, other regions are not possible so far. See [this](https://github.com/widewing/toyota-na) for North America** | ||
<p align=center> Version 1.0.0 only supports the new ctpa-oneapi API endpoints that were introduced with the new MyToyota app. Some functions are not yet implemented and must first be determined due to the lack of API documentation. </p> | ||
<p align=center> Users of the old MyT app should use a mytoyota python module version < 1.0.0. </p> | ||
|
||
⚠️ _This is still in beta_ | ||
|
||
⚠️ _Only EU is supported, other regions are not possible so far. See [this](https://github.com/widewing/toyota-na) for North America_ | ||
|
||
## Description | ||
|
||
|
@@ -23,74 +30,21 @@ pip install mytoyota | |
|
||
## Usage | ||
|
||
```python | ||
import json | ||
import asyncio | ||
from mytoyota.client import MyT | ||
|
||
username = "[email protected]" | ||
password = "MyPassword" | ||
brand = "toyota" # or lexus | ||
|
||
# Get supported regions, can be passed to the optional 'region' argument of MyT | ||
# At this moment, only the 'europe' region is supported | ||
print(MyT.get_supported_regions()) | ||
|
||
client = MyT(username=username, password=password, brand=brand) | ||
|
||
async def get_information(): | ||
print("Logging in...") | ||
await client.login() | ||
|
||
print("Retrieving cars...") | ||
# Returns cars registered to your account + information about each car. | ||
cars = await client.get_vehicles() | ||
|
||
for car in cars: | ||
|
||
# Returns live data from car/last time you used it as an object. | ||
vehicle = await client.get_vehicle_status(car) | ||
|
||
# You can either get them all async (Recommended) or sync (Look further down). | ||
data = await asyncio.gather( | ||
*[ | ||
client.get_driving_statistics(vehicle.vin, interval="day"), | ||
client.get_driving_statistics(vehicle.vin, interval="isoweek"), | ||
client.get_driving_statistics(vehicle.vin), | ||
client.get_driving_statistics(vehicle.vin, interval="year"), | ||
] | ||
) | ||
|
||
# You can access odometer data like this: | ||
mileage = vehicle.dashboard.odometer | ||
# Or retrieve the energy level (electric or gasoline) | ||
fuel = vehicle.dashboard.fuel_level | ||
battery = vehicle.dashboard.battery_level | ||
# Or Parking information: | ||
latitude = vehicle.parkinglocation.latitude | ||
|
||
# Daily stats | ||
daily_stats = await client.get_driving_statistics(vehicle.vin, interval="day") | ||
|
||
# ISO 8601 week stats | ||
iso_weekly_stats = await client.get_driving_statistics(vehicle.vin, interval="isoweek") | ||
|
||
# Monthly stats is returned by default | ||
monthly_stats = await client.get_driving_statistics(vehicle.vin) | ||
|
||
# Get year to date stats. | ||
yearly_stats = await client.get_driving_statistics(vehicle.vin, interval="year") | ||
|
||
|
||
loop = asyncio.get_event_loop() | ||
loop.run_until_complete(get_information()) | ||
loop.close() | ||
For a quick start on how to use the package take a look at the `simple_client_example.py` file contained in the report. You can also use and execute this file directly by using the following commands: | ||
|
||
```bash | ||
python -m venv mytoyota | ||
source mytoyota/bin/activate | ||
python -m pip install "mytoyota @ git+https://github.com/DurgNomis-drol/mytoyota@master" | ||
curl -LO https://raw.githubusercontent.com/GitOldGrumpy/mytoyota/master/simple_client_example.py | ||
# Create a credentials.json file with {"username":"[email protected]","password":"yourpassword"} | ||
python simple_client_example.py | ||
``` | ||
|
||
## Known issues | ||
|
||
- Statistical endpoint will return `None` if no trip have been performed in the requested timeframe. This problem will often happen at the start of each week, month or year. Also daily stats will of course also be unavailable if no trip have been performed. | ||
- Currently, it is only possible to get various vehicle information. Functions for controlling and setting vehicle properties have not yet been implemented. | ||
|
||
## Docs | ||
|
||
|
@@ -100,7 +54,7 @@ Coming soon... | |
|
||
This python module uses poetry (>= 1.2.2) and pre-commit. | ||
|
||
To start contributing, fork this repository and run `poetry install`. Then create a new branch. Before making a PR, please run pre-commit `poetry run pre-commit run --all-files` and make sure that all tests passes locally first. | ||
To start contributing, fork this repository and run `poetry install`. Then create a new branch. Before making a PR, please run pre-commit `poetry run pre-commit run --all-files` and make sure that all tests passes locally first by running `pytest tests/`. | ||
|
||
## Note | ||
|
||
|
@@ -109,10 +63,3 @@ As I [@DurgNomis-drol](https://github.com/DurgNomis-drol) am not a professional | |
## Credits | ||
|
||
A huge thanks go to [@calmjm](https://github.com/calmjm) for making [tojota](https://github.com/calmjm/tojota). | ||
|
||
[releases-shield]: https://img.shields.io/github/release/DurgNomis-drol/mytoyota.svg?style=for-the-badge | ||
[releases]: https://github.com/DurgNomis-drol/mytoyota/releases | ||
[workflow-shield]: https://img.shields.io/github/actions/workflow/status/DurgNomis-drol/mytoyota/build.yml?branch=master&style=for-the-badge | ||
[workflow]: https://github.com/DurgNomis-drol/mytoyota/actions | ||
[commits-shield]: https://img.shields.io/github/commit-activity/y/DurgNomis-drol/mytoyota.svg?style=for-the-badge | ||
[commits]: https://github.com/DurgNomis-drol/mytoyota/commits/master |