Update remaining i2c sensors to use async_add_executor_job (#41860)

This commit is contained in:
J. Nick Koston 2020-10-15 09:22:17 -05:00 committed by GitHub
parent 086378c48f
commit 2e05592039
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 10 deletions

View file

@ -89,7 +89,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
i2c_address = config[CONF_I2C_ADDRESS]
bus = smbus.SMBus(config[CONF_I2C_BUS])
sensor = await hass.async_add_job(
sensor = await hass.async_add_executor_job(
partial(
BME280,
bus,
@ -108,7 +108,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
_LOGGER.error("BME280 sensor not detected at %s", i2c_address)
return False
sensor_handler = await hass.async_add_job(BME280Handler, sensor)
sensor_handler = await hass.async_add_executor_job(BME280Handler, sensor)
dev = []
try:
@ -166,7 +166,7 @@ class BME280Sensor(Entity):
async def async_update(self):
"""Get the latest data from the BME280 and update the states."""
await self.hass.async_add_job(self.bme280_client.update)
await self.hass.async_add_executor_job(self.bme280_client.update)
if self.bme280_client.sensor.sample_ok:
if self.type == SENSOR_TEMP:
temperature = round(self.bme280_client.sensor.temperature, 1)