Skip to content

Commit

Permalink
Refresh codes faster (#66)
Browse files Browse the repository at this point in the history
* Update sensor.py

* Fix async update of sensors

* Update sensor.py

* Will comment out call to prevent battery drain.  Might implement as a service later.
  • Loading branch information
firstof9 authored Dec 2, 2020
1 parent a66f9d3 commit db250d4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions custom_components/lock-manager/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, hass, config):
self._lockname = config.get(CONF_LOCK_NAME)
self._data = None

self.update = Throttle(timedelta(seconds=5))(self.update)
self.update = Throttle(timedelta(seconds=60))(self.update)

async def update(self):
"""Get the latest data"""
Expand Down Expand Up @@ -187,7 +187,6 @@ def __init__(self, data, sensor_name, code_slot, lock_name, unique_id):
self._unique_id = unique_id
self._name = sensor_name
self._lock_name = lock_name
self.update()

@property
def unique_id(self):
Expand Down Expand Up @@ -223,12 +222,12 @@ def available(self):
return True
return False

def update(self):
async def async_update(self):
"""Fetch new state data for the sensor.
This is the only method that should fetch new data for Home Assistant.
"""

self.data.update()
await self.data.update()
# Using a dict to send the data back

if self.data._data is not None:
Expand Down

0 comments on commit db250d4

Please sign in to comment.