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
+7 -7
View File
@@ -45,21 +45,21 @@ 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_clock = yield gpio_pin_expression(config[CONF_CLOCK_PIN])
pin_clock = await gpio_pin_expression(config[CONF_CLOCK_PIN])
cg.add(var.set_pin_clock(pin_clock))
pin_data = yield gpio_pin_expression(config[CONF_DATA_PIN])
pin_data = await gpio_pin_expression(config[CONF_DATA_PIN])
cg.add(var.set_pin_data(pin_data))
if CONF_CO2 in config:
sens = yield sensor.new_sensor(config[CONF_CO2])
sens = await sensor.new_sensor(config[CONF_CO2])
cg.add(var.set_co2_sensor(sens))
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))