mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Update device_tracker to use async_add_executor_job (#41515)
This commit is contained in:
parent
4d9ff13384
commit
5b8ecc26a4
@ -479,7 +479,7 @@ class DeviceScanner:
|
|||||||
|
|
||||||
async def async_scan_devices(self) -> Any:
|
async def async_scan_devices(self) -> Any:
|
||||||
"""Scan for devices."""
|
"""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:
|
def get_device_name(self, device: str) -> str:
|
||||||
"""Get the name of a device."""
|
"""Get the name of a device."""
|
||||||
@ -487,7 +487,7 @@ class DeviceScanner:
|
|||||||
|
|
||||||
async def async_get_device_name(self, device: str) -> Any:
|
async def async_get_device_name(self, device: str) -> Any:
|
||||||
"""Get the name of a device."""
|
"""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:
|
def get_extra_attributes(self, device: str) -> dict:
|
||||||
"""Get the extra attributes of a device."""
|
"""Get the extra attributes of a device."""
|
||||||
@ -495,7 +495,7 @@ class DeviceScanner:
|
|||||||
|
|
||||||
async def async_get_extra_attributes(self, device: str) -> Any:
|
async def async_get_extra_attributes(self, device: str) -> Any:
|
||||||
"""Get the extra attributes of a device."""
|
"""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(
|
async def async_load_config(
|
||||||
@ -522,7 +522,7 @@ async def async_load_config(
|
|||||||
)
|
)
|
||||||
result = []
|
result = []
|
||||||
try:
|
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:
|
except HomeAssistantError as err:
|
||||||
LOGGER.error("Unable to load %s: %s", path, str(err))
|
LOGGER.error("Unable to load %s: %s", path, str(err))
|
||||||
return []
|
return []
|
||||||
|
@ -60,7 +60,7 @@ class DeviceTrackerPlatform:
|
|||||||
hass, {DOMAIN: self.config}
|
hass, {DOMAIN: self.config}
|
||||||
)
|
)
|
||||||
elif hasattr(self.platform, "get_scanner"):
|
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}
|
self.platform.get_scanner, hass, {DOMAIN: self.config}
|
||||||
)
|
)
|
||||||
elif hasattr(self.platform, "async_setup_scanner"):
|
elif hasattr(self.platform, "async_setup_scanner"):
|
||||||
@ -68,7 +68,7 @@ class DeviceTrackerPlatform:
|
|||||||
hass, self.config, tracker.async_see, discovery_info
|
hass, self.config, tracker.async_see, discovery_info
|
||||||
)
|
)
|
||||||
elif hasattr(self.platform, "setup_scanner"):
|
elif hasattr(self.platform, "setup_scanner"):
|
||||||
setup = await hass.async_add_job(
|
setup = await hass.async_add_executor_job(
|
||||||
self.platform.setup_scanner,
|
self.platform.setup_scanner,
|
||||||
hass,
|
hass,
|
||||||
self.config,
|
self.config,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user