Deprecated stuff (#16019)
* Use async with for locks * Fix regex in template test * Close session correctly * Use correct current_task method * push camera cleanup * Lint * Revert current_task * Update websocket_api.py * Mock executor_job betteR * Fix async_create_task mock
This commit is contained in:
1 parent
975befd136
commit
d1e1b9b38a
7 files changed
+50
-22
No files matched your search
@@ -330,19 +330,18 @@ class DeviceTracker:
|
||||
})
|
||||
|
||||
# update known_devices.yaml
|
||||
self.hass.async_add_job(
|
||||
self.hass.async_create_task(
|
||||
self.async_update_config(
|
||||
self.hass.config.path(YAML_DEVICES), dev_id, device)
|
||||
)
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_update_config(self, path, dev_id, device):
|
||||
async def async_update_config(self, path, dev_id, device):
|
||||
"""Add device to YAML configuration file.
|
||||
|
||||
This method is a coroutine.
|
||||
"""
|
||||
with (yield from self._is_updating):
|
||||
yield from self.hass.async_add_job(
|
||||
async with self._is_updating:
|
||||
await self.hass.async_add_executor_job(
|
||||
update_config, self.hass.config.path(YAML_DEVICES),
|
||||
dev_id, device)
|
||||
|
||||
@@ -681,8 +680,7 @@ def async_setup_scanner_platform(hass: HomeAssistantType, config: ConfigType,
|
||||
# Initial scan of each mac we also tell about host name for config
|
||||
seen = set() # type: Any
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_device_tracker_scan(now: dt_util.dt.datetime):
|
||||
async def async_device_tracker_scan(now: dt_util.dt.datetime):
|
||||
"""Handle interval matches."""
|
||||
if update_lock.locked():
|
||||
_LOGGER.warning(
|
||||
@@ -690,18 +688,18 @@ def async_setup_scanner_platform(hass: HomeAssistantType, config: ConfigType,
|
||||
"scan interval %s", platform, interval)
|
||||
return
|
||||
|
||||
with (yield from update_lock):
|
||||
found_devices = yield from scanner.async_scan_devices()
|
||||
async with update_lock:
|
||||
found_devices = await scanner.async_scan_devices()
|
||||
|
||||
for mac in found_devices:
|
||||
if mac in seen:
|
||||
host_name = None
|
||||
else:
|
||||
host_name = yield from scanner.async_get_device_name(mac)
|
||||
host_name = await scanner.async_get_device_name(mac)
|
||||
seen.add(mac)
|
||||
|
||||
try:
|
||||
extra_attributes = (yield from
|
||||
extra_attributes = (await
|
||||
scanner.async_get_extra_attributes(mac))
|
||||
except NotImplementedError:
|
||||
extra_attributes = dict()
|
||||
|
||||
Reference in new issue
Block a user