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
+5 -5
View File
@@ -63,18 +63,18 @@ CONFIG_SCHEMA = sensor.sensor_schema(
)
def to_code(config):
async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
yield cg.register_component(var, config)
yield sensor.register_sensor(var, config)
await cg.register_component(var, config)
await sensor.register_sensor(var, config)
pin = yield cg.gpio_pin_expression(config[CONF_PIN])
pin = await cg.gpio_pin_expression(config[CONF_PIN])
cg.add(var.set_pin(pin))
cg.add(var.set_filter_us(config[CONF_INTERNAL_FILTER]))
cg.add(var.set_timeout_us(config[CONF_TIMEOUT]))
if CONF_TOTAL in config:
sens = yield sensor.new_sensor(config[CONF_TOTAL])
sens = await sensor.new_sensor(config[CONF_TOTAL])
cg.add(var.set_total_sensor(sens))