Update device_tracker to use async_add_executor_job (#41515)

This commit is contained in:
J. Nick Koston 2020-10-08 16:56:32 -05:00 committed by GitHub
parent 4d9ff13384
commit 5b8ecc26a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -479,7 +479,7 @@ class DeviceScanner:
async def async_scan_devices(self) -> Any:
"""Scan for devices."""
return await self.hass.async_add_job(self.scan_devices)
return await self.hass.async_add_executor_job(self.scan_devices)
def get_device_name(self, device: str) -> str:
"""Get the name of a device."""
@ -487,7 +487,7 @@ class DeviceScanner:
async def async_get_device_name(self, device: str) -> Any:
"""Get the name of a device."""
return await self.hass.async_add_job(self.get_device_name, device)
return await self.hass.async_add_executor_job(self.get_device_name, device)
def get_extra_attributes(self, device: str) -> dict:
"""Get the extra attributes of a device."""
@ -495,7 +495,7 @@ class DeviceScanner:
async def async_get_extra_attributes(self, device: str) -> Any:
"""Get the extra attributes of a device."""
return await self.hass.async_add_job(self.get_extra_attributes, device)
return await self.hass.async_add_executor_job(self.get_extra_attributes, device)
async def async_load_config(
@ -522,7 +522,7 @@ async def async_load_config(
)
result = []
try:
devices = await hass.async_add_job(load_yaml_config_file, path)
devices = await hass.async_add_executor_job(load_yaml_config_file, path)
except HomeAssistantError as err:
LOGGER.error("Unable to load %s: %s", path, str(err))
return []

View File

@ -60,7 +60,7 @@ class DeviceTrackerPlatform:
hass, {DOMAIN: self.config}
)
elif hasattr(self.platform, "get_scanner"):
scanner = await hass.async_add_job(
scanner = await hass.async_add_executor_job(
self.platform.get_scanner, hass, {DOMAIN: self.config}
)
elif hasattr(self.platform, "async_setup_scanner"):
@ -68,7 +68,7 @@ class DeviceTrackerPlatform:
hass, self.config, tracker.async_see, discovery_info
)
elif hasattr(self.platform, "setup_scanner"):
setup = await hass.async_add_job(
setup = await hass.async_add_executor_job(
self.platform.setup_scanner,
hass,
self.config,