Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add weekly & yearly summaries (#265)
* Basics working. No statistics. Possible but needs changing. Will cause exceptions. No trips. Possible but needs changing. Will cause exceptions. No "setting" of data. Is possible need to work out endpoints. No HVAC. Is possible need to work out endpoint. Tests will fail. Doesn't deal with regresh token. Depracated endpoints still there but fail. May other things are still missing. * Moved all calls to the Vehicle class. Trips, Statistics & HVAC still missing. All "getter" functions are synchronous. All "setter" functions are asynchronous. HOWEVER none of them work, something is missing. Re-worked they way endpoints are retrieved and added capability checking. * Got a "setter" working. Alias can now be set. Can retrieve all notifications. Seems no way to limit how little/many are returned. Added flag for only unread notifications. * Update dependencies * Added /v1/global/remote/status which brings the door/window sensors (and another copy of fuel levels, odometer and range. Thanks @CM000n for testing) Updated logging function so (hopefully) identifiable information is censored. TODO debug logging functions. Addressed some review comments. * Added basic trips endpoint using pydantic models. Needs reviewing for correct usage. * Used python 3.9 compatible Optional[x] instead of 'x | None' * fix type hints in logs utils * Run poetry update * emoves redundancy by combining censor_dict and censor_all into a single function * emoves redundancy by combining censor_dict and censor_all into a single function * fix type hint * fix type hint * Fix type hints in api.py * use inline variable that is imidiatley returned with awared timezone element * lift code into else after jump into control flow * adjsut more type hints * fiy pylint errors * add docstrings * censor also link with vin from output and dump all by default * adjust models and print trips in _dump_all() * add healt_status model * cencor vin in HealtStatusModel * use more generic string cencoring * add location model * Fix typing for 3.8. Added Account Model. * Further Updates! * Fix typo * add vscode to gitignore * Added/Updated the following endpoints, with basic tests: v1_location, v1_trips, v1_vehicle_healh, v2_vehicle_guid, v4_account * WIP. _STILL BROKEN_ * fix trips model and adjust payload unpacking * Fix alias names and data types * Adjust StatusModel to inherit from it * Use car_ prefix to avoid pydantic namespace error * adjust request type for vehicles endpoint * adjust request type for notification endpoint * replace append loop with list extend * Adjust how information is received from VehicleGuidModel in Vehicle class * Comment out non supported feature from now in simple_client_test.py * fix notifications endpoint model * add RemoteStatusResponseModel * add RemoteStatusResponseModel * add telemtry model * adjust return type * Set payload on all Endpoint models to Optional with None as default * Use UnitValueModel for common Models * Update mytoyota/models/endpoints/vehicle_guid.py Co-authored-by: Sergio Conde Gómez <[email protected]> * add basic test for notification model * add basic test for telemetry model * run pre-commit on all files * HDC needs to be optional for fuel only cars. Range not always reported. responce => response * Add electric status endpoint * Model Trips.Route Add route field to trips as optional, default None Mark behaviours as optional, default None Quick hack to dump all * Adjust Notification model name and fix import in tests * adjust request type * remove unused import and use absolute imports * Updated controller.py - Simplified by removing support for regions and different endpoints. I suspect the code will work for Toyota(NA), Lexus and Suburu but until we have volunteers we cant take a look. All that code might need replacing/reworking so stripped it. - Reworked debug logging. Not yet censored. * Run pre-commit * fix str-bytes-safe error * add names, phone_numer and email to censor data * replace censor_vin with censor_string * Incompatible types in assignment literal incompatible with URL * uuid defined outside init * Route endpoint no longer always get route. Changed endpoints to take vin as argument. * move conftest file to tests folder * run pre-commit * remove unused retry arguments * abstracting requesting and parsing into own function * run pre-commit * better error handling in client * replace isort and flake8 with ruff * adjust black line-length to ruff and pylint * improve readability for endpoint gathering in vehicle model * Add some documentation. Alter defaults on trip endpoint. * Black issues * fix katashiki_code obscuring * increase line-length to 120 * deactivate pylint TODO warnings * added some docstrings and fix pylint R1705 * Added some docstrings * add test_api.py * replace test_endpoints with test_api * Move endpoints to const * move controller urls to const * seperate testing from linting * seperate testing from linting * seperate testing from linting * rename simple_client_test file to exclude it from pytest * rename simple_client_test file to exclude it from pytest * fix svar type for status in notifications model * adjust linting workflow * adjust linting workflow * Replace pylint and black with ruff * use pytest-pretty * ignore error in test * If a notification has not be read it doesn't have a notification read time. Remove locale. * Added basic Vehicle API for discussion. Updated endpoint models for data not always being available. * enforce more docstring rules * add rule for unused arguments * implement ruff specific rules * add ruff_cache to gitignore * install without dev dependencies in build pipeline * Fix small review issues * mark old tests as legacy and add some new tests for utils * mark old tests as legacy and add some new tests for utils * run coverage only against source files * run coverage only against source files * add simple test for https response formatting * Add notifiations to the Client API * use pprint in example.py * get initial lock status working * fix misbehaviour in bool conversion * poetry update * fix deprecation warning in httpx formatting test * djust use of pytest.param * recreate lock file * add tests for lock_status model * use caching client * replace unsafe characters, according to RFC specification, in AUTHORIZE_URL * If a refresh token exists this will be tried before attempting username/password authentication Will cache tokens so the authenticate endpoint is not hit on every run. This maybe removed once developement is completed.o * Add username to cache for people who are testing with multiple accounts * don't use CacheClient on request_raw * bump version and update readme * change badge styling * add coverage badge * Added supported for summaries * Fix possible missing Scores * Add Trips * lint only on pr * prevent commit to master * set preferred default to false * make preferred optional * make can_set_next_charging_event optional * revert formatting changes * revert workflow changes * add whitespaces * Weekly added * Implement Weekly and Yearly summaries * run pre-commit on all files * Update get_summary with some simplifications and more comments * Break out the summary calculations into there own functions * Updated with @CM000n suggestions * Remove left over comment. --------- Co-authored-by: GitOldGrumpy <[email protected]> Co-authored-by: John de Rooij <[email protected]> Co-authored-by: Simon Hörrle <[email protected]> Co-authored-by: Simon Hörrle <[email protected]> Co-authored-by: Sergio Conde Gómez <[email protected]> Co-authored-by: Simon Hörrle <[email protected]>
- Loading branch information