From 6cd097fcfab47fac9f7a1fba8b7cfa84fcb03215 Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Sat, 22 May 2021 20:58:57 +0200 Subject: [PATCH] Try not getting the same data over and over again... --- kumisensors.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/kumisensors.py b/kumisensors.py index 163c321..f01f42c 100644 --- a/kumisensors.py +++ b/kumisensors.py @@ -13,15 +13,10 @@ class KumiSensors: if not "://" in host: host = "http://" + host self.host = host - self.data = None self.hass = hass - def fetch_data(self): - return json.load(urlopen(self.host)) - async def get_data(self) -> dict: - self.data = self.data or await self.hass.async_add_executor_job(self.fetch_data) - return self.data + return await self.hass.async_add_executor_job(json.load(urlopen(self.host))) async def connect(self) -> bool: """Test if we can connect to the host."""