Cleanup component track_point_in_utc_time usage (#6330)
This commit is contained in:
parent
30bed8341a
commit
4e96e461f7
5 changed files with 9 additions and 12 deletions
|
@ -110,7 +110,7 @@ def setup_scanner(hass, config, see, discovery_info=None):
|
||||||
_LOGGER.info("Discovered Bluetooth LE device %s", address)
|
_LOGGER.info("Discovered Bluetooth LE device %s", address)
|
||||||
see_device(address, devs[address], new_device=True)
|
see_device(address, devs[address], new_device=True)
|
||||||
|
|
||||||
track_point_in_utc_time(hass, update_ble, now + interval)
|
track_point_in_utc_time(hass, update_ble, dt_util.utcnow() + interval)
|
||||||
|
|
||||||
update_ble(dt_util.utcnow())
|
update_ble(dt_util.utcnow())
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,8 @@ def setup_scanner(hass, config, see, discovery_info=None):
|
||||||
see_device((mac, result))
|
see_device((mac, result))
|
||||||
except bluetooth.BluetoothError:
|
except bluetooth.BluetoothError:
|
||||||
_LOGGER.exception('Error looking up bluetooth device!')
|
_LOGGER.exception('Error looking up bluetooth device!')
|
||||||
track_point_in_utc_time(hass, update_bluetooth, now + interval)
|
track_point_in_utc_time(
|
||||||
|
hass, update_bluetooth, dt_util.utcnow() + interval)
|
||||||
|
|
||||||
update_bluetooth(dt_util.utcnow())
|
update_bluetooth(dt_util.utcnow())
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ def setup_scanner(hass, config, see, discovery_info=None):
|
||||||
"""Update all the hosts on every interval time."""
|
"""Update all the hosts on every interval time."""
|
||||||
for host in hosts:
|
for host in hosts:
|
||||||
host.update(see)
|
host.update(see)
|
||||||
track_point_in_utc_time(hass, update, now + interval)
|
track_point_in_utc_time(hass, update, util.dt.utcnow() + interval)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return update(util.dt.utcnow())
|
return update(util.dt.utcnow())
|
||||||
|
|
|
@ -98,9 +98,8 @@ class TelldusLiveClient(object):
|
||||||
try:
|
try:
|
||||||
self._sync()
|
self._sync()
|
||||||
finally:
|
finally:
|
||||||
track_point_in_utc_time(self._hass,
|
track_point_in_utc_time(
|
||||||
self.update,
|
self._hass, self.update, utcnow() + self._interval)
|
||||||
now + self._interval)
|
|
||||||
|
|
||||||
def _sync(self):
|
def _sync(self):
|
||||||
"""Update local list of devices."""
|
"""Update local list of devices."""
|
||||||
|
@ -123,11 +122,8 @@ class TelldusLiveClient(object):
|
||||||
|
|
||||||
def discover(device_id, component):
|
def discover(device_id, component):
|
||||||
"""Discover the component."""
|
"""Discover the component."""
|
||||||
discovery.load_platform(self._hass,
|
discovery.load_platform(
|
||||||
component,
|
self._hass, component, DOMAIN, [device_id], self._config)
|
||||||
DOMAIN,
|
|
||||||
[device_id],
|
|
||||||
self._config)
|
|
||||||
|
|
||||||
known_ids = set([entity.device_id for entity in self.entities])
|
known_ids = set([entity.device_id for entity in self.entities])
|
||||||
for device in self._client.devices:
|
for device in self._client.devices:
|
||||||
|
|
|
@ -109,7 +109,7 @@ def setup(hass, config):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
finally:
|
finally:
|
||||||
track_point_in_utc_time(hass, update, now + interval)
|
track_point_in_utc_time(hass, update, utcnow() + interval)
|
||||||
|
|
||||||
_LOGGER.info('Logging in to service')
|
_LOGGER.info('Logging in to service')
|
||||||
return update(utcnow())
|
return update(utcnow())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue