From 151a9303397960638fd5d3596c8d33d13d12a1ab Mon Sep 17 00:00:00 2001 From: GitOldGrumpy Date: Sun, 14 Jan 2024 12:55:35 +0000 Subject: [PATCH] Quick test code to check status of 'possible' refresh endpoints --- mytoyota/models/vehicle.py | 21 +++++++++++++++++---- simple_client_example.py | 8 +++++--- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/mytoyota/models/vehicle.py b/mytoyota/models/vehicle.py index a1d20015..7479f942 100644 --- a/mytoyota/models/vehicle.py +++ b/mytoyota/models/vehicle.py @@ -380,10 +380,6 @@ async def get_trips( return ret - # - # More get functionality depending on what we find - # - async def set_alias(self, value) -> bool: """Set the alias for the vehicle. @@ -397,6 +393,23 @@ async def set_alias(self, value) -> bool: """ return value + async def force_update(self) -> None: + """Force update of endpoints + + Returns + ------- + + """ + endpoints_to_test = ["/v1/global/remote/electric/realtime-status", "/v1/global/remote/refresh-status", + "/v1/global/remote/refresh-climate-status"] + + for ep in endpoints_to_test: + try: + resp = await self._api.controller.request_json("POST", ep, vin=self.vin) + print(f"{ep}: {resp}") + except Exception as e: + print(f"{ep}: Threw {e}") + # # More set functionality depending on what we find # diff --git a/simple_client_example.py b/simple_client_example.py index cb9374a9..a89a96fe 100644 --- a/simple_client_example.py +++ b/simple_client_example.py @@ -49,8 +49,10 @@ async def get_information(): cars = await client.get_vehicles(metric=True) for car in cars: + await car.force_update() await car.update() + # Dashboard Information pp.pprint(f"Dashboard: {car.dashboard}") # Location Information @@ -66,9 +68,9 @@ async def get_information(): # pp.pprint( # f"Summary: {[[x] for x in await car.get_summary(date.today() - timedelta(days=7 * 4), date.today(), summary_type=SummaryType.WEEKLY)]}" # noqa: E501 # pylint: disable=C0301 # ) - pp.pprint( - f"Summary: {[[x] for x in await car.get_summary(date.today() - timedelta(days=6 * 30), date.today(), summary_type=SummaryType.MONTHLY)]}" # noqa: E501 - ) + #pp.pprint( + # f"Summary: {[[x] for x in await car.get_summary(date.today() - timedelta(days=6 * 30), date.today(), summary_type=SummaryType.MONTHLY)]}" # noqa: E501 + #) # pp.pprint( # f"Summary: {[[x] for x in await car.get_summary(date.today() - timedelta(days=365), date.today(), summary_type=SummaryType.YEARLY)]}" # noqa: E501 # pylint: disable=C0301 # )