Skip to content

Commit

Permalink
Set an appropriate SCAN_INTERVAL for Broadlink A1 sensor (home-assist…
Browse files Browse the repository at this point in the history
  • Loading branch information
felipediel authored Nov 10, 2020
1 parent 1fba245 commit 2b83af8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions homeassistant/components/broadlink/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class BroadlinkUpdateManager(ABC):
monitor device availability.
"""

SCAN_INTERVAL = timedelta(minutes=1)

def __init__(self, device):
"""Initialize the update manager."""
self.device = device
Expand All @@ -52,7 +54,7 @@ def __init__(self, device):
_LOGGER,
name=f"{device.name} ({device.api.model} at {device.api.host[0]})",
update_method=self.async_update,
update_interval=timedelta(minutes=1),
update_interval=self.SCAN_INTERVAL,
)
self.available = None
self.last_update = None
Expand All @@ -64,7 +66,7 @@ async def async_update(self):

except (BroadlinkException, OSError) as err:
if self.available and (
dt.utcnow() - self.last_update > timedelta(minutes=3)
dt.utcnow() - self.last_update > self.SCAN_INTERVAL * 3
or isinstance(err, (AuthorizationError, OSError))
):
self.available = False
Expand Down Expand Up @@ -96,6 +98,8 @@ async def async_fetch_data(self):
class BroadlinkA1UpdateManager(BroadlinkUpdateManager):
"""Manages updates for Broadlink A1 devices."""

SCAN_INTERVAL = timedelta(seconds=10)

async def async_fetch_data(self):
"""Fetch data from the device."""
return await self.device.async_request(self.device.api.check_sensors_raw)
Expand Down

0 comments on commit 2b83af8

Please sign in to comment.