Try not getting the same data over and over again...
This commit is contained in:
parent
1b5af38755
commit
6cd097fcfa
1 changed files with 1 additions and 6 deletions
|
@ -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."""
|
||||
|
|
Loading…
Reference in a new issue