From 7a31499441ff3672eecf435abe10ec276ae43aa1 Mon Sep 17 00:00:00 2001 From: Jeremy Compostella Date: Mon, 23 Aug 2021 14:42:26 -0700 Subject: [PATCH] EV_adaptive_charging: reduce the load on the Emporia server In order to comply with https://github.com/magico13/PyEmVue/issues/19, the service will only poll the by second data if it is actively charging. Signed-off-by: Jeremy Compostella --- EV_adaptive_charging.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/EV_adaptive_charging.py b/EV_adaptive_charging.py index 978b723..1da6098 100644 --- a/EV_adaptive_charging.py +++ b/EV_adaptive_charging.py @@ -81,7 +81,11 @@ def main(): entered_at = datetime.now() while True: try: - usage=vue.read(scale=Scale.SECOND.value) + if charger.isCharging(): + scale = Scale.SECOND.value + else: + scale = Scale.MINUTE.value + usage=vue.read(scale) break except: if entered_at + timedelta(seconds=90) < datetime.now():