Update nest to use async_add_executor_job (#41926)

This commit is contained in:
J. Nick Koston 2020-10-16 06:31:16 -05:00 committed by GitHub
parent 250fbd857b
commit 965bb2c8df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 10 additions and 8 deletions

View file

@ -149,7 +149,7 @@ async def async_setup_entry(hass, entry):
_LOGGER.debug("proceeding with setup")
conf = hass.data.get(DATA_NEST_CONFIG, {})
hass.data[DATA_NEST] = NestDevice(hass, conf, nest)
if not await hass.async_add_job(hass.data[DATA_NEST].initialize):
if not await hass.async_add_executor_job(hass.data[DATA_NEST].initialize):
return False
for component in "climate", "camera", "sensor", "binary_sensor":

View file

@ -117,7 +117,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
return sensors
async_add_entities(await hass.async_add_job(get_binary_sensors), True)
async_add_entities(await hass.async_add_executor_job(get_binary_sensors), True)
class NestBinarySensor(NestSensorDevice, BinarySensorEntity):

View file

@ -24,7 +24,9 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
async def async_setup_entry(hass, entry, async_add_entities):
"""Set up a Nest sensor based on a config entry."""
camera_devices = await hass.async_add_job(hass.data[nest.DATA_NEST].cameras)
camera_devices = await hass.async_add_executor_job(
hass.data[nest.DATA_NEST].cameras
)
cameras = [NestCamera(structure, device) for structure, device in camera_devices]
async_add_entities(cameras, True)

View file

@ -78,7 +78,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
"""Set up the Nest climate device based on a config entry."""
temp_unit = hass.config.units.temperature_unit
thermostats = await hass.async_add_job(hass.data[DATA_NEST].thermostats)
thermostats = await hass.async_add_executor_job(hass.data[DATA_NEST].thermostats)
all_devices = [
NestThermostat(structure, device, temp_unit)

View file

@ -136,12 +136,12 @@ class NestFlowHandler(config_entries.ConfigFlow):
config_path = info["nest_conf_path"]
if not await self.hass.async_add_job(os.path.isfile, config_path):
if not await self.hass.async_add_executor_job(os.path.isfile, config_path):
self.flow_impl = DOMAIN
return await self.async_step_link()
flow = self.hass.data[DATA_FLOW_IMPL][DOMAIN]
tokens = await self.hass.async_add_job(load_json, config_path)
tokens = await self.hass.async_add_executor_job(load_json, config_path)
return self._entry_from_tokens(
"Nest (import from configuration.yaml)", flow, tokens

View file

@ -40,7 +40,7 @@ async def resolve_auth_code(hass, client_id, client_secret, code):
auth.pin = code
try:
await hass.async_add_job(auth.login)
await hass.async_add_executor_job(auth.login)
return await result
except AuthorizationError as err:
if err.response.status_code == HTTP_UNAUTHORIZED:

View file

@ -144,7 +144,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
return all_sensors
async_add_entities(await hass.async_add_job(get_sensors), True)
async_add_entities(await hass.async_add_executor_job(get_sensors), True)
class NestBasicSensor(NestSensorDevice):