From d4de5c4f127045196f0f8a2636ae03e6d9dd9ee7 Mon Sep 17 00:00:00 2001 From: Brett Date: Mon, 16 Sep 2024 20:41:57 +1000 Subject: [PATCH] Improve energy history endpoints again --- setup.py | 2 +- tesla_fleet_api/energy.py | 18 +++++++++--------- tesla_fleet_api/energyspecific.py | 22 +++++++++++----------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/setup.py b/setup.py index 5b694e1..4b66235 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="tesla_fleet_api", - version="0.7.7", + version="0.7.8", author="Brett Adams", author_email="hello@teslemetry.com", description="Tesla Fleet API library for Python", diff --git a/tesla_fleet_api/energy.py b/tesla_fleet_api/energy.py index 68e146d..d282294 100644 --- a/tesla_fleet_api/energy.py +++ b/tesla_fleet_api/energy.py @@ -32,10 +32,10 @@ async def backup( async def backup_history( self, energy_site_id: int, - start_date: str, - end_date: str, - period: TeslaEnergyPeriod | str, - time_zone: str, + period: TeslaEnergyPeriod | str | None, + start_date: str | None = None, + end_date: str | None = None, + time_zone: str | None = None, ) -> dict[str, Any]: """Returns the backup (off-grid) event history of the site in duration of seconds.""" return await self._request( @@ -55,7 +55,7 @@ async def charge_history( energy_site_id: int, start_date: str, end_date: str, - time_zone: str, + time_zone: str | None = None, ) -> dict[str, Any]: """Returns the charging history of a wall connector.""" return await self._request( @@ -72,10 +72,10 @@ async def charge_history( async def energy_history( self, energy_site_id: int, - start_date: str, - end_date: str, - period: TeslaEnergyPeriod | str, - time_zone: str, + period: TeslaEnergyPeriod | str | None, + start_date: str | None = None, + end_date: str | None = None, + time_zone: str | None = None, ) -> dict[str, Any]: """Returns the energy measurements of the site, aggregated to the requested period.""" return await self._request( diff --git a/tesla_fleet_api/energyspecific.py b/tesla_fleet_api/energyspecific.py index 9ce7bc0..a2dbb21 100644 --- a/tesla_fleet_api/energyspecific.py +++ b/tesla_fleet_api/energyspecific.py @@ -29,17 +29,17 @@ async def backup(self, backup_reserve_percent: int) -> dict[str, Any]: async def backup_history( self, - start_date: str, - end_date: str, - period: TeslaEnergyPeriod | str, - time_zone: str, + period: TeslaEnergyPeriod | str | None, + start_date: str | None = None, + end_date: str | None = None, + time_zone: str | None = None, ) -> dict[str, Any]: """Returns the backup (off-grid) event history of the site in duration of seconds.""" return await self._parent.backup_history( self.energy_site_id, + period, start_date, end_date, - period, time_zone, ) @@ -47,7 +47,7 @@ async def charge_history( self, start_date: str, end_date: str, - time_zone: str, + time_zone: str | None = None, ) -> dict[str, Any]: """Returns the charging history of a wall connector.""" return await self._parent.charge_history( @@ -59,17 +59,17 @@ async def charge_history( async def energy_history( self, - start_date: str, - end_date: str, - period: TeslaEnergyPeriod | str, - time_zone: str, + period: TeslaEnergyPeriod | str | None, + start_date: str | None = None, + end_date: str | None = None, + time_zone: str | None = None, ) -> dict[str, Any]: """Returns the energy measurements of the site, aggregated to the requested period.""" return await self._parent.energy_history( self.energy_site_id, + period, start_date, end_date, - period, time_zone, )