Convert components to async-def syntax (#1823)

* Convert components to async-def syntax

* Remove stray @coroutine

* Manual part

* Convert complexer components code to async-def

* Manual cleanup

* More manual cleanup
This commit is contained in:
Otto Winter
2021-05-24 21:45:31 +02:00
committed by GitHub
parent 93d9d4b50a
commit a33bb32874
60 changed files with 592 additions and 633 deletions
+2 -4
View File
@@ -21,7 +21,6 @@ from esphome.const import (
ICON_THERMOMETER,
ICON_WATER_PERCENT,
)
from esphome.core import coroutine
from . import (
BME680BSECComponent,
CONF_BME680_BSEC_ID,
@@ -87,11 +86,10 @@ CONFIG_SCHEMA = cv.Schema(
)
@coroutine
def setup_conf(config, key, hub):
async def setup_conf(config, key, hub):
if key in config:
conf = config[key]
sens = yield sensor.new_sensor(conf)
sens = await sensor.new_sensor(conf)
cg.add(getattr(hub, f"set_{key}_sensor")(sens))
if CONF_SAMPLE_RATE in conf:
cg.add(getattr(hub, f"set_{key}_sample_rate")(conf[CONF_SAMPLE_RATE]))
@@ -2,7 +2,6 @@ import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import text_sensor
from esphome.const import CONF_ID, CONF_ICON
from esphome.core import coroutine
from . import BME680BSECComponent, CONF_BME680_BSEC_ID
DEPENDENCIES = ["bme680_bsec"]
@@ -25,12 +24,11 @@ CONFIG_SCHEMA = cv.Schema(
)
@coroutine
def setup_conf(config, key, hub):
async def setup_conf(config, key, hub):
if key in config:
conf = config[key]
sens = cg.new_Pvariable(conf[CONF_ID])
yield text_sensor.register_text_sensor(sens, conf)
await text_sensor.register_text_sensor(sens, conf)
cg.add(getattr(hub, f"set_{key}_text_sensor")(sens))