From 2e05592039a8f41ba2599d4e0013e8ca089f66a6 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 15 Oct 2020 09:22:17 -0500 Subject: [PATCH] Update remaining i2c sensors to use async_add_executor_job (#41860) --- homeassistant/components/bh1750/sensor.py | 4 ++-- homeassistant/components/bme280/sensor.py | 6 +++--- homeassistant/components/bme680/sensor.py | 4 ++-- homeassistant/components/htu21d/sensor.py | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/bh1750/sensor.py b/homeassistant/components/bh1750/sensor.py index 4d4067eb77d..7680b8b09ad 100644 --- a/homeassistant/components/bh1750/sensor.py +++ b/homeassistant/components/bh1750/sensor.py @@ -69,7 +69,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= bus = smbus.SMBus(bus_number) - sensor = await hass.async_add_job( + sensor = await hass.async_add_executor_job( partial( BH1750, bus, @@ -130,7 +130,7 @@ class BH1750Sensor(Entity): async def async_update(self): """Get the latest data from the BH1750 and update the states.""" - await self.hass.async_add_job(self.bh1750_sensor.update) + await self.hass.async_add_executor_job(self.bh1750_sensor.update) if self.bh1750_sensor.sample_ok and self.bh1750_sensor.light_level >= 0: self._state = int(round(self.bh1750_sensor.light_level * self._multiplier)) else: diff --git a/homeassistant/components/bme280/sensor.py b/homeassistant/components/bme280/sensor.py index dd5ed905fe2..5f38c420ff1 100644 --- a/homeassistant/components/bme280/sensor.py +++ b/homeassistant/components/bme280/sensor.py @@ -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) diff --git a/homeassistant/components/bme680/sensor.py b/homeassistant/components/bme680/sensor.py index e412b410935..49d95bbc53b 100644 --- a/homeassistant/components/bme680/sensor.py +++ b/homeassistant/components/bme680/sensor.py @@ -111,7 +111,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= SENSOR_TYPES[SENSOR_TEMP][1] = hass.config.units.temperature_unit name = config[CONF_NAME] - sensor_handler = await hass.async_add_job(_setup_bme680, config) + sensor_handler = await hass.async_add_executor_job(_setup_bme680, config) if sensor_handler is None: return @@ -347,7 +347,7 @@ class BME680Sensor(Entity): async def async_update(self): """Get the latest data from the BME680 and update the states.""" - await self.hass.async_add_job(self.bme680_client.update) + await self.hass.async_add_executor_job(self.bme680_client.update) if self.type == SENSOR_TEMP: temperature = round(self.bme680_client.sensor_data.temperature, 1) if self.temp_unit == TEMP_FAHRENHEIT: diff --git a/homeassistant/components/htu21d/sensor.py b/homeassistant/components/htu21d/sensor.py index 5a0c81b083c..a9b235faa0b 100644 --- a/homeassistant/components/htu21d/sensor.py +++ b/homeassistant/components/htu21d/sensor.py @@ -41,12 +41,12 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= temp_unit = hass.config.units.temperature_unit bus = smbus.SMBus(config.get(CONF_I2C_BUS)) - sensor = await hass.async_add_job(partial(HTU21D, bus, logger=_LOGGER)) + sensor = await hass.async_add_executor_job(partial(HTU21D, bus, logger=_LOGGER)) if not sensor.sample_ok: _LOGGER.error("HTU21D sensor not detected in bus %s", bus_number) return False - sensor_handler = await hass.async_add_job(HTU21DHandler, sensor) + sensor_handler = await hass.async_add_executor_job(HTU21DHandler, sensor) dev = [ HTU21DSensor(sensor_handler, name, SENSOR_TEMPERATURE, temp_unit), @@ -98,7 +98,7 @@ class HTU21DSensor(Entity): async def async_update(self): """Get the latest data from the HTU21D sensor and update the state.""" - await self.hass.async_add_job(self._client.update) + await self.hass.async_add_executor_job(self._client.update) if self._client.sensor.sample_ok: if self._variable == SENSOR_TEMPERATURE: value = round(self._client.sensor.temperature, 1)