Convert more code to async-def syntax (#2095)

This commit is contained in:
Otto Winter 2021-07-30 00:54:10 +02:00 committed by GitHub
parent 2966a62429
commit 34e8979d40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 22 deletions

View File

@ -18,8 +18,8 @@ CONFIG_SCHEMA = (
) )
def to_code(config): async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID]) var = cg.new_Pvariable(config[CONF_ID])
yield cg.register_component(var, config) await cg.register_component(var, config)
yield climate.register_climate(var, config) await climate.register_climate(var, config)
yield ble_client.register_ble_node(var, config) await ble_client.register_ble_node(var, config)

View File

@ -51,22 +51,22 @@ CONFIG_SCHEMA = (
) )
def to_code(config): async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID]) var = cg.new_Pvariable(config[CONF_ID])
yield cg.register_component(var, config) await cg.register_component(var, config)
yield esp32_ble_tracker.register_ble_device(var, config) await esp32_ble_tracker.register_ble_device(var, config)
cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex)) cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex))
if CONF_TEMPERATURE in config: 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(sens)) cg.add(var.set_temperature(sens))
if CONF_HUMIDITY in config: 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(sens)) cg.add(var.set_humidity(sens))
if CONF_BATTERY_LEVEL in config: if CONF_BATTERY_LEVEL in config:
sens = yield sensor.new_sensor(config[CONF_BATTERY_LEVEL]) sens = await sensor.new_sensor(config[CONF_BATTERY_LEVEL])
cg.add(var.set_battery_level(sens)) cg.add(var.set_battery_level(sens))
if CONF_BATTERY_VOLTAGE in config: if CONF_BATTERY_VOLTAGE in config:
sens = yield sensor.new_sensor(config[CONF_BATTERY_VOLTAGE]) sens = await sensor.new_sensor(config[CONF_BATTERY_VOLTAGE])
cg.add(var.set_battery_voltage(sens)) cg.add(var.set_battery_voltage(sens))

View File

@ -22,7 +22,7 @@ CONFIG_SCHEMA = (
) )
def to_code(config): async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID], config[CONF_HISTORICAL_MODE]) var = cg.new_Pvariable(config[CONF_ID], config[CONF_HISTORICAL_MODE])
yield cg.register_component(var, config) await cg.register_component(var, config)
yield uart.register_uart_device(var, config) await uart.register_uart_device(var, config)

View File

@ -18,9 +18,9 @@ CONFIG_SCHEMA = sensor.sensor_schema(UNIT_WATT_HOURS, ICON_FLASH, 0).extend(
) )
def to_code(config): async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID], config[CONF_TAG_NAME]) var = cg.new_Pvariable(config[CONF_ID], config[CONF_TAG_NAME])
yield cg.register_component(var, config) await cg.register_component(var, config)
yield sensor.register_sensor(var, config) await sensor.register_sensor(var, config)
teleinfo = yield cg.get_variable(config[CONF_TELEINFO_ID]) teleinfo = await cg.get_variable(config[CONF_TELEINFO_ID])
cg.add(teleinfo.register_teleinfo_listener(var)) cg.add(teleinfo.register_teleinfo_listener(var))

View File

@ -20,9 +20,9 @@ CONFIG_SCHEMA = text_sensor.TEXT_SENSOR_SCHEMA.extend(
) )
def to_code(config): async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID], config[CONF_TAG_NAME]) var = cg.new_Pvariable(config[CONF_ID], config[CONF_TAG_NAME])
yield cg.register_component(var, config) await cg.register_component(var, config)
yield text_sensor.register_text_sensor(var, config) await text_sensor.register_text_sensor(var, config)
teleinfo = yield cg.get_variable(config[CONF_TELEINFO_ID]) teleinfo = await cg.get_variable(config[CONF_TELEINFO_ID])
cg.add(teleinfo.register_teleinfo_listener(var)) cg.add(teleinfo.register_teleinfo_listener(var))