mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Update nest to use async_add_executor_job (#41926)
This commit is contained in:
parent
250fbd857b
commit
965bb2c8df
@ -149,7 +149,7 @@ async def async_setup_entry(hass, entry):
|
|||||||
_LOGGER.debug("proceeding with setup")
|
_LOGGER.debug("proceeding with setup")
|
||||||
conf = hass.data.get(DATA_NEST_CONFIG, {})
|
conf = hass.data.get(DATA_NEST_CONFIG, {})
|
||||||
hass.data[DATA_NEST] = NestDevice(hass, conf, nest)
|
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
|
return False
|
||||||
|
|
||||||
for component in "climate", "camera", "sensor", "binary_sensor":
|
for component in "climate", "camera", "sensor", "binary_sensor":
|
||||||
|
@ -117,7 +117,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
|
|||||||
|
|
||||||
return sensors
|
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):
|
class NestBinarySensor(NestSensorDevice, BinarySensorEntity):
|
||||||
|
@ -24,7 +24,9 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
|
|
||||||
async def async_setup_entry(hass, entry, async_add_entities):
|
async def async_setup_entry(hass, entry, async_add_entities):
|
||||||
"""Set up a Nest sensor based on a config entry."""
|
"""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]
|
cameras = [NestCamera(structure, device) for structure, device in camera_devices]
|
||||||
async_add_entities(cameras, True)
|
async_add_entities(cameras, True)
|
||||||
|
|
||||||
|
@ -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."""
|
"""Set up the Nest climate device based on a config entry."""
|
||||||
temp_unit = hass.config.units.temperature_unit
|
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 = [
|
all_devices = [
|
||||||
NestThermostat(structure, device, temp_unit)
|
NestThermostat(structure, device, temp_unit)
|
||||||
|
@ -136,12 +136,12 @@ class NestFlowHandler(config_entries.ConfigFlow):
|
|||||||
|
|
||||||
config_path = info["nest_conf_path"]
|
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
|
self.flow_impl = DOMAIN
|
||||||
return await self.async_step_link()
|
return await self.async_step_link()
|
||||||
|
|
||||||
flow = self.hass.data[DATA_FLOW_IMPL][DOMAIN]
|
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(
|
return self._entry_from_tokens(
|
||||||
"Nest (import from configuration.yaml)", flow, tokens
|
"Nest (import from configuration.yaml)", flow, tokens
|
||||||
|
@ -40,7 +40,7 @@ async def resolve_auth_code(hass, client_id, client_secret, code):
|
|||||||
auth.pin = code
|
auth.pin = code
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await hass.async_add_job(auth.login)
|
await hass.async_add_executor_job(auth.login)
|
||||||
return await result
|
return await result
|
||||||
except AuthorizationError as err:
|
except AuthorizationError as err:
|
||||||
if err.response.status_code == HTTP_UNAUTHORIZED:
|
if err.response.status_code == HTTP_UNAUTHORIZED:
|
||||||
|
@ -144,7 +144,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
|
|||||||
|
|
||||||
return all_sensors
|
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):
|
class NestBasicSensor(NestSensorDevice):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user