1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-18 07:45:56 +00:00

Convert components to async-def syntax (#1821)

This commit is contained in:
Otto Winter
2021-05-24 10:58:29 +02:00
committed by GitHub
parent b92702a312
commit 2376a2c941
296 changed files with 1423 additions and 1424 deletions

View File

@@ -47,18 +47,18 @@ CONFIG_SCHEMA = cv.Schema(
).extend(cv.polling_component_schema("60s"))
def to_code(config):
async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
yield cg.register_component(var, config)
await cg.register_component(var, config)
pin = yield gpio_pin_expression(config[CONF_PIN])
pin = await gpio_pin_expression(config[CONF_PIN])
cg.add(var.set_pin(pin))
if CONF_TEMPERATURE in config:
sens = yield sensor.new_sensor(config[CONF_TEMPERATURE])
sens = await sensor.new_sensor(config[CONF_TEMPERATURE])
cg.add(var.set_temperature_sensor(sens))
if CONF_HUMIDITY in config:
sens = yield sensor.new_sensor(config[CONF_HUMIDITY])
sens = await sensor.new_sensor(config[CONF_HUMIDITY])
cg.add(var.set_humidity_sensor(sens))
cg.add(var.set_dht_model(config[CONF_MODEL]))