From 2c5e434d7c85b0847ce91c271025ab95c03e1a40 Mon Sep 17 00:00:00 2001 From: Eric de Groot Date: Wed, 3 Apr 2024 21:21:18 -0700 Subject: [PATCH 1/2] fix: fix grid_status (#466) --- AUTHORS.md | 1 + teslajsonpy/energy.py | 2 +- tests/unit_tests/test_energy.py | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/AUTHORS.md b/AUTHORS.md index 0262d14b..ec92ce1d 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -23,3 +23,4 @@ - craigrouse [Github](https://github.com/craigrouse) - thierryVT [Github](https://github.com/thierryvt) - llamafilm [Github](https://github.com/llamafilm) +- ericdegroot [Github](https://github.com/ericdegroot) diff --git a/teslajsonpy/energy.py b/teslajsonpy/energy.py index 7b4dfc39..46c7cdf7 100644 --- a/teslajsonpy/energy.py +++ b/teslajsonpy/energy.py @@ -159,7 +159,7 @@ def grid_power(self) -> float: @property def grid_status(self) -> str: """Return grid status.""" - return self._site_summary.get("grid_status") + return self._site_data.get("grid_status") @property def load_power(self) -> float: diff --git a/tests/unit_tests/test_energy.py b/tests/unit_tests/test_energy.py index d2bec54d..3deca167 100644 --- a/tests/unit_tests/test_energy.py +++ b/tests/unit_tests/test_energy.py @@ -92,6 +92,10 @@ async def test_powerwall_site(monkeypatch): _solar_powerwall_site.grid_power == SITE_DATA["grid_power"] ) + assert ( + _solar_powerwall_site.grid_status + == SITE_DATA["grid_status"] + ) assert ( _solar_powerwall_site.load_power == SITE_DATA["load_power"] From 171048121a12fa7ebbd75d69dbdf83ddebdaf145 Mon Sep 17 00:00:00 2001 From: gkwok1 <51801924+gkwok1@users.noreply.github.com> Date: Thu, 4 Apr 2024 00:21:34 -0400 Subject: [PATCH 2/2] fix: fix Energy Left (#465) --- teslajsonpy/energy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/teslajsonpy/energy.py b/teslajsonpy/energy.py index 46c7cdf7..b050d027 100644 --- a/teslajsonpy/energy.py +++ b/teslajsonpy/energy.py @@ -149,7 +149,7 @@ def data_available(self) -> bool: @property def energy_left(self) -> float: """Return battery energy left in Watt hours.""" - return self._site_summary.get("energy_left") + return round (self._site_config.get("nameplate_energy") * self.percentage_charged / 100 ) @property def grid_power(self) -> float: