Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update example code in README.md to match changes in implementation #128

Merged
merged 1 commit into from
Jan 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 6 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -49,7 +49,6 @@ async def get_information():
# 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(
*[
@@ -60,53 +59,25 @@ async def get_information():
]
)

# You can deposit each result into premade object holder for statistics. This will make it easier to use in your code.

vehicle.statistics.daily = data[0]
vehicle.statistics.weekly = data[1]
vehicle.statistics.monthly = data[2]
vehicle.statistics.yearly = data[3]


# You can access odometer data like this:
mileage = vehicle.odometer.mileage
mileage = vehicle.dashboard.odometer
# Or retrieve the energy level (electric or gasoline)
fuel = vehicle.energy.level
fuel = vehicle.dashboard.fuel_level
battery = vehicle.dashboard.batter_level
# Or Parking information:
latitude = vehicle.parking.latitude


# Pretty print the object. This will provide you with all available information.
print(json.dumps(vehicle.as_dict(), indent=3))
latitude = vehicle.parkinglocation.latitude


# -------------------------------
# All data is return in an object.
# -------------------------------

# Returns live data from car/last time you used it.
vehicle = await client.get_vehicle_status(car)
print(vehicle.as_dict())

# Stats returned in a dict
# Daily stats
daily_stats = await client.get_driving_statistics(vehicle.vin, interval="day")
print(daily_stats.as_list())

# Stats returned in json.
weekly_stats = await client.get_driving_statistics(vehicle.vin, interval="isoweek")
print(weekly_stats.as_list())

# ISO 8601 week stats
iso_weekly_stats = await client.get_driving_statistics(vehicle.vin, interval="isoweek")
print(iso_weekly_stats.as_list)

# Monthly stats is returned by default
monthly_stats = await client.get_driving_statistics(vehicle.vin)
print(monthly_stats.as_list())

#Get year to date stats.
# Get year to date stats.
yearly_stats = await client.get_driving_statistics(vehicle.vin, interval="year")
print(yearly_stats.as_list())


loop = asyncio.get_event_loop()