From 2376a2c941002c2d5eef1bc487f7f589348e4932 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Mon, 24 May 2021 10:58:29 +0200 Subject: [PATCH] Convert components to async-def syntax (#1821) --- esphome/components/a4988/stepper.py | 12 +- esphome/components/ac_dimmer/output.py | 10 +- esphome/components/adc/sensor.py | 6 +- .../components/addressable_light/display.py | 12 +- esphome/components/ade7953/sensor.py | 8 +- esphome/components/ads1115/__init__.py | 6 +- esphome/components/ads1115/sensor.py | 8 +- esphome/components/aht10/sensor.py | 10 +- esphome/components/am2320/sensor.py | 10 +- esphome/components/animation/__init__.py | 2 +- esphome/components/apds9960/__init__.py | 6 +- esphome/components/apds9960/binary_sensor.py | 6 +- esphome/components/apds9960/sensor.py | 6 +- esphome/components/as3935/binary_sensor.py | 6 +- esphome/components/as3935/sensor.py | 8 +- esphome/components/as3935_i2c/__init__.py | 6 +- esphome/components/as3935_spi/__init__.py | 6 +- .../components/atc_mithermometer/sensor.py | 14 +- esphome/components/atm90e32/sensor.py | 24 +-- esphome/components/b_parasite/sensor.py | 8 +- esphome/components/bang_bang/climate.py | 14 +- esphome/components/bh1750/sensor.py | 8 +- esphome/components/binary/fan/__init__.py | 12 +- esphome/components/binary/light/__init__.py | 6 +- .../components/binary_sensor_map/sensor.py | 8 +- esphome/components/ble_client/__init__.py | 10 +- .../components/ble_client/sensor/__init__.py | 12 +- .../components/ble_client/switch/__init__.py | 8 +- .../components/ble_presence/binary_sensor.py | 8 +- esphome/components/ble_rssi/sensor.py | 8 +- esphome/components/ble_scanner/text_sensor.py | 8 +- esphome/components/bme280/sensor.py | 12 +- esphome/components/bme680/sensor.py | 14 +- esphome/components/bme680_bsec/__init__.py | 6 +- esphome/components/bme680_bsec/sensor.py | 6 +- esphome/components/bme680_bsec/text_sensor.py | 6 +- esphome/components/bmp085/sensor.py | 10 +- esphome/components/bmp280/sensor.py | 10 +- esphome/components/ccs811/sensor.py | 14 +- esphome/components/climate_ir_lg/climate.py | 4 +- esphome/components/color/__init__.py | 2 +- esphome/components/coolix/climate.py | 4 +- esphome/components/cse7766/sensor.py | 12 +- esphome/components/ct_clamp/sensor.py | 8 +- .../custom/binary_sensor/__init__.py | 6 +- esphome/components/custom/climate/__init__.py | 6 +- esphome/components/custom/cover/__init__.py | 6 +- esphome/components/custom/light/__init__.py | 6 +- esphome/components/custom/output/__init__.py | 6 +- esphome/components/custom/sensor/__init__.py | 6 +- esphome/components/custom/switch/__init__.py | 6 +- .../components/custom/text_sensor/__init__.py | 6 +- .../components/custom_component/__init__.py | 6 +- esphome/components/cwww/light.py | 8 +- esphome/components/daikin/climate.py | 4 +- esphome/components/dallas/__init__.py | 6 +- esphome/components/dallas/sensor.py | 6 +- esphome/components/debug/__init__.py | 4 +- esphome/components/deep_sleep/__init__.py | 6 +- esphome/components/dfplayer/__init__.py | 8 +- esphome/components/dht/sensor.py | 10 +- esphome/components/dht12/sensor.py | 10 +- esphome/components/ds1307/time.py | 8 +- esphome/components/duty_cycle/sensor.py | 8 +- esphome/components/e131/__init__.py | 4 +- esphome/components/endstop/cover.py | 16 +- .../components/esp32_ble_beacon/__init__.py | 4 +- .../components/esp32_ble_tracker/__init__.py | 10 +- esphome/components/esp32_camera/__init__.py | 4 +- esphome/components/esp32_dac/output.py | 8 +- esphome/components/esp32_hall/sensor.py | 6 +- esphome/components/esp32_touch/__init__.py | 4 +- .../components/esp32_touch/binary_sensor.py | 6 +- esphome/components/esp8266_pwm/output.py | 8 +- esphome/components/ethernet/__init__.py | 6 +- .../exposure_notifications/__init__.py | 6 +- .../external_components/__init__.py | 2 +- esphome/components/ezo/sensor.py | 8 +- esphome/components/fastled_clockless/light.py | 4 +- esphome/components/fastled_spi/light.py | 4 +- .../components/fingerprint_grow/__init__.py | 18 +- .../fingerprint_grow/binary_sensor.py | 6 +- esphome/components/fingerprint_grow/sensor.py | 6 +- esphome/components/font/__init__.py | 2 +- esphome/components/fujitsu_general/climate.py | 4 +- .../components/gpio/binary_sensor/__init__.py | 8 +- esphome/components/gpio/output/__init__.py | 8 +- esphome/components/gpio/switch/__init__.py | 10 +- esphome/components/gps/__init__.py | 18 +- esphome/components/gps/time/__init__.py | 8 +- esphome/components/hbridge/light.py | 10 +- esphome/components/hdc1080/sensor.py | 10 +- esphome/components/hitachi_ac344/climate.py | 4 +- esphome/components/hlw8012/sensor.py | 18 +- esphome/components/hm3301/sensor.py | 14 +- esphome/components/hmc5883l/sensor.py | 14 +- .../homeassistant/binary_sensor/__init__.py | 6 +- .../homeassistant/sensor/__init__.py | 6 +- .../homeassistant/text_sensor/__init__.py | 6 +- .../components/homeassistant/time/__init__.py | 6 +- esphome/components/http_request/__init__.py | 4 +- esphome/components/htu21d/sensor.py | 10 +- esphome/components/hx711/sensor.py | 10 +- esphome/components/ili9341/display.py | 16 +- esphome/components/image/__init__.py | 2 +- esphome/components/ina219/sensor.py | 14 +- esphome/components/ina226/sensor.py | 14 +- esphome/components/ina3221/sensor.py | 14 +- .../components/inkbird_ibsth1_mini/sensor.py | 12 +- esphome/components/inkplate6/display.py | 48 ++--- esphome/components/integration/sensor.py | 8 +- esphome/components/interval/__init__.py | 6 +- esphome/components/lcd_gpio/display.py | 14 +- esphome/components/lcd_pcf8574/display.py | 8 +- esphome/components/ledc/output.py | 8 +- esphome/components/max31855/sensor.py | 10 +- esphome/components/max31856/sensor.py | 8 +- esphome/components/max31865/sensor.py | 8 +- esphome/components/max6675/sensor.py | 8 +- esphome/components/max7219/display.py | 10 +- esphome/components/max7219digit/display.py | 10 +- esphome/components/mcp23008/__init__.py | 6 +- esphome/components/mcp23016/__init__.py | 6 +- esphome/components/mcp23017/__init__.py | 6 +- esphome/components/mcp23s08/__init__.py | 6 +- esphome/components/mcp23s17/__init__.py | 6 +- esphome/components/mcp2515/canbus.py | 6 +- esphome/components/mcp3008/__init__.py | 6 +- esphome/components/mcp3008/sensor.py | 8 +- esphome/components/mcp4725/output.py | 8 +- esphome/components/mcp9808/sensor.py | 8 +- esphome/components/mhz19/sensor.py | 10 +- esphome/components/midea_ac/climate.py | 14 +- esphome/components/midea_dongle/__init__.py | 6 +- esphome/components/mitsubishi/climate.py | 4 +- esphome/components/modbus/__init__.py | 6 +- esphome/components/monochromatic/light.py | 6 +- esphome/components/mpr121/__init__.py | 6 +- esphome/components/mpr121/binary_sensor.py | 6 +- esphome/components/mpu6050/sensor.py | 12 +- .../mqtt_subscribe/sensor/__init__.py | 8 +- .../mqtt_subscribe/text_sensor/__init__.py | 8 +- esphome/components/ms5611/sensor.py | 10 +- esphome/components/my9231/__init__.py | 8 +- esphome/components/my9231/output.py | 6 +- esphome/components/neopixelbus/light.py | 6 +- esphome/components/nextion/binary_sensor.py | 6 +- esphome/components/nextion/display.py | 10 +- esphome/components/ntc/sensor.py | 8 +- esphome/components/output/__init__.py | 2 +- esphome/components/output/switch/__init__.py | 8 +- esphome/components/partition/light.py | 8 +- esphome/components/pca9685/__init__.py | 6 +- esphome/components/pca9685/output.py | 6 +- esphome/components/pcd8544/display.py | 14 +- esphome/components/pcf8574/__init__.py | 6 +- esphome/components/pid/climate.py | 12 +- esphome/components/pid/sensor/__init__.py | 8 +- esphome/components/pmsx003/sensor.py | 18 +- esphome/components/pn532/binary_sensor.py | 6 +- esphome/components/pn532_i2c/__init__.py | 6 +- esphome/components/pn532_spi/__init__.py | 6 +- esphome/components/power_supply/__init__.py | 6 +- esphome/components/prometheus/__init__.py | 6 +- esphome/components/pulse_counter/sensor.py | 10 +- esphome/components/pulse_meter/sensor.py | 10 +- esphome/components/pulse_width/sensor.py | 8 +- esphome/components/pzem004t/sensor.py | 14 +- esphome/components/pzemac/sensor.py | 18 +- esphome/components/pzemdc/sensor.py | 12 +- esphome/components/qmc5883l/sensor.py | 14 +- esphome/components/rc522/binary_sensor.py | 9 +- esphome/components/rc522_i2c/__init__.py | 6 +- esphome/components/rc522_spi/__init__.py | 6 +- esphome/components/rc522_spi/binary_sensor.py | 4 +- esphome/components/rdm6300/__init__.py | 8 +- esphome/components/rdm6300/binary_sensor.py | 6 +- .../components/remote_receiver/__init__.py | 10 +- .../remote_receiver/binary_sensor.py | 6 +- .../components/remote_transmitter/__init__.py | 6 +- esphome/components/resistance/sensor.py | 8 +- esphome/components/restart/switch.py | 6 +- esphome/components/rf_bridge/__init__.py | 10 +- esphome/components/rgb/light.py | 10 +- esphome/components/rgbw/light.py | 12 +- esphome/components/rgbww/light.py | 14 +- esphome/components/rotary_encoder/sensor.py | 16 +- esphome/components/rtttl/__init__.py | 8 +- esphome/components/ruuvi_ble/__init__.py | 4 +- esphome/components/ruuvitag/sensor.py | 28 +-- esphome/components/scd30/sensor.py | 12 +- esphome/components/script/__init__.py | 6 +- esphome/components/sds011/sensor.py | 10 +- esphome/components/senseair/sensor.py | 8 +- esphome/components/servo/__init__.py | 6 +- esphome/components/sgp30/sensor.py | 14 +- esphome/components/sgp40/sensor.py | 12 +- esphome/components/sht3xd/sensor.py | 10 +- esphome/components/sht4x/sensor.py | 8 +- esphome/components/shtcx/sensor.py | 10 +- esphome/components/shutdown/switch.py | 6 +- esphome/components/sim800l/__init__.py | 8 +- esphome/components/slow_pwm/output.py | 8 +- esphome/components/sm16716/__init__.py | 8 +- esphome/components/sm16716/output.py | 6 +- esphome/components/sm2135/__init__.py | 8 +- esphome/components/sm2135/output.py | 6 +- esphome/components/sm300d2/sensor.py | 20 +- esphome/components/sn74hc595/__init__.py | 12 +- esphome/components/sntp/time.py | 6 +- esphome/components/speed/fan/__init__.py | 12 +- esphome/components/sps30/sensor.py | 26 +-- esphome/components/ssd1306_i2c/display.py | 6 +- esphome/components/ssd1306_spi/display.py | 8 +- esphome/components/ssd1322_spi/display.py | 8 +- esphome/components/ssd1325_spi/display.py | 8 +- esphome/components/ssd1327_i2c/display.py | 6 +- esphome/components/ssd1327_spi/display.py | 8 +- esphome/components/ssd1331_spi/display.py | 8 +- esphome/components/ssd1351_spi/display.py | 8 +- esphome/components/st7735/display.py | 200 +++++++++--------- esphome/components/st7789v/display.py | 16 +- esphome/components/status/binary_sensor.py | 6 +- esphome/components/stepper/__init__.py | 2 +- esphome/components/sts3x/sensor.py | 8 +- esphome/components/substitutions/__init__.py | 2 +- esphome/components/sun/__init__.py | 16 +- esphome/components/sun/sensor/__init__.py | 8 +- .../components/sun/text_sensor/__init__.py | 8 +- esphome/components/sx1509/__init__.py | 6 +- .../sx1509/binary_sensor/__init__.py | 6 +- esphome/components/sx1509/output/__init__.py | 8 +- esphome/components/tca9548a/__init__.py | 6 +- esphome/components/tcl112/climate.py | 4 +- esphome/components/tcs34725/sensor.py | 18 +- esphome/components/teleinfo/sensor.py | 8 +- .../template/binary_sensor/__init__.py | 8 +- esphome/components/template/cover/__init__.py | 20 +- .../components/template/output/__init__.py | 8 +- .../components/template/sensor/__init__.py | 8 +- .../components/template/switch/__init__.py | 12 +- .../template/text_sensor/__init__.py | 8 +- esphome/components/thermostat/climate.py | 56 ++--- esphome/components/time_based/cover.py | 12 +- esphome/components/tlc59208f/__init__.py | 6 +- esphome/components/tlc59208f/output.py | 6 +- esphome/components/tm1637/display.py | 12 +- esphome/components/tm1651/__init__.py | 8 +- esphome/components/tmp102/sensor.py | 8 +- esphome/components/tmp117/sensor.py | 8 +- esphome/components/tof10120/sensor.py | 8 +- esphome/components/toshiba/climate.py | 4 +- .../components/total_daily_energy/sensor.py | 10 +- esphome/components/tsl2561/sensor.py | 8 +- esphome/components/ttp229_bsf/__init__.py | 8 +- .../components/ttp229_bsf/binary_sensor.py | 6 +- esphome/components/ttp229_lsf/__init__.py | 6 +- .../components/ttp229_lsf/binary_sensor.py | 6 +- esphome/components/tuya/__init__.py | 8 +- .../components/tuya/binary_sensor/__init__.py | 8 +- esphome/components/tuya/climate/__init__.py | 8 +- esphome/components/tuya/fan/__init__.py | 8 +- esphome/components/tuya/light/__init__.py | 8 +- esphome/components/tuya/sensor/__init__.py | 8 +- esphome/components/tuya/switch/__init__.py | 8 +- esphome/components/tx20/sensor.py | 10 +- esphome/components/uart/switch/__init__.py | 8 +- esphome/components/uln2003/stepper.py | 14 +- esphome/components/ultrasonic/sensor.py | 10 +- esphome/components/uptime/sensor.py | 6 +- esphome/components/version/text_sensor.py | 6 +- esphome/components/vl53l0x/sensor.py | 10 +- .../components/waveshare_epaper/display.py | 16 +- esphome/components/whirlpool/climate.py | 4 +- esphome/components/wifi_info/text_sensor.py | 10 +- esphome/components/wifi_signal/sensor.py | 6 +- esphome/components/xiaomi_ble/__init__.py | 4 +- esphome/components/xiaomi_cgd1/sensor.py | 12 +- esphome/components/xiaomi_cgg1/sensor.py | 12 +- esphome/components/xiaomi_gcls002/sensor.py | 14 +- esphome/components/xiaomi_hhccjcy01/sensor.py | 16 +- .../components/xiaomi_hhccpot002/sensor.py | 10 +- esphome/components/xiaomi_jqjcy01ym/sensor.py | 14 +- esphome/components/xiaomi_lywsd02/sensor.py | 12 +- .../components/xiaomi_lywsd03mmc/sensor.py | 12 +- esphome/components/xiaomi_lywsdcgq/sensor.py | 12 +- esphome/components/xiaomi_mhoc401/sensor.py | 12 +- esphome/components/xiaomi_miscale/sensor.py | 8 +- esphome/components/xiaomi_miscale2/sensor.py | 10 +- .../xiaomi_mjyd02yla/binary_sensor.py | 16 +- .../xiaomi_mue4094rt/binary_sensor.py | 8 +- .../components/xiaomi_wx08zm/binary_sensor.py | 12 +- esphome/components/xpt2046/__init__.py | 10 +- esphome/components/xpt2046/binary_sensor.py | 6 +- esphome/components/yashima/climate.py | 10 +- esphome/components/zyaura/sensor.py | 14 +- 296 files changed, 1423 insertions(+), 1424 deletions(-) diff --git a/esphome/components/a4988/stepper.py b/esphome/components/a4988/stepper.py index 1de3562ff7..7f53856c7b 100644 --- a/esphome/components/a4988/stepper.py +++ b/esphome/components/a4988/stepper.py @@ -18,16 +18,16 @@ CONFIG_SCHEMA = stepper.STEPPER_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield stepper.register_stepper(var, config) + await cg.register_component(var, config) + await stepper.register_stepper(var, config) - step_pin = yield cg.gpio_pin_expression(config[CONF_STEP_PIN]) + step_pin = await cg.gpio_pin_expression(config[CONF_STEP_PIN]) cg.add(var.set_step_pin(step_pin)) - dir_pin = yield cg.gpio_pin_expression(config[CONF_DIR_PIN]) + dir_pin = await cg.gpio_pin_expression(config[CONF_DIR_PIN]) cg.add(var.set_dir_pin(dir_pin)) if CONF_SLEEP_PIN in config: - sleep_pin = yield cg.gpio_pin_expression(config[CONF_SLEEP_PIN]) + sleep_pin = await cg.gpio_pin_expression(config[CONF_SLEEP_PIN]) cg.add(var.set_sleep_pin(sleep_pin)) diff --git a/esphome/components/ac_dimmer/output.py b/esphome/components/ac_dimmer/output.py index 2f06a0b6fc..2c37d325eb 100644 --- a/esphome/components/ac_dimmer/output.py +++ b/esphome/components/ac_dimmer/output.py @@ -32,18 +32,18 @@ CONFIG_SCHEMA = output.FLOAT_OUTPUT_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -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) # override default min power to 10% if CONF_MIN_POWER not in config: config[CONF_MIN_POWER] = 0.1 - yield output.register_output(var, config) + await output.register_output(var, config) - pin = yield cg.gpio_pin_expression(config[CONF_GATE_PIN]) + pin = await cg.gpio_pin_expression(config[CONF_GATE_PIN]) cg.add(var.set_gate_pin(pin)) - pin = yield cg.gpio_pin_expression(config[CONF_ZERO_CROSS_PIN]) + pin = await cg.gpio_pin_expression(config[CONF_ZERO_CROSS_PIN]) cg.add(var.set_zero_cross_pin(pin)) cg.add(var.set_init_with_half_cycle(config[CONF_INIT_WITH_HALF_CYCLE])) cg.add(var.set_method(config[CONF_METHOD])) diff --git a/esphome/components/adc/sensor.py b/esphome/components/adc/sensor.py index 2e36c6179a..f988563227 100644 --- a/esphome/components/adc/sensor.py +++ b/esphome/components/adc/sensor.py @@ -49,10 +49,10 @@ CONFIG_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) if config[CONF_PIN] == "VCC": cg.add_define("USE_ADC_SENSOR_VCC") diff --git a/esphome/components/addressable_light/display.py b/esphome/components/addressable_light/display.py index e5d3ca3034..0684bf8dfc 100644 --- a/esphome/components/addressable_light/display.py +++ b/esphome/components/addressable_light/display.py @@ -38,18 +38,18 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - wrapped_light = yield cg.get_variable(config[CONF_ADDRESSABLE_LIGHT_ID]) + wrapped_light = await cg.get_variable(config[CONF_ADDRESSABLE_LIGHT_ID]) cg.add(var.set_width(config[CONF_WIDTH])) cg.add(var.set_height(config[CONF_HEIGHT])) cg.add(var.set_light(wrapped_light)) - yield cg.register_component(var, config) - yield display.register_display(var, config) + await cg.register_component(var, config) + await display.register_display(var, config) if CONF_PIXEL_MAPPER in config: - pixel_mapper_template_ = yield cg.process_lambda( + pixel_mapper_template_ = await cg.process_lambda( config[CONF_PIXEL_MAPPER], [(int, "x"), (int, "y")], return_type=cg.int_, @@ -57,7 +57,7 @@ def to_code(config): cg.add(var.set_pixel_mapper(pixel_mapper_template_)) if CONF_LAMBDA in config: - lambda_ = yield cg.process_lambda( + lambda_ = await cg.process_lambda( config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void ) cg.add(var.set_writer(lambda_)) diff --git a/esphome/components/ade7953/sensor.py b/esphome/components/ade7953/sensor.py index 6bc9917806..b91e8d3bea 100644 --- a/esphome/components/ade7953/sensor.py +++ b/esphome/components/ade7953/sensor.py @@ -52,10 +52,10 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) if CONF_IRQ_PIN in config: cg.add(var.set_irq_pin(config[CONF_IRQ_PIN])) @@ -70,5 +70,5 @@ def to_code(config): if key not in config: continue conf = config[key] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(getattr(var, f"set_{key}_sensor")(sens)) diff --git a/esphome/components/ads1115/__init__.py b/esphome/components/ads1115/__init__.py index 32ab17db31..e8861a2f67 100644 --- a/esphome/components/ads1115/__init__.py +++ b/esphome/components/ads1115/__init__.py @@ -23,9 +23,9 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) cg.add(var.set_continuous_mode(config[CONF_CONTINUOUS_MODE])) diff --git a/esphome/components/ads1115/sensor.py b/esphome/components/ads1115/sensor.py index 6eb39bdd1a..4585a758b5 100644 --- a/esphome/components/ads1115/sensor.py +++ b/esphome/components/ads1115/sensor.py @@ -64,11 +64,11 @@ CONFIG_SCHEMA = ( ) -def to_code(config): - paren = yield cg.get_variable(config[CONF_ADS1115_ID]) +async def to_code(config): + paren = await cg.get_variable(config[CONF_ADS1115_ID]) var = cg.new_Pvariable(config[CONF_ID], paren) - yield sensor.register_sensor(var, config) - yield cg.register_component(var, config) + await sensor.register_sensor(var, config) + await cg.register_component(var, config) cg.add(var.set_multiplexer(config[CONF_MULTIPLEXER])) cg.add(var.set_gain(config[CONF_GAIN])) diff --git a/esphome/components/aht10/sensor.py b/esphome/components/aht10/sensor.py index e335934a8e..2e553638d1 100644 --- a/esphome/components/aht10/sensor.py +++ b/esphome/components/aht10/sensor.py @@ -34,15 +34,15 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, 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_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)) diff --git a/esphome/components/am2320/sensor.py b/esphome/components/am2320/sensor.py index 6d1cc42581..c0a6a60437 100644 --- a/esphome/components/am2320/sensor.py +++ b/esphome/components/am2320/sensor.py @@ -36,15 +36,15 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, 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_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)) diff --git a/esphome/components/animation/__init__.py b/esphome/components/animation/__init__.py index fbcb2b4c1f..3ae3aa94f9 100644 --- a/esphome/components/animation/__init__.py +++ b/esphome/components/animation/__init__.py @@ -34,7 +34,7 @@ CONFIG_SCHEMA = cv.All(font.validate_pillow_installed, ANIMATION_SCHEMA) CODEOWNERS = ["@syndlex"] -def to_code(config): +async def to_code(config): from PIL import Image path = CORE.relative_config_path(config[CONF_FILE]) diff --git a/esphome/components/apds9960/__init__.py b/esphome/components/apds9960/__init__.py index 9346b5ece1..8de83251b7 100644 --- a/esphome/components/apds9960/__init__.py +++ b/esphome/components/apds9960/__init__.py @@ -23,7 +23,7 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) diff --git a/esphome/components/apds9960/binary_sensor.py b/esphome/components/apds9960/binary_sensor.py index 0433061385..4a5c69f6a9 100644 --- a/esphome/components/apds9960/binary_sensor.py +++ b/esphome/components/apds9960/binary_sensor.py @@ -24,8 +24,8 @@ CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend( ) -def to_code(config): - hub = yield cg.get_variable(config[CONF_APDS9960_ID]) - var = yield binary_sensor.new_binary_sensor(config) +async def to_code(config): + hub = await cg.get_variable(config[CONF_APDS9960_ID]) + var = await binary_sensor.new_binary_sensor(config) func = getattr(hub, DIRECTIONS[config[CONF_DIRECTION]]) cg.add(func(var)) diff --git a/esphome/components/apds9960/sensor.py b/esphome/components/apds9960/sensor.py index a1ebd9b5c3..53633693a2 100644 --- a/esphome/components/apds9960/sensor.py +++ b/esphome/components/apds9960/sensor.py @@ -24,8 +24,8 @@ CONFIG_SCHEMA = sensor.sensor_schema( ) -def to_code(config): - hub = yield cg.get_variable(config[CONF_APDS9960_ID]) - var = yield sensor.new_sensor(config) +async def to_code(config): + hub = await cg.get_variable(config[CONF_APDS9960_ID]) + var = await sensor.new_sensor(config) func = getattr(hub, TYPES[config[CONF_TYPE]]) cg.add(func(var)) diff --git a/esphome/components/as3935/binary_sensor.py b/esphome/components/as3935/binary_sensor.py index 85ba052869..11b2ac812c 100644 --- a/esphome/components/as3935/binary_sensor.py +++ b/esphome/components/as3935/binary_sensor.py @@ -12,7 +12,7 @@ CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend( ) -def to_code(config): - hub = yield cg.get_variable(config[CONF_AS3935_ID]) - var = yield binary_sensor.new_binary_sensor(config) +async def to_code(config): + hub = await cg.get_variable(config[CONF_AS3935_ID]) + var = await binary_sensor.new_binary_sensor(config) cg.add(hub.set_thunder_alert_binary_sensor(var)) diff --git a/esphome/components/as3935/sensor.py b/esphome/components/as3935/sensor.py index 64eeea7b04..6afe890d65 100644 --- a/esphome/components/as3935/sensor.py +++ b/esphome/components/as3935/sensor.py @@ -27,15 +27,15 @@ CONFIG_SCHEMA = cv.Schema( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): - hub = yield cg.get_variable(config[CONF_AS3935_ID]) +async def to_code(config): + hub = await cg.get_variable(config[CONF_AS3935_ID]) if CONF_DISTANCE in config: conf = config[CONF_DISTANCE] - distance_sensor = yield sensor.new_sensor(conf) + distance_sensor = await sensor.new_sensor(conf) cg.add(hub.set_distance_sensor(distance_sensor)) if CONF_LIGHTNING_ENERGY in config: conf = config[CONF_LIGHTNING_ENERGY] - lightning_energy_sensor = yield sensor.new_sensor(conf) + lightning_energy_sensor = await sensor.new_sensor(conf) cg.add(hub.set_energy_sensor(lightning_energy_sensor)) diff --git a/esphome/components/as3935_i2c/__init__.py b/esphome/components/as3935_i2c/__init__.py index 277ccd84d3..aa741b2ea6 100644 --- a/esphome/components/as3935_i2c/__init__.py +++ b/esphome/components/as3935_i2c/__init__.py @@ -20,7 +20,7 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield as3935.setup_as3935(var, config) - yield i2c.register_i2c_device(var, config) + await as3935.setup_as3935(var, config) + await i2c.register_i2c_device(var, config) diff --git a/esphome/components/as3935_spi/__init__.py b/esphome/components/as3935_spi/__init__.py index b921444b8b..849539f092 100644 --- a/esphome/components/as3935_spi/__init__.py +++ b/esphome/components/as3935_spi/__init__.py @@ -20,7 +20,7 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield as3935.setup_as3935(var, config) - yield spi.register_spi_device(var, config) + await as3935.setup_as3935(var, config) + await spi.register_spi_device(var, config) diff --git a/esphome/components/atc_mithermometer/sensor.py b/esphome/components/atc_mithermometer/sensor.py index 51891b33cb..161f1f021b 100644 --- a/esphome/components/atc_mithermometer/sensor.py +++ b/esphome/components/atc_mithermometer/sensor.py @@ -51,22 +51,22 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield esp32_ble_tracker.register_ble_device(var, config) + await cg.register_component(var, config) + await esp32_ble_tracker.register_ble_device(var, config) cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex)) 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)) 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)) 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)) 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)) diff --git a/esphome/components/atm90e32/sensor.py b/esphome/components/atm90e32/sensor.py index 4a9100d9d6..b0e43559f9 100644 --- a/esphome/components/atm90e32/sensor.py +++ b/esphome/components/atm90e32/sensor.py @@ -113,10 +113,10 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield spi.register_spi_device(var, config) + await cg.register_component(var, config) + await spi.register_spi_device(var, config) for i, phase in enumerate([CONF_PHASE_A, CONF_PHASE_B, CONF_PHASE_C]): if phase not in config: @@ -125,31 +125,31 @@ def to_code(config): cg.add(var.set_volt_gain(i, conf[CONF_GAIN_VOLTAGE])) cg.add(var.set_ct_gain(i, conf[CONF_GAIN_CT])) if CONF_VOLTAGE in conf: - sens = yield sensor.new_sensor(conf[CONF_VOLTAGE]) + sens = await sensor.new_sensor(conf[CONF_VOLTAGE]) cg.add(var.set_voltage_sensor(i, sens)) if CONF_CURRENT in conf: - sens = yield sensor.new_sensor(conf[CONF_CURRENT]) + sens = await sensor.new_sensor(conf[CONF_CURRENT]) cg.add(var.set_current_sensor(i, sens)) if CONF_POWER in conf: - sens = yield sensor.new_sensor(conf[CONF_POWER]) + sens = await sensor.new_sensor(conf[CONF_POWER]) cg.add(var.set_power_sensor(i, sens)) if CONF_REACTIVE_POWER in conf: - sens = yield sensor.new_sensor(conf[CONF_REACTIVE_POWER]) + sens = await sensor.new_sensor(conf[CONF_REACTIVE_POWER]) cg.add(var.set_reactive_power_sensor(i, sens)) if CONF_POWER_FACTOR in conf: - sens = yield sensor.new_sensor(conf[CONF_POWER_FACTOR]) + sens = await sensor.new_sensor(conf[CONF_POWER_FACTOR]) cg.add(var.set_power_factor_sensor(i, sens)) if CONF_FORWARD_ACTIVE_ENERGY in conf: - sens = yield sensor.new_sensor(conf[CONF_FORWARD_ACTIVE_ENERGY]) + sens = await sensor.new_sensor(conf[CONF_FORWARD_ACTIVE_ENERGY]) cg.add(var.set_forward_active_energy_sensor(i, sens)) if CONF_REVERSE_ACTIVE_ENERGY in conf: - sens = yield sensor.new_sensor(conf[CONF_REVERSE_ACTIVE_ENERGY]) + sens = await sensor.new_sensor(conf[CONF_REVERSE_ACTIVE_ENERGY]) cg.add(var.set_reverse_active_energy_sensor(i, sens)) if CONF_FREQUENCY in config: - sens = yield sensor.new_sensor(config[CONF_FREQUENCY]) + sens = await sensor.new_sensor(config[CONF_FREQUENCY]) cg.add(var.set_freq_sensor(sens)) if CONF_CHIP_TEMPERATURE in config: - sens = yield sensor.new_sensor(config[CONF_CHIP_TEMPERATURE]) + sens = await sensor.new_sensor(config[CONF_CHIP_TEMPERATURE]) cg.add(var.set_chip_temperature_sensor(sens)) cg.add(var.set_line_freq(config[CONF_LINE_FREQUENCY])) cg.add(var.set_current_phases(config[CONF_CURRENT_PHASES])) diff --git a/esphome/components/b_parasite/sensor.py b/esphome/components/b_parasite/sensor.py index d90ea84cd3..415cae454f 100644 --- a/esphome/components/b_parasite/sensor.py +++ b/esphome/components/b_parasite/sensor.py @@ -50,10 +50,10 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield esp32_ble_tracker.register_ble_device(var, config) + await cg.register_component(var, config) + await esp32_ble_tracker.register_ble_device(var, config) cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex)) @@ -64,5 +64,5 @@ def to_code(config): (CONF_MOISTURE, var.set_soil_moisture), ]: if config_key in config: - sens = yield sensor.new_sensor(config[config_key]) + sens = await sensor.new_sensor(config[config_key]) cg.add(setter(sens)) diff --git a/esphome/components/bang_bang/climate.py b/esphome/components/bang_bang/climate.py index e0d75a6a1e..5c935987de 100644 --- a/esphome/components/bang_bang/climate.py +++ b/esphome/components/bang_bang/climate.py @@ -39,12 +39,12 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield climate.register_climate(var, config) + await cg.register_component(var, config) + await climate.register_climate(var, config) - sens = yield cg.get_variable(config[CONF_SENSOR]) + sens = await cg.get_variable(config[CONF_SENSOR]) cg.add(var.set_sensor(sens)) normal_config = BangBangClimateTargetTempConfig( @@ -53,17 +53,17 @@ def to_code(config): ) cg.add(var.set_normal_config(normal_config)) - yield automation.build_automation( + await automation.build_automation( var.get_idle_trigger(), [], config[CONF_IDLE_ACTION] ) if CONF_COOL_ACTION in config: - yield automation.build_automation( + await automation.build_automation( var.get_cool_trigger(), [], config[CONF_COOL_ACTION] ) cg.add(var.set_supports_cool(True)) if CONF_HEAT_ACTION in config: - yield automation.build_automation( + await automation.build_automation( var.get_heat_trigger(), [], config[CONF_HEAT_ACTION] ) cg.add(var.set_supports_heat(True)) diff --git a/esphome/components/bh1750/sensor.py b/esphome/components/bh1750/sensor.py index 0e37b2b865..6c3c20d9c4 100644 --- a/esphome/components/bh1750/sensor.py +++ b/esphome/components/bh1750/sensor.py @@ -46,11 +46,11 @@ CONFIG_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) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await sensor.register_sensor(var, config) + await i2c.register_i2c_device(var, config) cg.add(var.set_resolution(config[CONF_RESOLUTION])) cg.add(var.set_measurement_duration(config[CONF_MEASUREMENT_DURATION])) diff --git a/esphome/components/binary/fan/__init__.py b/esphome/components/binary/fan/__init__.py index 88dc506235..e6c8d9bfe9 100644 --- a/esphome/components/binary/fan/__init__.py +++ b/esphome/components/binary/fan/__init__.py @@ -21,19 +21,19 @@ CONFIG_SCHEMA = fan.FAN_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_OUTPUT_ID]) - yield cg.register_component(var, config) + await cg.register_component(var, config) - fan_ = yield fan.create_fan_state(config) + fan_ = await fan.create_fan_state(config) cg.add(var.set_fan(fan_)) - output_ = yield cg.get_variable(config[CONF_OUTPUT]) + output_ = await cg.get_variable(config[CONF_OUTPUT]) cg.add(var.set_output(output_)) if CONF_OSCILLATION_OUTPUT in config: - oscillation_output = yield cg.get_variable(config[CONF_OSCILLATION_OUTPUT]) + oscillation_output = await cg.get_variable(config[CONF_OSCILLATION_OUTPUT]) cg.add(var.set_oscillating(oscillation_output)) if CONF_DIRECTION_OUTPUT in config: - direction_output = yield cg.get_variable(config[CONF_DIRECTION_OUTPUT]) + direction_output = await cg.get_variable(config[CONF_DIRECTION_OUTPUT]) cg.add(var.set_direction(direction_output)) diff --git a/esphome/components/binary/light/__init__.py b/esphome/components/binary/light/__init__.py index 7e62f4705f..49227ccadc 100644 --- a/esphome/components/binary/light/__init__.py +++ b/esphome/components/binary/light/__init__.py @@ -14,9 +14,9 @@ CONFIG_SCHEMA = light.BINARY_LIGHT_SCHEMA.extend( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_OUTPUT_ID]) - yield light.register_light(var, config) + await light.register_light(var, config) - out = yield cg.get_variable(config[CONF_OUTPUT]) + out = await cg.get_variable(config[CONF_OUTPUT]) cg.add(var.set_output(out)) diff --git a/esphome/components/binary_sensor_map/sensor.py b/esphome/components/binary_sensor_map/sensor.py index 81bc85e570..406a1b7bd1 100644 --- a/esphome/components/binary_sensor_map/sensor.py +++ b/esphome/components/binary_sensor_map/sensor.py @@ -48,14 +48,14 @@ CONFIG_SCHEMA = cv.typed_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) constant = SENSOR_MAP_TYPES[config[CONF_TYPE]] cg.add(var.set_sensor_type(constant)) for ch in config[CONF_CHANNELS]: - input_var = yield cg.get_variable(ch[CONF_BINARY_SENSOR]) + input_var = await cg.get_variable(ch[CONF_BINARY_SENSOR]) cg.add(var.add_channel(input_var, ch[CONF_VALUE])) diff --git a/esphome/components/ble_client/__init__.py b/esphome/components/ble_client/__init__.py index d3b287574b..b3ba8c2a47 100644 --- a/esphome/components/ble_client/__init__.py +++ b/esphome/components/ble_client/__init__.py @@ -74,14 +74,14 @@ def register_ble_node(var, config): cg.add(parent.register_ble_node(var)) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield esp32_ble_tracker.register_client(var, config) + await cg.register_component(var, config) + await esp32_ble_tracker.register_client(var, config) cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex)) for conf in config.get(CONF_ON_CONNECT, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) - yield automation.build_automation(trigger, [], conf) + await automation.build_automation(trigger, [], conf) for conf in config.get(CONF_ON_DISCONNECT, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) - yield automation.build_automation(trigger, [], conf) + await automation.build_automation(trigger, [], conf) diff --git a/esphome/components/ble_client/sensor/__init__.py b/esphome/components/ble_client/sensor/__init__.py index 27eca87a37..a7ab0acd73 100644 --- a/esphome/components/ble_client/sensor/__init__.py +++ b/esphome/components/ble_client/sensor/__init__.py @@ -50,7 +50,7 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) if len(config[CONF_SERVICE_UUID]) == len(esp32_ble_tracker.bt_uuid16_format): cg.add( @@ -105,11 +105,11 @@ def to_code(config): uuid128 = esp32_ble_tracker.as_hex_array(config[CONF_DESCRIPTOR_UUID]) cg.add(var.set_descr_uuid128(uuid128)) - yield cg.register_component(var, config) - yield ble_client.register_ble_node(var, config) + await cg.register_component(var, config) + await ble_client.register_ble_node(var, config) cg.add(var.set_enable_notify(config[CONF_NOTIFY])) - yield sensor.register_sensor(var, config) + await sensor.register_sensor(var, config) for conf in config.get(CONF_ON_NOTIFY, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) - yield ble_client.register_ble_node(trigger, config) - yield automation.build_automation(trigger, [(float, "x")], conf) + await ble_client.register_ble_node(trigger, config) + await automation.build_automation(trigger, [(float, "x")], conf) diff --git a/esphome/components/ble_client/switch/__init__.py b/esphome/components/ble_client/switch/__init__.py index acc8683407..e5b5ab281b 100644 --- a/esphome/components/ble_client/switch/__init__.py +++ b/esphome/components/ble_client/switch/__init__.py @@ -23,8 +23,8 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield switch.register_switch(var, config) - yield ble_client.register_ble_node(var, config) + await cg.register_component(var, config) + await switch.register_switch(var, config) + await ble_client.register_ble_node(var, config) diff --git a/esphome/components/ble_presence/binary_sensor.py b/esphome/components/ble_presence/binary_sensor.py index 4c6e7ee567..c58d29e6be 100644 --- a/esphome/components/ble_presence/binary_sensor.py +++ b/esphome/components/ble_presence/binary_sensor.py @@ -27,11 +27,11 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield esp32_ble_tracker.register_ble_device(var, config) - yield binary_sensor.register_binary_sensor(var, config) + await cg.register_component(var, config) + await esp32_ble_tracker.register_ble_device(var, config) + await binary_sensor.register_binary_sensor(var, config) if CONF_MAC_ADDRESS in config: cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex)) diff --git a/esphome/components/ble_rssi/sensor.py b/esphome/components/ble_rssi/sensor.py index f6ee209ae1..279fc4ae19 100644 --- a/esphome/components/ble_rssi/sensor.py +++ b/esphome/components/ble_rssi/sensor.py @@ -32,11 +32,11 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield esp32_ble_tracker.register_ble_device(var, config) - yield sensor.register_sensor(var, config) + await cg.register_component(var, config) + await esp32_ble_tracker.register_ble_device(var, config) + await sensor.register_sensor(var, config) if CONF_MAC_ADDRESS in config: cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex)) diff --git a/esphome/components/ble_scanner/text_sensor.py b/esphome/components/ble_scanner/text_sensor.py index 96c7b4d887..0e140aa701 100644 --- a/esphome/components/ble_scanner/text_sensor.py +++ b/esphome/components/ble_scanner/text_sensor.py @@ -24,8 +24,8 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield esp32_ble_tracker.register_ble_device(var, config) - yield text_sensor.register_text_sensor(var, config) + await cg.register_component(var, config) + await esp32_ble_tracker.register_ble_device(var, config) + await text_sensor.register_text_sensor(var, config) diff --git a/esphome/components/bme280/sensor.py b/esphome/components/bme280/sensor.py index 5b0e418a66..2b1b8825f8 100644 --- a/esphome/components/bme280/sensor.py +++ b/esphome/components/bme280/sensor.py @@ -84,26 +84,26 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) if CONF_TEMPERATURE in config: conf = config[CONF_TEMPERATURE] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_temperature_sensor(sens)) cg.add(var.set_temperature_oversampling(conf[CONF_OVERSAMPLING])) if CONF_PRESSURE in config: conf = config[CONF_PRESSURE] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_pressure_sensor(sens)) cg.add(var.set_pressure_oversampling(conf[CONF_OVERSAMPLING])) if CONF_HUMIDITY in config: conf = config[CONF_HUMIDITY] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_humidity_sensor(sens)) cg.add(var.set_humidity_oversampling(conf[CONF_OVERSAMPLING])) diff --git a/esphome/components/bme680/sensor.py b/esphome/components/bme680/sensor.py index a82ecefe99..08a5b3b0a2 100644 --- a/esphome/components/bme680/sensor.py +++ b/esphome/components/bme680/sensor.py @@ -114,32 +114,32 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) if CONF_TEMPERATURE in config: conf = config[CONF_TEMPERATURE] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_temperature_sensor(sens)) cg.add(var.set_temperature_oversampling(conf[CONF_OVERSAMPLING])) if CONF_PRESSURE in config: conf = config[CONF_PRESSURE] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_pressure_sensor(sens)) cg.add(var.set_pressure_oversampling(conf[CONF_OVERSAMPLING])) if CONF_HUMIDITY in config: conf = config[CONF_HUMIDITY] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_humidity_sensor(sens)) cg.add(var.set_humidity_oversampling(conf[CONF_OVERSAMPLING])) if CONF_GAS_RESISTANCE in config: conf = config[CONF_GAS_RESISTANCE] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_gas_resistance_sensor(sens)) cg.add(var.set_iir_filter(IIR_FILTER_OPTIONS[config[CONF_IIR_FILTER]])) diff --git a/esphome/components/bme680_bsec/__init__.py b/esphome/components/bme680_bsec/__init__.py index e9704b5e59..d258819aa4 100644 --- a/esphome/components/bme680_bsec/__init__.py +++ b/esphome/components/bme680_bsec/__init__.py @@ -48,10 +48,10 @@ CONFIG_SCHEMA = cv.Schema( ).extend(i2c.i2c_device_schema(0x76)) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) cg.add(var.set_temperature_offset(config[CONF_TEMPERATURE_OFFSET])) cg.add(var.set_iaq_mode(config[CONF_IAQ_MODE])) diff --git a/esphome/components/bme680_bsec/sensor.py b/esphome/components/bme680_bsec/sensor.py index b5f0ce190d..0781f50f4e 100644 --- a/esphome/components/bme680_bsec/sensor.py +++ b/esphome/components/bme680_bsec/sensor.py @@ -97,7 +97,7 @@ def setup_conf(config, key, hub): cg.add(getattr(hub, f"set_{key}_sample_rate")(conf[CONF_SAMPLE_RATE])) -def to_code(config): - hub = yield cg.get_variable(config[CONF_BME680_BSEC_ID]) +async def to_code(config): + hub = await cg.get_variable(config[CONF_BME680_BSEC_ID]) for key in TYPES: - yield setup_conf(config, key, hub) + await setup_conf(config, key, hub) diff --git a/esphome/components/bme680_bsec/text_sensor.py b/esphome/components/bme680_bsec/text_sensor.py index bd90a419f5..41a63753a6 100644 --- a/esphome/components/bme680_bsec/text_sensor.py +++ b/esphome/components/bme680_bsec/text_sensor.py @@ -34,7 +34,7 @@ def setup_conf(config, key, hub): cg.add(getattr(hub, f"set_{key}_text_sensor")(sens)) -def to_code(config): - hub = yield cg.get_variable(config[CONF_BME680_BSEC_ID]) +async def to_code(config): + hub = await cg.get_variable(config[CONF_BME680_BSEC_ID]) for key in TYPES: - yield setup_conf(config, key, hub) + await setup_conf(config, key, hub) diff --git a/esphome/components/bmp085/sensor.py b/esphome/components/bmp085/sensor.py index a070e4aa69..eca5283d5d 100644 --- a/esphome/components/bmp085/sensor.py +++ b/esphome/components/bmp085/sensor.py @@ -36,17 +36,17 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) if CONF_TEMPERATURE in config: conf = config[CONF_TEMPERATURE] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_temperature(sens)) if CONF_PRESSURE in config: conf = config[CONF_PRESSURE] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_pressure(sens)) diff --git a/esphome/components/bmp280/sensor.py b/esphome/components/bmp280/sensor.py index b12d7bff7f..d86767ecd5 100644 --- a/esphome/components/bmp280/sensor.py +++ b/esphome/components/bmp280/sensor.py @@ -72,19 +72,19 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) if CONF_TEMPERATURE in config: conf = config[CONF_TEMPERATURE] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_temperature_sensor(sens)) cg.add(var.set_temperature_oversampling(conf[CONF_OVERSAMPLING])) if CONF_PRESSURE in config: conf = config[CONF_PRESSURE] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_pressure_sensor(sens)) cg.add(var.set_pressure_oversampling(conf[CONF_OVERSAMPLING])) diff --git a/esphome/components/ccs811/sensor.py b/esphome/components/ccs811/sensor.py index 95b108a225..e86d8f9b83 100644 --- a/esphome/components/ccs811/sensor.py +++ b/esphome/components/ccs811/sensor.py @@ -43,22 +43,22 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) - sens = yield sensor.new_sensor(config[CONF_ECO2]) + sens = await sensor.new_sensor(config[CONF_ECO2]) cg.add(var.set_co2(sens)) - sens = yield sensor.new_sensor(config[CONF_TVOC]) + sens = await sensor.new_sensor(config[CONF_TVOC]) cg.add(var.set_tvoc(sens)) if CONF_BASELINE in config: cg.add(var.set_baseline(config[CONF_BASELINE])) if CONF_TEMPERATURE in config: - sens = yield cg.get_variable(config[CONF_TEMPERATURE]) + sens = await cg.get_variable(config[CONF_TEMPERATURE]) cg.add(var.set_temperature(sens)) if CONF_HUMIDITY in config: - sens = yield cg.get_variable(config[CONF_HUMIDITY]) + sens = await cg.get_variable(config[CONF_HUMIDITY]) cg.add(var.set_humidity(sens)) diff --git a/esphome/components/climate_ir_lg/climate.py b/esphome/components/climate_ir_lg/climate.py index 06e538d9c7..c58e40f7f4 100644 --- a/esphome/components/climate_ir_lg/climate.py +++ b/esphome/components/climate_ir_lg/climate.py @@ -36,9 +36,9 @@ CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield climate_ir.register_climate_ir(var, config) + await climate_ir.register_climate_ir(var, config) cg.add(var.set_header_high(config[CONF_HEADER_HIGH])) cg.add(var.set_header_low(config[CONF_HEADER_LOW])) diff --git a/esphome/components/color/__init__.py b/esphome/components/color/__init__.py index 6712d078a4..47679fcc68 100644 --- a/esphome/components/color/__init__.py +++ b/esphome/components/color/__init__.py @@ -26,7 +26,7 @@ CONFIG_SCHEMA = cv.Schema( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): r = 0 if CONF_RED in config: r = int(config[CONF_RED] * 255) diff --git a/esphome/components/coolix/climate.py b/esphome/components/coolix/climate.py index b7a584643b..2cfd1912e5 100644 --- a/esphome/components/coolix/climate.py +++ b/esphome/components/coolix/climate.py @@ -16,6 +16,6 @@ CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield climate_ir.register_climate_ir(var, config) + await climate_ir.register_climate_ir(var, config) diff --git a/esphome/components/cse7766/sensor.py b/esphome/components/cse7766/sensor.py index 71e9458618..3e136dae49 100644 --- a/esphome/components/cse7766/sensor.py +++ b/esphome/components/cse7766/sensor.py @@ -42,20 +42,20 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield uart.register_uart_device(var, config) + await cg.register_component(var, config) + await uart.register_uart_device(var, config) if CONF_VOLTAGE in config: conf = config[CONF_VOLTAGE] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_voltage_sensor(sens)) if CONF_CURRENT in config: conf = config[CONF_CURRENT] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_current_sensor(sens)) if CONF_POWER in config: conf = config[CONF_POWER] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_power_sensor(sens)) diff --git a/esphome/components/ct_clamp/sensor.py b/esphome/components/ct_clamp/sensor.py index e4dbd92387..8b15c9309d 100644 --- a/esphome/components/ct_clamp/sensor.py +++ b/esphome/components/ct_clamp/sensor.py @@ -32,11 +32,11 @@ CONFIG_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) - sens = yield cg.get_variable(config[CONF_SENSOR]) + sens = await cg.get_variable(config[CONF_SENSOR]) cg.add(var.set_source(sens)) cg.add(var.set_sample_duration(config[CONF_SAMPLE_DURATION])) diff --git a/esphome/components/custom/binary_sensor/__init__.py b/esphome/components/custom/binary_sensor/__init__.py index 402540c254..18d613d4c1 100644 --- a/esphome/components/custom/binary_sensor/__init__.py +++ b/esphome/components/custom/binary_sensor/__init__.py @@ -17,8 +17,8 @@ CONFIG_SCHEMA = cv.Schema( ) -def to_code(config): - template_ = yield cg.process_lambda( +async def to_code(config): + template_ = await cg.process_lambda( config[CONF_LAMBDA], [], return_type=cg.std_vector.template(binary_sensor.BinarySensorPtr), @@ -28,4 +28,4 @@ def to_code(config): custom = cg.variable(config[CONF_ID], rhs) for i, conf in enumerate(config[CONF_BINARY_SENSORS]): rhs = custom.Pget_binary_sensor(i) - yield binary_sensor.register_binary_sensor(rhs, conf) + await binary_sensor.register_binary_sensor(rhs, conf) diff --git a/esphome/components/custom/climate/__init__.py b/esphome/components/custom/climate/__init__.py index 75f9c3247e..a95456133a 100644 --- a/esphome/components/custom/climate/__init__.py +++ b/esphome/components/custom/climate/__init__.py @@ -16,8 +16,8 @@ CONFIG_SCHEMA = cv.Schema( ) -def to_code(config): - template_ = yield cg.process_lambda( +async def to_code(config): + template_ = await cg.process_lambda( config[CONF_LAMBDA], [], return_type=cg.std_vector.template(climate.Climate.operator("ptr")), @@ -27,4 +27,4 @@ def to_code(config): custom = cg.variable(config[CONF_ID], rhs) for i, conf in enumerate(config[CONF_CLIMATES]): rhs = custom.Pget_climate(i) - yield climate.register_climate(rhs, conf) + await climate.register_climate(rhs, conf) diff --git a/esphome/components/custom/cover/__init__.py b/esphome/components/custom/cover/__init__.py index 35f25b827d..37fd4cdbbc 100644 --- a/esphome/components/custom/cover/__init__.py +++ b/esphome/components/custom/cover/__init__.py @@ -16,8 +16,8 @@ CONFIG_SCHEMA = cv.Schema( ) -def to_code(config): - template_ = yield cg.process_lambda( +async def to_code(config): + template_ = await cg.process_lambda( config[CONF_LAMBDA], [], return_type=cg.std_vector.template(cover.Cover.operator("ptr")), @@ -27,4 +27,4 @@ def to_code(config): custom = cg.variable(config[CONF_ID], rhs) for i, conf in enumerate(config[CONF_COVERS]): rhs = custom.Pget_cover(i) - yield cover.register_cover(rhs, conf) + await cover.register_cover(rhs, conf) diff --git a/esphome/components/custom/light/__init__.py b/esphome/components/custom/light/__init__.py index f4bd8331f1..b6ebe13ab2 100644 --- a/esphome/components/custom/light/__init__.py +++ b/esphome/components/custom/light/__init__.py @@ -16,8 +16,8 @@ CONFIG_SCHEMA = cv.Schema( ) -def to_code(config): - template_ = yield cg.process_lambda( +async def to_code(config): + template_ = await cg.process_lambda( config[CONF_LAMBDA], [], return_type=cg.std_vector.template(light.LightOutput.operator("ptr")), @@ -27,4 +27,4 @@ def to_code(config): custom = cg.variable(config[CONF_ID], rhs) for i, conf in enumerate(config[CONF_LIGHTS]): rhs = custom.Pget_light(i) - yield light.register_light(rhs, conf) + await light.register_light(rhs, conf) diff --git a/esphome/components/custom/output/__init__.py b/esphome/components/custom/output/__init__.py index c803d89c32..97ef070fc3 100644 --- a/esphome/components/custom/output/__init__.py +++ b/esphome/components/custom/output/__init__.py @@ -42,7 +42,7 @@ CONFIG_SCHEMA = cv.typed_schema( ) -def to_code(config): +async def to_code(config): type = config[CONF_TYPE] if type == "binary": ret_type = output.BinaryOutputPtr @@ -50,7 +50,7 @@ def to_code(config): else: ret_type = output.FloatOutputPtr klass = CustomFloatOutputConstructor - template_ = yield cg.process_lambda( + template_ = await cg.process_lambda( config[CONF_LAMBDA], [], return_type=cg.std_vector.template(ret_type) ) @@ -58,4 +58,4 @@ def to_code(config): custom = cg.variable(config[CONF_ID], rhs) for i, conf in enumerate(config[CONF_OUTPUTS]): out = cg.Pvariable(conf[CONF_ID], custom.get_output(i)) - yield output.register_output(out, conf) + await output.register_output(out, conf) diff --git a/esphome/components/custom/sensor/__init__.py b/esphome/components/custom/sensor/__init__.py index 2be14afc0d..bf9421e43e 100644 --- a/esphome/components/custom/sensor/__init__.py +++ b/esphome/components/custom/sensor/__init__.py @@ -15,8 +15,8 @@ CONFIG_SCHEMA = cv.Schema( ) -def to_code(config): - template_ = yield cg.process_lambda( +async def to_code(config): + template_ = await cg.process_lambda( config[CONF_LAMBDA], [], return_type=cg.std_vector.template(sensor.SensorPtr) ) @@ -24,4 +24,4 @@ def to_code(config): var = cg.variable(config[CONF_ID], rhs) for i, conf in enumerate(config[CONF_SENSORS]): sens = cg.Pvariable(conf[CONF_ID], var.get_sensor(i)) - yield sensor.register_sensor(sens, conf) + await sensor.register_sensor(sens, conf) diff --git a/esphome/components/custom/switch/__init__.py b/esphome/components/custom/switch/__init__.py index a470c3e440..e0b9d7751a 100644 --- a/esphome/components/custom/switch/__init__.py +++ b/esphome/components/custom/switch/__init__.py @@ -21,8 +21,8 @@ CONFIG_SCHEMA = cv.Schema( ) -def to_code(config): - template_ = yield cg.process_lambda( +async def to_code(config): + template_ = await cg.process_lambda( config[CONF_LAMBDA], [], return_type=cg.std_vector.template(switch.SwitchPtr) ) @@ -30,4 +30,4 @@ def to_code(config): var = cg.variable(config[CONF_ID], rhs) for i, conf in enumerate(config[CONF_SWITCHES]): switch_ = cg.Pvariable(conf[CONF_ID], var.get_switch(i)) - yield switch.register_switch(switch_, conf) + await switch.register_switch(switch_, conf) diff --git a/esphome/components/custom/text_sensor/__init__.py b/esphome/components/custom/text_sensor/__init__.py index f09d72d228..5b6d416436 100644 --- a/esphome/components/custom/text_sensor/__init__.py +++ b/esphome/components/custom/text_sensor/__init__.py @@ -21,8 +21,8 @@ CONFIG_SCHEMA = cv.Schema( ) -def to_code(config): - template_ = yield cg.process_lambda( +async def to_code(config): + template_ = await cg.process_lambda( config[CONF_LAMBDA], [], return_type=cg.std_vector.template(text_sensor.TextSensorPtr), @@ -33,4 +33,4 @@ def to_code(config): for i, conf in enumerate(config[CONF_TEXT_SENSORS]): text = cg.Pvariable(conf[CONF_ID], var.get_text_sensor(i)) - yield text_sensor.register_text_sensor(text, conf) + await text_sensor.register_text_sensor(text, conf) diff --git a/esphome/components/custom_component/__init__.py b/esphome/components/custom_component/__init__.py index fc154a82c3..d41dd7ea59 100644 --- a/esphome/components/custom_component/__init__.py +++ b/esphome/components/custom_component/__init__.py @@ -19,8 +19,8 @@ CONFIG_SCHEMA = cv.Schema( ) -def to_code(config): - template_ = yield cg.process_lambda( +async def to_code(config): + template_ = await cg.process_lambda( config[CONF_LAMBDA], [], return_type=cg.std_vector.template(cg.ComponentPtr) ) @@ -28,4 +28,4 @@ def to_code(config): var = cg.variable(config[CONF_ID], rhs) for i, conf in enumerate(config.get(CONF_COMPONENTS, [])): comp = cg.Pvariable(conf[CONF_ID], var.get_component(i)) - yield cg.register_component(comp, conf) + await cg.register_component(comp, conf) diff --git a/esphome/components/cwww/light.py b/esphome/components/cwww/light.py index b099de435d..674c48d219 100644 --- a/esphome/components/cwww/light.py +++ b/esphome/components/cwww/light.py @@ -26,14 +26,14 @@ CONFIG_SCHEMA = light.RGB_LIGHT_SCHEMA.extend( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_OUTPUT_ID]) - yield light.register_light(var, config) - cwhite = yield cg.get_variable(config[CONF_COLD_WHITE]) + await light.register_light(var, config) + cwhite = await cg.get_variable(config[CONF_COLD_WHITE]) cg.add(var.set_cold_white(cwhite)) cg.add(var.set_cold_white_temperature(config[CONF_COLD_WHITE_COLOR_TEMPERATURE])) - wwhite = yield cg.get_variable(config[CONF_WARM_WHITE]) + wwhite = await cg.get_variable(config[CONF_WARM_WHITE]) cg.add(var.set_warm_white(wwhite)) cg.add(var.set_warm_white_temperature(config[CONF_WARM_WHITE_COLOR_TEMPERATURE])) cg.add(var.set_constant_brightness(config[CONF_CONSTANT_BRIGHTNESS])) diff --git a/esphome/components/daikin/climate.py b/esphome/components/daikin/climate.py index 07bc079a9a..af60b17448 100644 --- a/esphome/components/daikin/climate.py +++ b/esphome/components/daikin/climate.py @@ -15,6 +15,6 @@ CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield climate_ir.register_climate_ir(var, config) + await climate_ir.register_climate_ir(var, config) diff --git a/esphome/components/dallas/__init__.py b/esphome/components/dallas/__init__.py index 87049b8c64..e889c41175 100644 --- a/esphome/components/dallas/__init__.py +++ b/esphome/components/dallas/__init__.py @@ -20,8 +20,8 @@ CONFIG_SCHEMA = cv.Schema( ).extend(cv.polling_component_schema("60s")) -def to_code(config): - pin = yield cg.gpio_pin_expression(config[CONF_PIN]) +async def to_code(config): + pin = await cg.gpio_pin_expression(config[CONF_PIN]) one_wire = cg.new_Pvariable(config[CONF_ONE_WIRE_ID], pin) var = cg.new_Pvariable(config[CONF_ID], one_wire) - yield cg.register_component(var, config) + await cg.register_component(var, config) diff --git a/esphome/components/dallas/sensor.py b/esphome/components/dallas/sensor.py index bb0a463a62..21ba7b9154 100644 --- a/esphome/components/dallas/sensor.py +++ b/esphome/components/dallas/sensor.py @@ -29,12 +29,12 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): - hub = yield cg.get_variable(config[CONF_DALLAS_ID]) +async def to_code(config): + hub = await cg.get_variable(config[CONF_DALLAS_ID]) if CONF_ADDRESS in config: address = config[CONF_ADDRESS] rhs = hub.Pget_sensor_by_address(address, config.get(CONF_RESOLUTION)) else: rhs = hub.Pget_sensor_by_index(config[CONF_INDEX], config.get(CONF_RESOLUTION)) var = cg.Pvariable(config[CONF_ID], rhs) - yield sensor.register_sensor(var, config) + await sensor.register_sensor(var, config) diff --git a/esphome/components/debug/__init__.py b/esphome/components/debug/__init__.py index e43eb8bfc1..32c4339530 100644 --- a/esphome/components/debug/__init__.py +++ b/esphome/components/debug/__init__.py @@ -14,6 +14,6 @@ CONFIG_SCHEMA = cv.Schema( ).extend(cv.COMPONENT_SCHEMA) -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) diff --git a/esphome/components/deep_sleep/__init__.py b/esphome/components/deep_sleep/__init__.py index c0d035987d..bfc8c40cfb 100644 --- a/esphome/components/deep_sleep/__init__.py +++ b/esphome/components/deep_sleep/__init__.py @@ -78,14 +78,14 @@ CONFIG_SCHEMA = cv.Schema( ).extend(cv.COMPONENT_SCHEMA) -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) if CONF_SLEEP_DURATION in config: cg.add(var.set_sleep_duration(config[CONF_SLEEP_DURATION])) if CONF_WAKEUP_PIN in config: - pin = yield cg.gpio_pin_expression(config[CONF_WAKEUP_PIN]) + pin = await cg.gpio_pin_expression(config[CONF_WAKEUP_PIN]) cg.add(var.set_wakeup_pin(pin)) if CONF_WAKEUP_PIN_MODE in config: cg.add(var.set_wakeup_pin_mode(config[CONF_WAKEUP_PIN_MODE])) diff --git a/esphome/components/dfplayer/__init__.py b/esphome/components/dfplayer/__init__.py index 33e74a220b..95fef4d234 100644 --- a/esphome/components/dfplayer/__init__.py +++ b/esphome/components/dfplayer/__init__.py @@ -68,14 +68,14 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield uart.register_uart_device(var, config) + await cg.register_component(var, config) + await uart.register_uart_device(var, config) for conf in config.get(CONF_ON_FINISHED_PLAYBACK, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) - yield automation.build_automation(trigger, [], conf) + await automation.build_automation(trigger, [], conf) @automation.register_action( diff --git a/esphome/components/dht/sensor.py b/esphome/components/dht/sensor.py index 4b2f6ee8d2..57971e8202 100644 --- a/esphome/components/dht/sensor.py +++ b/esphome/components/dht/sensor.py @@ -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])) diff --git a/esphome/components/dht12/sensor.py b/esphome/components/dht12/sensor.py index f63768142c..68ff6ae1bb 100644 --- a/esphome/components/dht12/sensor.py +++ b/esphome/components/dht12/sensor.py @@ -34,15 +34,15 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, 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_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)) diff --git a/esphome/components/ds1307/time.py b/esphome/components/ds1307/time.py index 9c1d75c029..cd80a87170 100644 --- a/esphome/components/ds1307/time.py +++ b/esphome/components/ds1307/time.py @@ -50,9 +50,9 @@ def ds1307_read_time_to_code(config, action_id, template_arg, args): yield var -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) - yield time.register_time(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) + await time.register_time(var, config) diff --git a/esphome/components/duty_cycle/sensor.py b/esphome/components/duty_cycle/sensor.py index 0dd91bade3..e3d2318b51 100644 --- a/esphome/components/duty_cycle/sensor.py +++ b/esphome/components/duty_cycle/sensor.py @@ -29,10 +29,10 @@ CONFIG_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)) diff --git a/esphome/components/e131/__init__.py b/esphome/components/e131/__init__.py index b33aef8cf3..e02042d4c9 100644 --- a/esphome/components/e131/__init__.py +++ b/esphome/components/e131/__init__.py @@ -29,9 +29,9 @@ CONFIG_SCHEMA = cv.Schema( ) -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) cg.add(var.set_method(METHODS[config[CONF_METHOD]])) diff --git a/esphome/components/endstop/cover.py b/esphome/components/endstop/cover.py index b463d5d960..9f3cd395a5 100644 --- a/esphome/components/endstop/cover.py +++ b/esphome/components/endstop/cover.py @@ -32,26 +32,26 @@ CONFIG_SCHEMA = cover.COVER_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield cover.register_cover(var, config) + await cg.register_component(var, config) + await cover.register_cover(var, config) - yield automation.build_automation( + await automation.build_automation( var.get_stop_trigger(), [], config[CONF_STOP_ACTION] ) - bin = yield cg.get_variable(config[CONF_OPEN_ENDSTOP]) + bin = await cg.get_variable(config[CONF_OPEN_ENDSTOP]) cg.add(var.set_open_endstop(bin)) cg.add(var.set_open_duration(config[CONF_OPEN_DURATION])) - yield automation.build_automation( + await automation.build_automation( var.get_open_trigger(), [], config[CONF_OPEN_ACTION] ) - bin = yield cg.get_variable(config[CONF_CLOSE_ENDSTOP]) + bin = await cg.get_variable(config[CONF_CLOSE_ENDSTOP]) cg.add(var.set_close_endstop(bin)) cg.add(var.set_close_duration(config[CONF_CLOSE_DURATION])) - yield automation.build_automation( + await automation.build_automation( var.get_close_trigger(), [], config[CONF_CLOSE_ACTION] ) diff --git a/esphome/components/esp32_ble_beacon/__init__.py b/esphome/components/esp32_ble_beacon/__init__.py index 46f5678856..3e00692d3a 100644 --- a/esphome/components/esp32_ble_beacon/__init__.py +++ b/esphome/components/esp32_ble_beacon/__init__.py @@ -22,12 +22,12 @@ CONFIG_SCHEMA = cv.Schema( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): uuid = config[CONF_UUID].hex uuid_arr = [ cg.RawExpression("0x{}".format(uuid[i : i + 2])) for i in range(0, len(uuid), 2) ] var = cg.new_Pvariable(config[CONF_ID], uuid_arr) - yield cg.register_component(var, config) + await cg.register_component(var, config) cg.add(var.set_major(config[CONF_MAJOR])) cg.add(var.set_minor(config[CONF_MINOR])) diff --git a/esphome/components/esp32_ble_tracker/__init__.py b/esphome/components/esp32_ble_tracker/__init__.py index 8726ab3e8d..916fecffc9 100644 --- a/esphome/components/esp32_ble_tracker/__init__.py +++ b/esphome/components/esp32_ble_tracker/__init__.py @@ -177,9 +177,9 @@ ESP_BLE_DEVICE_SCHEMA = cv.Schema( ) -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) params = config[CONF_SCAN_PARAMETERS] cg.add(var.set_scan_duration(params[CONF_DURATION])) cg.add(var.set_scan_interval(int(params[CONF_INTERVAL].total_milliseconds / 0.625))) @@ -189,7 +189,7 @@ def to_code(config): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) if CONF_MAC_ADDRESS in conf: cg.add(trigger.set_address(conf[CONF_MAC_ADDRESS].as_hex)) - yield automation.build_automation(trigger, [(ESPBTDeviceConstRef, "x")], conf) + await automation.build_automation(trigger, [(ESPBTDeviceConstRef, "x")], conf) for conf in config.get(CONF_ON_BLE_SERVICE_DATA_ADVERTISE, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) if len(conf[CONF_SERVICE_UUID]) == len(bt_uuid16_format): @@ -201,7 +201,7 @@ def to_code(config): cg.add(trigger.set_service_uuid128(uuid128)) if CONF_MAC_ADDRESS in conf: cg.add(trigger.set_address(conf[CONF_MAC_ADDRESS].as_hex)) - yield automation.build_automation(trigger, [(adv_data_t_const_ref, "x")], conf) + await automation.build_automation(trigger, [(adv_data_t_const_ref, "x")], conf) for conf in config.get(CONF_ON_BLE_MANUFACTURER_DATA_ADVERTISE, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) if len(conf[CONF_MANUFACTURER_ID]) == len(bt_uuid16_format): @@ -213,7 +213,7 @@ def to_code(config): cg.add(trigger.set_manufacturer_uuid128(uuid128)) if CONF_MAC_ADDRESS in conf: cg.add(trigger.set_address(conf[CONF_MAC_ADDRESS].as_hex)) - yield automation.build_automation(trigger, [(adv_data_t_const_ref, "x")], conf) + await automation.build_automation(trigger, [(adv_data_t_const_ref, "x")], conf) @coroutine diff --git a/esphome/components/esp32_camera/__init__.py b/esphome/components/esp32_camera/__init__.py index f7169257a4..f3c0e0f165 100644 --- a/esphome/components/esp32_camera/__init__.py +++ b/esphome/components/esp32_camera/__init__.py @@ -124,9 +124,9 @@ SETTERS = { } -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID], config[CONF_NAME]) - yield cg.register_component(var, config) + await cg.register_component(var, config) for key, setter in SETTERS.items(): if key in config: diff --git a/esphome/components/esp32_dac/output.py b/esphome/components/esp32_dac/output.py index 8cfc7570e9..8534a1bae1 100644 --- a/esphome/components/esp32_dac/output.py +++ b/esphome/components/esp32_dac/output.py @@ -26,10 +26,10 @@ CONFIG_SCHEMA = output.FLOAT_OUTPUT_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield output.register_output(var, config) + await cg.register_component(var, config) + await output.register_output(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)) diff --git a/esphome/components/esp32_hall/sensor.py b/esphome/components/esp32_hall/sensor.py index 363b3f7548..0f1cbb373c 100644 --- a/esphome/components/esp32_hall/sensor.py +++ b/esphome/components/esp32_hall/sensor.py @@ -27,7 +27,7 @@ CONFIG_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) diff --git a/esphome/components/esp32_touch/__init__.py b/esphome/components/esp32_touch/__init__.py index 5c3b47af77..1564476ecf 100644 --- a/esphome/components/esp32_touch/__init__.py +++ b/esphome/components/esp32_touch/__init__.py @@ -77,9 +77,9 @@ CONFIG_SCHEMA = cv.Schema( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): touch = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(touch, config) + await cg.register_component(touch, config) cg.add(touch.set_setup_mode(config[CONF_SETUP_MODE])) cg.add(touch.set_iir_filter(config[CONF_IIR_FILTER])) diff --git a/esphome/components/esp32_touch/binary_sensor.py b/esphome/components/esp32_touch/binary_sensor.py index f8bc348132..300de23f08 100644 --- a/esphome/components/esp32_touch/binary_sensor.py +++ b/esphome/components/esp32_touch/binary_sensor.py @@ -51,13 +51,13 @@ CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend( ) -def to_code(config): - hub = yield cg.get_variable(config[CONF_ESP32_TOUCH_ID]) +async def to_code(config): + hub = await cg.get_variable(config[CONF_ESP32_TOUCH_ID]) var = cg.new_Pvariable( config[CONF_ID], config[CONF_NAME], TOUCH_PADS[config[CONF_PIN]], config[CONF_THRESHOLD], ) - yield binary_sensor.register_binary_sensor(var, config) + await binary_sensor.register_binary_sensor(var, config) cg.add(hub.register_touch_pad(var)) diff --git a/esphome/components/esp8266_pwm/output.py b/esphome/components/esp8266_pwm/output.py index ad7da4e001..38361da017 100644 --- a/esphome/components/esp8266_pwm/output.py +++ b/esphome/components/esp8266_pwm/output.py @@ -35,12 +35,12 @@ CONFIG_SCHEMA = output.FLOAT_OUTPUT_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield output.register_output(var, config) + await cg.register_component(var, config) + await output.register_output(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_frequency(config[CONF_FREQUENCY])) diff --git a/esphome/components/ethernet/__init__.py b/esphome/components/ethernet/__init__.py index 82366eeac2..c6f81e5046 100644 --- a/esphome/components/ethernet/__init__.py +++ b/esphome/components/ethernet/__init__.py @@ -106,9 +106,9 @@ def manual_ip(config): @coroutine_with_priority(60.0) -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) cg.add(var.set_phy_addr(config[CONF_PHY_ADDR])) cg.add(var.set_mdc_pin(config[CONF_MDC_PIN])) @@ -118,7 +118,7 @@ def to_code(config): cg.add(var.set_use_address(config[CONF_USE_ADDRESS])) if CONF_POWER_PIN in config: - pin = yield cg.gpio_pin_expression(config[CONF_POWER_PIN]) + pin = await cg.gpio_pin_expression(config[CONF_POWER_PIN]) cg.add(var.set_power_pin(pin)) if CONF_MANUAL_IP in config: diff --git a/esphome/components/exposure_notifications/__init__.py b/esphome/components/exposure_notifications/__init__.py index 1bd8007785..9c28552267 100644 --- a/esphome/components/exposure_notifications/__init__.py +++ b/esphome/components/exposure_notifications/__init__.py @@ -32,8 +32,8 @@ CONFIG_SCHEMA = cv.Schema( ) -def to_code(config): +async def to_code(config): for conf in config.get(CONF_ON_EXPOSURE_NOTIFICATION, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID]) - yield automation.build_automation(trigger, [(ExposureNotification, "x")], conf) - yield esp32_ble_tracker.register_ble_device(trigger, conf) + await automation.build_automation(trigger, [(ExposureNotification, "x")], conf) + await esp32_ble_tracker.register_ble_device(trigger, conf) diff --git a/esphome/components/external_components/__init__.py b/esphome/components/external_components/__init__.py index 272812adcf..1602ac3b07 100644 --- a/esphome/components/external_components/__init__.py +++ b/esphome/components/external_components/__init__.py @@ -98,7 +98,7 @@ CONFIG_SCHEMA = cv.ensure_list( ) -def to_code(config): +async def to_code(config): pass diff --git a/esphome/components/ezo/sensor.py b/esphome/components/ezo/sensor.py index 12640f4038..09b36b7135 100644 --- a/esphome/components/ezo/sensor.py +++ b/esphome/components/ezo/sensor.py @@ -24,8 +24,8 @@ CONFIG_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) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await sensor.register_sensor(var, config) + await i2c.register_i2c_device(var, config) diff --git a/esphome/components/fastled_clockless/light.py b/esphome/components/fastled_clockless/light.py index b8a36ff390..17f72427e4 100644 --- a/esphome/components/fastled_clockless/light.py +++ b/esphome/components/fastled_clockless/light.py @@ -51,8 +51,8 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): - var = yield fastled_base.new_fastled_light(config) +async def to_code(config): + var = await fastled_base.new_fastled_light(config) rgb_order = None if CONF_RGB_ORDER in config: diff --git a/esphome/components/fastled_spi/light.py b/esphome/components/fastled_spi/light.py index 11e0a8159c..d6ba0e8358 100644 --- a/esphome/components/fastled_spi/light.py +++ b/esphome/components/fastled_spi/light.py @@ -34,8 +34,8 @@ CONFIG_SCHEMA = fastled_base.BASE_SCHEMA.extend( ) -def to_code(config): - var = yield fastled_base.new_fastled_light(config) +async def to_code(config): + var = await fastled_base.new_fastled_light(config) rgb_order = cg.RawExpression( config[CONF_RGB_ORDER] if CONF_RGB_ORDER in config else "RGB" diff --git a/esphome/components/fingerprint_grow/__init__.py b/esphome/components/fingerprint_grow/__init__.py index 6fbaa4e6c9..52426a3f2d 100644 --- a/esphome/components/fingerprint_grow/__init__.py +++ b/esphome/components/fingerprint_grow/__init__.py @@ -132,45 +132,45 @@ CONFIG_SCHEMA = ( ) -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) if CONF_PASSWORD in config: password = config[CONF_PASSWORD] cg.add(var.set_password(password)) - yield uart.register_uart_device(var, config) + await uart.register_uart_device(var, config) if CONF_NEW_PASSWORD in config: new_password = config[CONF_NEW_PASSWORD] cg.add(var.set_new_password(new_password)) if CONF_SENSING_PIN in config: - sensing_pin = yield cg.gpio_pin_expression(config[CONF_SENSING_PIN]) + sensing_pin = await cg.gpio_pin_expression(config[CONF_SENSING_PIN]) cg.add(var.set_sensing_pin(sensing_pin)) for conf in config.get(CONF_ON_FINGER_SCAN_MATCHED, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) - yield automation.build_automation( + await automation.build_automation( trigger, [(cg.uint16, "finger_id"), (cg.uint16, "confidence")], conf ) for conf in config.get(CONF_ON_FINGER_SCAN_UNMATCHED, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) - yield automation.build_automation(trigger, [], conf) + await automation.build_automation(trigger, [], conf) for conf in config.get(CONF_ON_ENROLLMENT_SCAN, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) - yield automation.build_automation( + await automation.build_automation( trigger, [(cg.uint8, "scan_num"), (cg.uint16, "finger_id")], conf ) for conf in config.get(CONF_ON_ENROLLMENT_DONE, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) - yield automation.build_automation(trigger, [(cg.uint16, "finger_id")], conf) + await automation.build_automation(trigger, [(cg.uint16, "finger_id")], conf) for conf in config.get(CONF_ON_ENROLLMENT_FAILED, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) - yield automation.build_automation(trigger, [(cg.uint16, "finger_id")], conf) + await automation.build_automation(trigger, [(cg.uint16, "finger_id")], conf) @automation.register_action( diff --git a/esphome/components/fingerprint_grow/binary_sensor.py b/esphome/components/fingerprint_grow/binary_sensor.py index 4f49841f15..f432ef92cc 100644 --- a/esphome/components/fingerprint_grow/binary_sensor.py +++ b/esphome/components/fingerprint_grow/binary_sensor.py @@ -14,7 +14,7 @@ CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend( ) -def to_code(config): - hub = yield cg.get_variable(config[CONF_FINGERPRINT_GROW_ID]) - var = yield binary_sensor.new_binary_sensor(config) +async def to_code(config): + hub = await cg.get_variable(config[CONF_FINGERPRINT_GROW_ID]) + var = await binary_sensor.new_binary_sensor(config) cg.add(hub.set_enrolling_binary_sensor(var)) diff --git a/esphome/components/fingerprint_grow/sensor.py b/esphome/components/fingerprint_grow/sensor.py index c76c898727..11f61a6a71 100644 --- a/esphome/components/fingerprint_grow/sensor.py +++ b/esphome/components/fingerprint_grow/sensor.py @@ -46,8 +46,8 @@ CONFIG_SCHEMA = cv.Schema( ) -def to_code(config): - hub = yield cg.get_variable(config[CONF_FINGERPRINT_GROW_ID]) +async def to_code(config): + hub = await cg.get_variable(config[CONF_FINGERPRINT_GROW_ID]) for key in [ CONF_FINGERPRINT_COUNT, @@ -60,5 +60,5 @@ def to_code(config): if key not in config: continue conf = config[key] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(getattr(hub, f"set_{key}_sensor")(sens)) diff --git a/esphome/components/font/__init__.py b/esphome/components/font/__init__.py index b54342d586..11bbedd80b 100644 --- a/esphome/components/font/__init__.py +++ b/esphome/components/font/__init__.py @@ -92,7 +92,7 @@ FONT_SCHEMA = cv.Schema( CONFIG_SCHEMA = cv.All(validate_pillow_installed, FONT_SCHEMA) -def to_code(config): +async def to_code(config): from PIL import ImageFont path = CORE.relative_config_path(config[CONF_FILE]) diff --git a/esphome/components/fujitsu_general/climate.py b/esphome/components/fujitsu_general/climate.py index d58049e3f2..427721f2db 100644 --- a/esphome/components/fujitsu_general/climate.py +++ b/esphome/components/fujitsu_general/climate.py @@ -17,6 +17,6 @@ CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield climate_ir.register_climate_ir(var, config) + await climate_ir.register_climate_ir(var, config) diff --git a/esphome/components/gpio/binary_sensor/__init__.py b/esphome/components/gpio/binary_sensor/__init__.py index 4a24efcdb0..4d91b81a44 100644 --- a/esphome/components/gpio/binary_sensor/__init__.py +++ b/esphome/components/gpio/binary_sensor/__init__.py @@ -17,10 +17,10 @@ CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield binary_sensor.register_binary_sensor(var, config) + await cg.register_component(var, config) + await binary_sensor.register_binary_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)) diff --git a/esphome/components/gpio/output/__init__.py b/esphome/components/gpio/output/__init__.py index d98a490566..2fa9f4dc78 100644 --- a/esphome/components/gpio/output/__init__.py +++ b/esphome/components/gpio/output/__init__.py @@ -15,10 +15,10 @@ CONFIG_SCHEMA = output.BINARY_OUTPUT_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield output.register_output(var, config) - yield cg.register_component(var, config) + await output.register_output(var, config) + await cg.register_component(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)) diff --git a/esphome/components/gpio/switch/__init__.py b/esphome/components/gpio/switch/__init__.py index 44a9699b84..a03e16a2c1 100644 --- a/esphome/components/gpio/switch/__init__.py +++ b/esphome/components/gpio/switch/__init__.py @@ -33,12 +33,12 @@ CONFIG_SCHEMA = switch.SWITCH_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield switch.register_switch(var, config) + await cg.register_component(var, config) + await switch.register_switch(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_restore_mode(config[CONF_RESTORE_MODE])) @@ -46,7 +46,7 @@ def to_code(config): if CONF_INTERLOCK in config: interlock = [] for it in config[CONF_INTERLOCK]: - lock = yield cg.get_variable(it) + lock = await cg.get_variable(it) interlock.append(lock) cg.add(var.set_interlock(interlock)) cg.add(var.set_interlock_wait_time(config[CONF_INTERLOCK_WAIT_TIME])) diff --git a/esphome/components/gps/__init__.py b/esphome/components/gps/__init__.py index c09a49315c..e982bd4dfd 100644 --- a/esphome/components/gps/__init__.py +++ b/esphome/components/gps/__init__.py @@ -58,33 +58,33 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield uart.register_uart_device(var, config) + await cg.register_component(var, config) + await uart.register_uart_device(var, config) if CONF_LATITUDE in config: - sens = yield sensor.new_sensor(config[CONF_LATITUDE]) + sens = await sensor.new_sensor(config[CONF_LATITUDE]) cg.add(var.set_latitude_sensor(sens)) if CONF_LONGITUDE in config: - sens = yield sensor.new_sensor(config[CONF_LONGITUDE]) + sens = await sensor.new_sensor(config[CONF_LONGITUDE]) cg.add(var.set_longitude_sensor(sens)) if CONF_SPEED in config: - sens = yield sensor.new_sensor(config[CONF_SPEED]) + sens = await sensor.new_sensor(config[CONF_SPEED]) cg.add(var.set_speed_sensor(sens)) if CONF_COURSE in config: - sens = yield sensor.new_sensor(config[CONF_COURSE]) + sens = await sensor.new_sensor(config[CONF_COURSE]) cg.add(var.set_course_sensor(sens)) if CONF_ALTITUDE in config: - sens = yield sensor.new_sensor(config[CONF_ALTITUDE]) + sens = await sensor.new_sensor(config[CONF_ALTITUDE]) cg.add(var.set_altitude_sensor(sens)) if CONF_SATELLITES in config: - sens = yield sensor.new_sensor(config[CONF_SATELLITES]) + sens = await sensor.new_sensor(config[CONF_SATELLITES]) cg.add(var.set_satellites_sensor(sens)) # https://platformio.org/lib/show/1655/TinyGPSPlus diff --git a/esphome/components/gps/time/__init__.py b/esphome/components/gps/time/__init__.py index 24ea263f6c..1dae22a2b2 100644 --- a/esphome/components/gps/time/__init__.py +++ b/esphome/components/gps/time/__init__.py @@ -18,10 +18,10 @@ CONFIG_SCHEMA = time_.TIME_SCHEMA.extend( ).extend(cv.polling_component_schema("5min")) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield time_.register_time(var, config) - yield cg.register_component(var, config) + await time_.register_time(var, config) + await cg.register_component(var, config) - paren = yield cg.get_variable(config[CONF_GPS_ID]) + paren = await cg.get_variable(config[CONF_GPS_ID]) cg.add(paren.register_listener(var)) diff --git a/esphome/components/hbridge/light.py b/esphome/components/hbridge/light.py index 6c695fbd4a..b4ae45977a 100644 --- a/esphome/components/hbridge/light.py +++ b/esphome/components/hbridge/light.py @@ -17,12 +17,12 @@ CONFIG_SCHEMA = light.RGB_LIGHT_SCHEMA.extend( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_OUTPUT_ID]) - yield cg.register_component(var, config) - yield light.register_light(var, config) + await cg.register_component(var, config) + await light.register_light(var, config) - hside = yield cg.get_variable(config[CONF_PIN_A]) + hside = await cg.get_variable(config[CONF_PIN_A]) cg.add(var.set_pina_pin(hside)) - lside = yield cg.get_variable(config[CONF_PIN_B]) + lside = await cg.get_variable(config[CONF_PIN_B]) cg.add(var.set_pinb_pin(lside)) diff --git a/esphome/components/hdc1080/sensor.py b/esphome/components/hdc1080/sensor.py index 15a92cccf2..0995f98589 100644 --- a/esphome/components/hdc1080/sensor.py +++ b/esphome/components/hdc1080/sensor.py @@ -36,15 +36,15 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, 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)) 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)) diff --git a/esphome/components/hitachi_ac344/climate.py b/esphome/components/hitachi_ac344/climate.py index 9ae0cd39de..94b34eb955 100644 --- a/esphome/components/hitachi_ac344/climate.py +++ b/esphome/components/hitachi_ac344/climate.py @@ -15,6 +15,6 @@ CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield climate_ir.register_climate_ir(var, config) + await climate_ir.register_climate_ir(var, config) diff --git a/esphome/components/hlw8012/sensor.py b/esphome/components/hlw8012/sensor.py index 28aa24d7cd..aeab94a05c 100644 --- a/esphome/components/hlw8012/sensor.py +++ b/esphome/components/hlw8012/sensor.py @@ -70,28 +70,28 @@ 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) - sel = yield cg.gpio_pin_expression(config[CONF_SEL_PIN]) + sel = await cg.gpio_pin_expression(config[CONF_SEL_PIN]) cg.add(var.set_sel_pin(sel)) - cf = yield cg.gpio_pin_expression(config[CONF_CF_PIN]) + cf = await cg.gpio_pin_expression(config[CONF_CF_PIN]) cg.add(var.set_cf_pin(cf)) - cf1 = yield cg.gpio_pin_expression(config[CONF_CF1_PIN]) + cf1 = await cg.gpio_pin_expression(config[CONF_CF1_PIN]) cg.add(var.set_cf1_pin(cf1)) if CONF_VOLTAGE in config: - sens = yield sensor.new_sensor(config[CONF_VOLTAGE]) + sens = await sensor.new_sensor(config[CONF_VOLTAGE]) cg.add(var.set_voltage_sensor(sens)) if CONF_CURRENT in config: - sens = yield sensor.new_sensor(config[CONF_CURRENT]) + sens = await sensor.new_sensor(config[CONF_CURRENT]) cg.add(var.set_current_sensor(sens)) if CONF_POWER in config: - sens = yield sensor.new_sensor(config[CONF_POWER]) + sens = await sensor.new_sensor(config[CONF_POWER]) cg.add(var.set_power_sensor(sens)) if CONF_ENERGY in config: - sens = yield sensor.new_sensor(config[CONF_ENERGY]) + sens = await sensor.new_sensor(config[CONF_ENERGY]) cg.add(var.set_energy_sensor(sens)) cg.add(var.set_current_resistor(config[CONF_CURRENT_RESISTOR])) cg.add(var.set_voltage_divider(config[CONF_VOLTAGE_DIVIDER])) diff --git a/esphome/components/hm3301/sensor.py b/esphome/components/hm3301/sensor.py index 14ca2e77ba..6d77841d20 100644 --- a/esphome/components/hm3301/sensor.py +++ b/esphome/components/hm3301/sensor.py @@ -76,25 +76,25 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) if CONF_PM_1_0 in config: - sens = yield sensor.new_sensor(config[CONF_PM_1_0]) + sens = await sensor.new_sensor(config[CONF_PM_1_0]) cg.add(var.set_pm_1_0_sensor(sens)) if CONF_PM_2_5 in config: - sens = yield sensor.new_sensor(config[CONF_PM_2_5]) + sens = await sensor.new_sensor(config[CONF_PM_2_5]) cg.add(var.set_pm_2_5_sensor(sens)) if CONF_PM_10_0 in config: - sens = yield sensor.new_sensor(config[CONF_PM_10_0]) + sens = await sensor.new_sensor(config[CONF_PM_10_0]) cg.add(var.set_pm_10_0_sensor(sens)) if CONF_AQI in config: - sens = yield sensor.new_sensor(config[CONF_AQI]) + sens = await sensor.new_sensor(config[CONF_AQI]) cg.add(var.set_aqi_sensor(sens)) cg.add(var.set_aqi_calculation_type(config[CONF_AQI][CONF_CALCULATION_TYPE])) diff --git a/esphome/components/hmc5883l/sensor.py b/esphome/components/hmc5883l/sensor.py index d057caf030..c615f929ee 100644 --- a/esphome/components/hmc5883l/sensor.py +++ b/esphome/components/hmc5883l/sensor.py @@ -115,23 +115,23 @@ def auto_data_rate(config): return HMC5883LDatarates[75] -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) cg.add(var.set_oversampling(config[CONF_OVERSAMPLING])) cg.add(var.set_datarate(auto_data_rate(config))) cg.add(var.set_range(config[CONF_RANGE])) if CONF_FIELD_STRENGTH_X in config: - sens = yield sensor.new_sensor(config[CONF_FIELD_STRENGTH_X]) + sens = await sensor.new_sensor(config[CONF_FIELD_STRENGTH_X]) cg.add(var.set_x_sensor(sens)) if CONF_FIELD_STRENGTH_Y in config: - sens = yield sensor.new_sensor(config[CONF_FIELD_STRENGTH_Y]) + sens = await sensor.new_sensor(config[CONF_FIELD_STRENGTH_Y]) cg.add(var.set_y_sensor(sens)) if CONF_FIELD_STRENGTH_Z in config: - sens = yield sensor.new_sensor(config[CONF_FIELD_STRENGTH_Z]) + sens = await sensor.new_sensor(config[CONF_FIELD_STRENGTH_Z]) cg.add(var.set_z_sensor(sens)) if CONF_HEADING in config: - sens = yield sensor.new_sensor(config[CONF_HEADING]) + sens = await sensor.new_sensor(config[CONF_HEADING]) cg.add(var.set_heading_sensor(sens)) diff --git a/esphome/components/homeassistant/binary_sensor/__init__.py b/esphome/components/homeassistant/binary_sensor/__init__.py index cf2f3092af..4972466aac 100644 --- a/esphome/components/homeassistant/binary_sensor/__init__.py +++ b/esphome/components/homeassistant/binary_sensor/__init__.py @@ -18,10 +18,10 @@ CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield binary_sensor.register_binary_sensor(var, config) + await cg.register_component(var, config) + await binary_sensor.register_binary_sensor(var, config) cg.add(var.set_entity_id(config[CONF_ENTITY_ID])) if CONF_ATTRIBUTE in config: diff --git a/esphome/components/homeassistant/sensor/__init__.py b/esphome/components/homeassistant/sensor/__init__.py index c754ae295b..771db25b85 100644 --- a/esphome/components/homeassistant/sensor/__init__.py +++ b/esphome/components/homeassistant/sensor/__init__.py @@ -28,10 +28,10 @@ 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) cg.add(var.set_entity_id(config[CONF_ENTITY_ID])) if CONF_ATTRIBUTE in config: diff --git a/esphome/components/homeassistant/text_sensor/__init__.py b/esphome/components/homeassistant/text_sensor/__init__.py index ed14615b80..b63d45b9ce 100644 --- a/esphome/components/homeassistant/text_sensor/__init__.py +++ b/esphome/components/homeassistant/text_sensor/__init__.py @@ -19,10 +19,10 @@ CONFIG_SCHEMA = text_sensor.TEXT_SENSOR_SCHEMA.extend( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield text_sensor.register_text_sensor(var, config) + await cg.register_component(var, config) + await text_sensor.register_text_sensor(var, config) cg.add(var.set_entity_id(config[CONF_ENTITY_ID])) if CONF_ATTRIBUTE in config: diff --git a/esphome/components/homeassistant/time/__init__.py b/esphome/components/homeassistant/time/__init__.py index e995421302..0040988794 100644 --- a/esphome/components/homeassistant/time/__init__.py +++ b/esphome/components/homeassistant/time/__init__.py @@ -15,8 +15,8 @@ CONFIG_SCHEMA = time_.TIME_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield time_.register_time(var, config) - yield cg.register_component(var, config) + await time_.register_time(var, config) + await cg.register_component(var, config) cg.add_define("USE_HOMEASSISTANT_TIME") diff --git a/esphome/components/http_request/__init__.py b/esphome/components/http_request/__init__.py index ef664a9d35..6512b59d52 100644 --- a/esphome/components/http_request/__init__.py +++ b/esphome/components/http_request/__init__.py @@ -107,11 +107,11 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) cg.add(var.set_timeout(config[CONF_TIMEOUT])) cg.add(var.set_useragent(config[CONF_USERAGENT])) - yield cg.register_component(var, config) + await cg.register_component(var, config) HTTP_REQUEST_ACTION_SCHEMA = cv.Schema( diff --git a/esphome/components/htu21d/sensor.py b/esphome/components/htu21d/sensor.py index 258681a5aa..596a7d4531 100644 --- a/esphome/components/htu21d/sensor.py +++ b/esphome/components/htu21d/sensor.py @@ -36,15 +36,15 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, 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)) 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)) diff --git a/esphome/components/hx711/sensor.py b/esphome/components/hx711/sensor.py index 191a7386e6..b249ca8f77 100644 --- a/esphome/components/hx711/sensor.py +++ b/esphome/components/hx711/sensor.py @@ -37,13 +37,13 @@ CONFIG_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) - dout_pin = yield cg.gpio_pin_expression(config[CONF_DOUT_PIN]) + dout_pin = await cg.gpio_pin_expression(config[CONF_DOUT_PIN]) cg.add(var.set_dout_pin(dout_pin)) - sck_pin = yield cg.gpio_pin_expression(config[CONF_CLK_PIN]) + sck_pin = await cg.gpio_pin_expression(config[CONF_CLK_PIN]) cg.add(var.set_sck_pin(sck_pin)) cg.add(var.set_gain(config[CONF_GAIN])) diff --git a/esphome/components/ili9341/display.py b/esphome/components/ili9341/display.py index 8c1a28ea5d..450a958c56 100644 --- a/esphome/components/ili9341/display.py +++ b/esphome/components/ili9341/display.py @@ -47,7 +47,7 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): if config[CONF_MODEL] == "M5STACK": lcd_type = ILI9341M5Stack if config[CONF_MODEL] == "TFT_2.4": @@ -55,21 +55,21 @@ def to_code(config): rhs = lcd_type.new() var = cg.Pvariable(config[CONF_ID], rhs) - yield cg.register_component(var, config) - yield display.register_display(var, config) - yield spi.register_spi_device(var, config) + await cg.register_component(var, config) + await display.register_display(var, config) + await spi.register_spi_device(var, config) cg.add(var.set_model(config[CONF_MODEL])) - dc = yield cg.gpio_pin_expression(config[CONF_DC_PIN]) + dc = await cg.gpio_pin_expression(config[CONF_DC_PIN]) cg.add(var.set_dc_pin(dc)) if CONF_LAMBDA in config: - lambda_ = yield cg.process_lambda( + lambda_ = await cg.process_lambda( config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void ) cg.add(var.set_writer(lambda_)) if CONF_RESET_PIN in config: - reset = yield cg.gpio_pin_expression(config[CONF_RESET_PIN]) + reset = await cg.gpio_pin_expression(config[CONF_RESET_PIN]) cg.add(var.set_reset_pin(reset)) if CONF_LED_PIN in config: - led_pin = yield cg.gpio_pin_expression(config[CONF_LED_PIN]) + led_pin = await cg.gpio_pin_expression(config[CONF_LED_PIN]) cg.add(var.set_led_pin(led_pin)) diff --git a/esphome/components/image/__init__.py b/esphome/components/image/__init__.py index b629779690..b946a86bc4 100644 --- a/esphome/components/image/__init__.py +++ b/esphome/components/image/__init__.py @@ -39,7 +39,7 @@ IMAGE_SCHEMA = cv.Schema( CONFIG_SCHEMA = cv.All(font.validate_pillow_installed, IMAGE_SCHEMA) -def to_code(config): +async def to_code(config): from PIL import Image path = CORE.relative_config_path(config[CONF_FILE]) diff --git a/esphome/components/ina219/sensor.py b/esphome/components/ina219/sensor.py index d122754b88..29241c062e 100644 --- a/esphome/components/ina219/sensor.py +++ b/esphome/components/ina219/sensor.py @@ -58,27 +58,27 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) cg.add(var.set_shunt_resistance_ohm(config[CONF_SHUNT_RESISTANCE])) cg.add(var.set_max_current_a(config[CONF_MAX_CURRENT])) cg.add(var.set_max_voltage_v(config[CONF_MAX_VOLTAGE])) if CONF_BUS_VOLTAGE in config: - sens = yield sensor.new_sensor(config[CONF_BUS_VOLTAGE]) + sens = await sensor.new_sensor(config[CONF_BUS_VOLTAGE]) cg.add(var.set_bus_voltage_sensor(sens)) if CONF_SHUNT_VOLTAGE in config: - sens = yield sensor.new_sensor(config[CONF_SHUNT_VOLTAGE]) + sens = await sensor.new_sensor(config[CONF_SHUNT_VOLTAGE]) cg.add(var.set_shunt_voltage_sensor(sens)) if CONF_CURRENT in config: - sens = yield sensor.new_sensor(config[CONF_CURRENT]) + sens = await sensor.new_sensor(config[CONF_CURRENT]) cg.add(var.set_current_sensor(sens)) if CONF_POWER in config: - sens = yield sensor.new_sensor(config[CONF_POWER]) + sens = await sensor.new_sensor(config[CONF_POWER]) cg.add(var.set_power_sensor(sens)) diff --git a/esphome/components/ina226/sensor.py b/esphome/components/ina226/sensor.py index 2b7346fbe2..d6d385f5cb 100644 --- a/esphome/components/ina226/sensor.py +++ b/esphome/components/ina226/sensor.py @@ -54,27 +54,27 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) cg.add(var.set_shunt_resistance_ohm(config[CONF_SHUNT_RESISTANCE])) cg.add(var.set_max_current_a(config[CONF_MAX_CURRENT])) if CONF_BUS_VOLTAGE in config: - sens = yield sensor.new_sensor(config[CONF_BUS_VOLTAGE]) + sens = await sensor.new_sensor(config[CONF_BUS_VOLTAGE]) cg.add(var.set_bus_voltage_sensor(sens)) if CONF_SHUNT_VOLTAGE in config: - sens = yield sensor.new_sensor(config[CONF_SHUNT_VOLTAGE]) + sens = await sensor.new_sensor(config[CONF_SHUNT_VOLTAGE]) cg.add(var.set_shunt_voltage_sensor(sens)) if CONF_CURRENT in config: - sens = yield sensor.new_sensor(config[CONF_CURRENT]) + sens = await sensor.new_sensor(config[CONF_CURRENT]) cg.add(var.set_current_sensor(sens)) if CONF_POWER in config: - sens = yield sensor.new_sensor(config[CONF_POWER]) + sens = await sensor.new_sensor(config[CONF_POWER]) cg.add(var.set_power_sensor(sens)) diff --git a/esphome/components/ina3221/sensor.py b/esphome/components/ina3221/sensor.py index c055e149b7..b97022ca27 100644 --- a/esphome/components/ina3221/sensor.py +++ b/esphome/components/ina3221/sensor.py @@ -62,10 +62,10 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) for i, channel in enumerate([CONF_CHANNEL_1, CONF_CHANNEL_2, CONF_CHANNEL_3]): if channel not in config: @@ -74,14 +74,14 @@ def to_code(config): if CONF_SHUNT_RESISTANCE in conf: cg.add(var.set_shunt_resistance(i, conf[CONF_SHUNT_RESISTANCE])) if CONF_BUS_VOLTAGE in conf: - sens = yield sensor.new_sensor(conf[CONF_BUS_VOLTAGE]) + sens = await sensor.new_sensor(conf[CONF_BUS_VOLTAGE]) cg.add(var.set_bus_voltage_sensor(i, sens)) if CONF_SHUNT_VOLTAGE in conf: - sens = yield sensor.new_sensor(conf[CONF_SHUNT_VOLTAGE]) + sens = await sensor.new_sensor(conf[CONF_SHUNT_VOLTAGE]) cg.add(var.set_shunt_voltage_sensor(i, sens)) if CONF_CURRENT in conf: - sens = yield sensor.new_sensor(conf[CONF_CURRENT]) + sens = await sensor.new_sensor(conf[CONF_CURRENT]) cg.add(var.set_current_sensor(i, sens)) if CONF_POWER in conf: - sens = yield sensor.new_sensor(conf[CONF_POWER]) + sens = await sensor.new_sensor(conf[CONF_POWER]) cg.add(var.set_power_sensor(i, sens)) diff --git a/esphome/components/inkbird_ibsth1_mini/sensor.py b/esphome/components/inkbird_ibsth1_mini/sensor.py index c67acb8595..cc12be3bf4 100644 --- a/esphome/components/inkbird_ibsth1_mini/sensor.py +++ b/esphome/components/inkbird_ibsth1_mini/sensor.py @@ -44,19 +44,19 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield esp32_ble_tracker.register_ble_device(var, config) + await cg.register_component(var, config) + await esp32_ble_tracker.register_ble_device(var, config) cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex)) 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)) 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)) 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)) diff --git a/esphome/components/inkplate6/display.py b/esphome/components/inkplate6/display.py index 323936d2c4..8e00a69751 100644 --- a/esphome/components/inkplate6/display.py +++ b/esphome/components/inkplate6/display.py @@ -94,15 +94,15 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield display.register_display(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await display.register_display(var, config) + await i2c.register_i2c_device(var, config) if CONF_LAMBDA in config: - lambda_ = yield cg.process_lambda( + lambda_ = await cg.process_lambda( config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void ) cg.add(var.set_writer(lambda_)) @@ -111,61 +111,61 @@ def to_code(config): cg.add(var.set_partial_updating(config[CONF_PARTIAL_UPDATING])) cg.add(var.set_full_update_every(config[CONF_FULL_UPDATE_EVERY])) - ckv = yield cg.gpio_pin_expression(config[CONF_CKV_PIN]) + ckv = await cg.gpio_pin_expression(config[CONF_CKV_PIN]) cg.add(var.set_ckv_pin(ckv)) - gmod = yield cg.gpio_pin_expression(config[CONF_GMOD_PIN]) + gmod = await cg.gpio_pin_expression(config[CONF_GMOD_PIN]) cg.add(var.set_gmod_pin(gmod)) - gpio0_enable = yield cg.gpio_pin_expression(config[CONF_GPIO0_ENABLE_PIN]) + gpio0_enable = await cg.gpio_pin_expression(config[CONF_GPIO0_ENABLE_PIN]) cg.add(var.set_gpio0_enable_pin(gpio0_enable)) - oe = yield cg.gpio_pin_expression(config[CONF_OE_PIN]) + oe = await cg.gpio_pin_expression(config[CONF_OE_PIN]) cg.add(var.set_oe_pin(oe)) - powerup = yield cg.gpio_pin_expression(config[CONF_POWERUP_PIN]) + powerup = await cg.gpio_pin_expression(config[CONF_POWERUP_PIN]) cg.add(var.set_powerup_pin(powerup)) - sph = yield cg.gpio_pin_expression(config[CONF_SPH_PIN]) + sph = await cg.gpio_pin_expression(config[CONF_SPH_PIN]) cg.add(var.set_sph_pin(sph)) - spv = yield cg.gpio_pin_expression(config[CONF_SPV_PIN]) + spv = await cg.gpio_pin_expression(config[CONF_SPV_PIN]) cg.add(var.set_spv_pin(spv)) - vcom = yield cg.gpio_pin_expression(config[CONF_VCOM_PIN]) + vcom = await cg.gpio_pin_expression(config[CONF_VCOM_PIN]) cg.add(var.set_vcom_pin(vcom)) - wakeup = yield cg.gpio_pin_expression(config[CONF_WAKEUP_PIN]) + wakeup = await cg.gpio_pin_expression(config[CONF_WAKEUP_PIN]) cg.add(var.set_wakeup_pin(wakeup)) - cl = yield cg.gpio_pin_expression(config[CONF_CL_PIN]) + cl = await cg.gpio_pin_expression(config[CONF_CL_PIN]) cg.add(var.set_cl_pin(cl)) - le = yield cg.gpio_pin_expression(config[CONF_LE_PIN]) + le = await cg.gpio_pin_expression(config[CONF_LE_PIN]) cg.add(var.set_le_pin(le)) - display_data_0 = yield cg.gpio_pin_expression(config[CONF_DISPLAY_DATA_0_PIN]) + display_data_0 = await cg.gpio_pin_expression(config[CONF_DISPLAY_DATA_0_PIN]) cg.add(var.set_display_data_0_pin(display_data_0)) - display_data_1 = yield cg.gpio_pin_expression(config[CONF_DISPLAY_DATA_1_PIN]) + display_data_1 = await cg.gpio_pin_expression(config[CONF_DISPLAY_DATA_1_PIN]) cg.add(var.set_display_data_1_pin(display_data_1)) - display_data_2 = yield cg.gpio_pin_expression(config[CONF_DISPLAY_DATA_2_PIN]) + display_data_2 = await cg.gpio_pin_expression(config[CONF_DISPLAY_DATA_2_PIN]) cg.add(var.set_display_data_2_pin(display_data_2)) - display_data_3 = yield cg.gpio_pin_expression(config[CONF_DISPLAY_DATA_3_PIN]) + display_data_3 = await cg.gpio_pin_expression(config[CONF_DISPLAY_DATA_3_PIN]) cg.add(var.set_display_data_3_pin(display_data_3)) - display_data_4 = yield cg.gpio_pin_expression(config[CONF_DISPLAY_DATA_4_PIN]) + display_data_4 = await cg.gpio_pin_expression(config[CONF_DISPLAY_DATA_4_PIN]) cg.add(var.set_display_data_4_pin(display_data_4)) - display_data_5 = yield cg.gpio_pin_expression(config[CONF_DISPLAY_DATA_5_PIN]) + display_data_5 = await cg.gpio_pin_expression(config[CONF_DISPLAY_DATA_5_PIN]) cg.add(var.set_display_data_5_pin(display_data_5)) - display_data_6 = yield cg.gpio_pin_expression(config[CONF_DISPLAY_DATA_6_PIN]) + display_data_6 = await cg.gpio_pin_expression(config[CONF_DISPLAY_DATA_6_PIN]) cg.add(var.set_display_data_6_pin(display_data_6)) - display_data_7 = yield cg.gpio_pin_expression(config[CONF_DISPLAY_DATA_7_PIN]) + display_data_7 = await cg.gpio_pin_expression(config[CONF_DISPLAY_DATA_7_PIN]) cg.add(var.set_display_data_7_pin(display_data_7)) cg.add_build_flag("-DBOARD_HAS_PSRAM") diff --git a/esphome/components/integration/sensor.py b/esphome/components/integration/sensor.py index 81b588610e..5ce5352fd0 100644 --- a/esphome/components/integration/sensor.py +++ b/esphome/components/integration/sensor.py @@ -41,13 +41,13 @@ CONFIG_SCHEMA = sensor.SENSOR_SCHEMA.extend( ).extend(cv.COMPONENT_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) - sens = yield cg.get_variable(config[CONF_SENSOR]) + sens = await cg.get_variable(config[CONF_SENSOR]) cg.add(var.set_sensor(sens)) cg.add(var.set_time(config[CONF_TIME_UNIT])) cg.add(var.set_method(config[CONF_INTEGRATION_METHOD])) diff --git a/esphome/components/interval/__init__.py b/esphome/components/interval/__init__.py index 7d04a9e9ab..4514f80ba3 100644 --- a/esphome/components/interval/__init__.py +++ b/esphome/components/interval/__init__.py @@ -19,10 +19,10 @@ CONFIG_SCHEMA = automation.validate_automation( ) -def to_code(config): +async def to_code(config): for conf in config: var = cg.new_Pvariable(conf[CONF_ID]) - yield cg.register_component(var, conf) - yield automation.build_automation(var, [], conf) + await cg.register_component(var, conf) + await automation.build_automation(var, [], conf) cg.add(var.set_update_interval(conf[CONF_INTERVAL])) diff --git a/esphome/components/lcd_gpio/display.py b/esphome/components/lcd_gpio/display.py index 28c6df2efd..6b0a2f69de 100644 --- a/esphome/components/lcd_gpio/display.py +++ b/esphome/components/lcd_gpio/display.py @@ -39,25 +39,25 @@ CONFIG_SCHEMA = lcd_base.LCD_SCHEMA.extend( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield lcd_base.setup_lcd_display(var, config) + await lcd_base.setup_lcd_display(var, config) pins_ = [] for conf in config[CONF_DATA_PINS]: - pins_.append((yield cg.gpio_pin_expression(conf))) + pins_.append((await cg.gpio_pin_expression(conf))) cg.add(var.set_data_pins(*pins_)) - enable = yield cg.gpio_pin_expression(config[CONF_ENABLE_PIN]) + enable = await cg.gpio_pin_expression(config[CONF_ENABLE_PIN]) cg.add(var.set_enable_pin(enable)) - rs = yield cg.gpio_pin_expression(config[CONF_RS_PIN]) + rs = await cg.gpio_pin_expression(config[CONF_RS_PIN]) cg.add(var.set_rs_pin(rs)) if CONF_RW_PIN in config: - rw = yield cg.gpio_pin_expression(config[CONF_RW_PIN]) + rw = await cg.gpio_pin_expression(config[CONF_RW_PIN]) cg.add(var.set_rw_pin(rw)) if CONF_LAMBDA in config: - lambda_ = yield cg.process_lambda( + lambda_ = await cg.process_lambda( config[CONF_LAMBDA], [(GPIOLCDDisplay.operator("ref"), "it")], return_type=cg.void, diff --git a/esphome/components/lcd_pcf8574/display.py b/esphome/components/lcd_pcf8574/display.py index 6499a8369e..5d9dd7adba 100644 --- a/esphome/components/lcd_pcf8574/display.py +++ b/esphome/components/lcd_pcf8574/display.py @@ -18,13 +18,13 @@ CONFIG_SCHEMA = lcd_base.LCD_SCHEMA.extend( ).extend(i2c.i2c_device_schema(0x3F)) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield lcd_base.setup_lcd_display(var, config) - yield i2c.register_i2c_device(var, config) + await lcd_base.setup_lcd_display(var, config) + await i2c.register_i2c_device(var, config) if CONF_LAMBDA in config: - lambda_ = yield cg.process_lambda( + lambda_ = await cg.process_lambda( config[CONF_LAMBDA], [(PCF8574LCDDisplay.operator("ref"), "it")], return_type=cg.void, diff --git a/esphome/components/ledc/output.py b/esphome/components/ledc/output.py index df746fff4f..4431be2ed5 100644 --- a/esphome/components/ledc/output.py +++ b/esphome/components/ledc/output.py @@ -58,11 +58,11 @@ CONFIG_SCHEMA = output.FLOAT_OUTPUT_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): - gpio = yield cg.gpio_pin_expression(config[CONF_PIN]) +async def to_code(config): + gpio = await cg.gpio_pin_expression(config[CONF_PIN]) var = cg.new_Pvariable(config[CONF_ID], gpio) - yield cg.register_component(var, config) - yield output.register_output(var, config) + await cg.register_component(var, config) + await output.register_output(var, config) if CONF_CHANNEL in config: cg.add(var.set_channel(config[CONF_CHANNEL])) cg.add(var.set_frequency(config[CONF_FREQUENCY])) diff --git a/esphome/components/max31855/sensor.py b/esphome/components/max31855/sensor.py index 5d3fa461b1..55de8d681e 100644 --- a/esphome/components/max31855/sensor.py +++ b/esphome/components/max31855/sensor.py @@ -29,11 +29,11 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield spi.register_spi_device(var, config) - yield sensor.register_sensor(var, config) + await cg.register_component(var, config) + await spi.register_spi_device(var, config) + await sensor.register_sensor(var, config) if CONF_REFERENCE_TEMPERATURE in config: - tc_ref = yield sensor.new_sensor(config[CONF_REFERENCE_TEMPERATURE]) + tc_ref = await sensor.new_sensor(config[CONF_REFERENCE_TEMPERATURE]) cg.add(var.set_reference_sensor(tc_ref)) diff --git a/esphome/components/max31856/sensor.py b/esphome/components/max31856/sensor.py index afbb637609..5c7b7f1f0e 100644 --- a/esphome/components/max31856/sensor.py +++ b/esphome/components/max31856/sensor.py @@ -35,9 +35,9 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield spi.register_spi_device(var, config) - yield sensor.register_sensor(var, config) + await cg.register_component(var, config) + await spi.register_spi_device(var, config) + await sensor.register_sensor(var, config) cg.add(var.set_filter(config[CONF_MAINS_FILTER])) diff --git a/esphome/components/max31865/sensor.py b/esphome/components/max31865/sensor.py index bebc42c95e..addedc8296 100644 --- a/esphome/components/max31865/sensor.py +++ b/esphome/components/max31865/sensor.py @@ -45,11 +45,11 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield spi.register_spi_device(var, config) - yield sensor.register_sensor(var, config) + await cg.register_component(var, config) + await spi.register_spi_device(var, config) + await sensor.register_sensor(var, config) cg.add(var.set_reference_resistance(config[CONF_REFERENCE_RESISTANCE])) cg.add(var.set_nominal_resistance(config[CONF_RTD_NOMINAL_RESISTANCE])) cg.add(var.set_filter(config[CONF_MAINS_FILTER])) diff --git a/esphome/components/max6675/sensor.py b/esphome/components/max6675/sensor.py index 0713654f84..6697f2ae90 100644 --- a/esphome/components/max6675/sensor.py +++ b/esphome/components/max6675/sensor.py @@ -20,8 +20,8 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield spi.register_spi_device(var, config) - yield sensor.register_sensor(var, config) + await cg.register_component(var, config) + await spi.register_spi_device(var, config) + await sensor.register_sensor(var, config) diff --git a/esphome/components/max7219/display.py b/esphome/components/max7219/display.py index fba4d7ca76..391d033f24 100644 --- a/esphome/components/max7219/display.py +++ b/esphome/components/max7219/display.py @@ -27,18 +27,18 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield spi.register_spi_device(var, config) - yield display.register_display(var, config) + await cg.register_component(var, config) + await spi.register_spi_device(var, config) + await display.register_display(var, config) cg.add(var.set_num_chips(config[CONF_NUM_CHIPS])) cg.add(var.set_intensity(config[CONF_INTENSITY])) cg.add(var.set_reverse(config[CONF_REVERSE_ENABLE])) if CONF_LAMBDA in config: - lambda_ = yield cg.process_lambda( + lambda_ = await cg.process_lambda( config[CONF_LAMBDA], [(MAX7219ComponentRef, "it")], return_type=cg.void ) cg.add(var.set_writer(lambda_)) diff --git a/esphome/components/max7219digit/display.py b/esphome/components/max7219digit/display.py index 4863312b5a..e1ca128699 100644 --- a/esphome/components/max7219digit/display.py +++ b/esphome/components/max7219digit/display.py @@ -60,11 +60,11 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield spi.register_spi_device(var, config) - yield display.register_display(var, config) + await cg.register_component(var, config) + await spi.register_spi_device(var, config) + await display.register_display(var, config) cg.add(var.set_num_chips(config[CONF_NUM_CHIPS])) cg.add(var.set_intensity(config[CONF_INTENSITY])) @@ -77,7 +77,7 @@ def to_code(config): cg.add(var.set_reverse(config[CONF_REVERSE_ENABLE])) if CONF_LAMBDA in config: - lambda_ = yield cg.process_lambda( + lambda_ = await cg.process_lambda( config[CONF_LAMBDA], [(MAX7219ComponentRef, "it")], return_type=cg.void ) cg.add(var.set_writer(lambda_)) diff --git a/esphome/components/mcp23008/__init__.py b/esphome/components/mcp23008/__init__.py index ae43e9ff0a..a534c9f87f 100644 --- a/esphome/components/mcp23008/__init__.py +++ b/esphome/components/mcp23008/__init__.py @@ -23,6 +23,6 @@ CONFIG_SCHEMA = ( ) -def to_code(config): - var = yield mcp23xxx_base.register_mcp23xxx(config) - yield i2c.register_i2c_device(var, config) +async def to_code(config): + var = await mcp23xxx_base.register_mcp23xxx(config) + await i2c.register_i2c_device(var, config) diff --git a/esphome/components/mcp23016/__init__.py b/esphome/components/mcp23016/__init__.py index 2aa29c9cde..d1f0dad2b7 100644 --- a/esphome/components/mcp23016/__init__.py +++ b/esphome/components/mcp23016/__init__.py @@ -28,10 +28,10 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) CONF_MCP23016 = "mcp23016" diff --git a/esphome/components/mcp23017/__init__.py b/esphome/components/mcp23017/__init__.py index a86133e232..42fc37dd1d 100644 --- a/esphome/components/mcp23017/__init__.py +++ b/esphome/components/mcp23017/__init__.py @@ -23,6 +23,6 @@ CONFIG_SCHEMA = ( ) -def to_code(config): - var = yield mcp23xxx_base.register_mcp23xxx(config) - yield i2c.register_i2c_device(var, config) +async def to_code(config): + var = await mcp23xxx_base.register_mcp23xxx(config) + await i2c.register_i2c_device(var, config) diff --git a/esphome/components/mcp23s08/__init__.py b/esphome/components/mcp23s08/__init__.py index cfeb65de9b..4d3998def8 100644 --- a/esphome/components/mcp23s08/__init__.py +++ b/esphome/components/mcp23s08/__init__.py @@ -26,7 +26,7 @@ CONFIG_SCHEMA = ( ) -def to_code(config): - var = yield mcp23xxx_base.register_mcp23xxx(config) +async def to_code(config): + var = await mcp23xxx_base.register_mcp23xxx(config) cg.add(var.set_device_address(config[CONF_DEVICEADDRESS])) - yield spi.register_spi_device(var, config) + await spi.register_spi_device(var, config) diff --git a/esphome/components/mcp23s17/__init__.py b/esphome/components/mcp23s17/__init__.py index c38bd2617a..9e199f79c4 100644 --- a/esphome/components/mcp23s17/__init__.py +++ b/esphome/components/mcp23s17/__init__.py @@ -26,7 +26,7 @@ CONFIG_SCHEMA = ( ) -def to_code(config): - var = yield mcp23xxx_base.register_mcp23xxx(config) +async def to_code(config): + var = await mcp23xxx_base.register_mcp23xxx(config) cg.add(var.set_device_address(config[CONF_DEVICEADDRESS])) - yield spi.register_spi_device(var, config) + await spi.register_spi_device(var, config) diff --git a/esphome/components/mcp2515/canbus.py b/esphome/components/mcp2515/canbus.py index 0fc679d17a..c410c1af69 100644 --- a/esphome/components/mcp2515/canbus.py +++ b/esphome/components/mcp2515/canbus.py @@ -35,10 +35,10 @@ CONFIG_SCHEMA = canbus.CANBUS_SCHEMA.extend( ).extend(spi.spi_device_schema(True)) -def to_code(config): +async def to_code(config): rhs = mcp2515.new() var = cg.Pvariable(config[CONF_ID], rhs) - yield canbus.register_canbus(var, config) + await canbus.register_canbus(var, config) if CONF_CLOCK in config: canclock = CAN_CLOCK[config[CONF_CLOCK]] cg.add(var.set_mcp_clock(canclock)) @@ -46,4 +46,4 @@ def to_code(config): mode = MCP_MODE[config[CONF_MODE]] cg.add(var.set_mcp_mode(mode)) - yield spi.register_spi_device(var, config) + await spi.register_spi_device(var, config) diff --git a/esphome/components/mcp3008/__init__.py b/esphome/components/mcp3008/__init__.py index 6a0410a75b..24a48664c1 100644 --- a/esphome/components/mcp3008/__init__.py +++ b/esphome/components/mcp3008/__init__.py @@ -19,7 +19,7 @@ CONFIG_SCHEMA = cv.Schema( ).extend(spi.spi_device_schema(cs_pin_required=True)) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield spi.register_spi_device(var, config) + await cg.register_component(var, config) + await spi.register_spi_device(var, config) diff --git a/esphome/components/mcp3008/sensor.py b/esphome/components/mcp3008/sensor.py index b146158552..4fc9b83afb 100644 --- a/esphome/components/mcp3008/sensor.py +++ b/esphome/components/mcp3008/sensor.py @@ -24,8 +24,8 @@ CONFIG_SCHEMA = sensor.SENSOR_SCHEMA.extend( ).extend(cv.polling_component_schema("1s")) -def to_code(config): - parent = yield cg.get_variable(config[CONF_MCP3008_ID]) +async def to_code(config): + parent = await cg.get_variable(config[CONF_MCP3008_ID]) var = cg.new_Pvariable( config[CONF_ID], parent, @@ -33,5 +33,5 @@ def to_code(config): config[CONF_NUMBER], config[CONF_REFERENCE_VOLTAGE], ) - yield cg.register_component(var, config) - yield sensor.register_sensor(var, config) + await cg.register_component(var, config) + await sensor.register_sensor(var, config) diff --git a/esphome/components/mcp4725/output.py b/esphome/components/mcp4725/output.py index a010ca9970..8f8b80d927 100644 --- a/esphome/components/mcp4725/output.py +++ b/esphome/components/mcp4725/output.py @@ -19,8 +19,8 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) - yield output.register_output(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) + await output.register_output(var, config) diff --git a/esphome/components/mcp9808/sensor.py b/esphome/components/mcp9808/sensor.py index 4973d41ff5..f11d5cd755 100644 --- a/esphome/components/mcp9808/sensor.py +++ b/esphome/components/mcp9808/sensor.py @@ -23,8 +23,8 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) - yield sensor.register_sensor(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) + await sensor.register_sensor(var, config) diff --git a/esphome/components/mhz19/sensor.py b/esphome/components/mhz19/sensor.py index 6989814ada..abe33cae7e 100644 --- a/esphome/components/mhz19/sensor.py +++ b/esphome/components/mhz19/sensor.py @@ -45,17 +45,17 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield uart.register_uart_device(var, config) + await cg.register_component(var, config) + await uart.register_uart_device(var, config) 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_AUTOMATIC_BASELINE_CALIBRATION in config: diff --git a/esphome/components/midea_ac/climate.py b/esphome/components/midea_ac/climate.py index 94aed91d4c..e0128febfb 100644 --- a/esphome/components/midea_ac/climate.py +++ b/esphome/components/midea_ac/climate.py @@ -49,21 +49,21 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield climate.register_climate(var, config) - paren = yield cg.get_variable(config[CONF_MIDEA_DONGLE_ID]) + await cg.register_component(var, config) + await climate.register_climate(var, config) + paren = await cg.get_variable(config[CONF_MIDEA_DONGLE_ID]) cg.add(var.set_midea_dongle_parent(paren)) cg.add(var.set_beeper_feedback(config[CONF_BEEPER])) cg.add(var.set_swing_horizontal(config[CONF_SWING_HORIZONTAL])) cg.add(var.set_swing_both(config[CONF_SWING_BOTH])) if CONF_OUTDOOR_TEMPERATURE in config: - sens = yield sensor.new_sensor(config[CONF_OUTDOOR_TEMPERATURE]) + sens = await sensor.new_sensor(config[CONF_OUTDOOR_TEMPERATURE]) cg.add(var.set_outdoor_temperature_sensor(sens)) if CONF_POWER_USAGE in config: - sens = yield sensor.new_sensor(config[CONF_POWER_USAGE]) + sens = await sensor.new_sensor(config[CONF_POWER_USAGE]) cg.add(var.set_power_sensor(sens)) if CONF_HUMIDITY_SETPOINT in config: - sens = yield sensor.new_sensor(config[CONF_HUMIDITY_SETPOINT]) + sens = await sensor.new_sensor(config[CONF_HUMIDITY_SETPOINT]) cg.add(var.set_humidity_setpoint_sensor(sens)) diff --git a/esphome/components/midea_dongle/__init__.py b/esphome/components/midea_dongle/__init__.py index 3efeb2661d..daa8ea6657 100644 --- a/esphome/components/midea_dongle/__init__.py +++ b/esphome/components/midea_dongle/__init__.py @@ -23,8 +23,8 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield uart.register_uart_device(var, config) + await cg.register_component(var, config) + await uart.register_uart_device(var, config) cg.add(var.use_strength_icon(config[CONF_STRENGTH_ICON])) diff --git a/esphome/components/mitsubishi/climate.py b/esphome/components/mitsubishi/climate.py index f150985d28..0df17a5d16 100644 --- a/esphome/components/mitsubishi/climate.py +++ b/esphome/components/mitsubishi/climate.py @@ -16,6 +16,6 @@ CONFIG_SCHEMA = climate_ir.CLIMATE_IR_SCHEMA.extend( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield climate_ir.register_climate_ir(var, config) + await climate_ir.register_climate_ir(var, config) diff --git a/esphome/components/modbus/__init__.py b/esphome/components/modbus/__init__.py index e71f196fca..c8e58431da 100644 --- a/esphome/components/modbus/__init__.py +++ b/esphome/components/modbus/__init__.py @@ -23,12 +23,12 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): cg.add_global(modbus_ns.using) var = cg.new_Pvariable(config[CONF_ID]) - 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) def modbus_device_schema(default_address): diff --git a/esphome/components/monochromatic/light.py b/esphome/components/monochromatic/light.py index 32d9981a57..8f13f58f89 100644 --- a/esphome/components/monochromatic/light.py +++ b/esphome/components/monochromatic/light.py @@ -16,9 +16,9 @@ CONFIG_SCHEMA = light.BRIGHTNESS_ONLY_LIGHT_SCHEMA.extend( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_OUTPUT_ID]) - yield light.register_light(var, config) + await light.register_light(var, config) - out = yield cg.get_variable(config[CONF_OUTPUT]) + out = await cg.get_variable(config[CONF_OUTPUT]) cg.add(var.set_output(out)) diff --git a/esphome/components/mpr121/__init__.py b/esphome/components/mpr121/__init__.py index eb3043c2b1..dabfb47ad6 100644 --- a/esphome/components/mpr121/__init__.py +++ b/esphome/components/mpr121/__init__.py @@ -35,11 +35,11 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) cg.add(var.set_touch_debounce(config[CONF_TOUCH_DEBOUNCE])) cg.add(var.set_release_debounce(config[CONF_RELEASE_DEBOUNCE])) cg.add(var.set_touch_threshold(config[CONF_TOUCH_THRESHOLD])) cg.add(var.set_release_threshold(config[CONF_RELEASE_THRESHOLD])) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) diff --git a/esphome/components/mpr121/binary_sensor.py b/esphome/components/mpr121/binary_sensor.py index 68e56075f5..20b80e063e 100644 --- a/esphome/components/mpr121/binary_sensor.py +++ b/esphome/components/mpr121/binary_sensor.py @@ -24,10 +24,10 @@ CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield binary_sensor.register_binary_sensor(var, config) - hub = yield cg.get_variable(config[CONF_MPR121_ID]) + await binary_sensor.register_binary_sensor(var, config) + hub = await cg.get_variable(config[CONF_MPR121_ID]) cg.add(var.set_channel(config[CONF_CHANNEL])) if CONF_TOUCH_THRESHOLD in config: diff --git a/esphome/components/mpu6050/sensor.py b/esphome/components/mpu6050/sensor.py index 11d491006e..2054897dfb 100644 --- a/esphome/components/mpu6050/sensor.py +++ b/esphome/components/mpu6050/sensor.py @@ -56,21 +56,21 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) for d in ["x", "y", "z"]: accel_key = f"accel_{d}" if accel_key in config: - sens = yield sensor.new_sensor(config[accel_key]) + sens = await sensor.new_sensor(config[accel_key]) cg.add(getattr(var, f"set_accel_{d}_sensor")(sens)) accel_key = f"gyro_{d}" if accel_key in config: - sens = yield sensor.new_sensor(config[accel_key]) + sens = await sensor.new_sensor(config[accel_key]) cg.add(getattr(var, f"set_gyro_{d}_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)) diff --git a/esphome/components/mqtt_subscribe/sensor/__init__.py b/esphome/components/mqtt_subscribe/sensor/__init__.py index 00c2d324d3..25a2079f81 100644 --- a/esphome/components/mqtt_subscribe/sensor/__init__.py +++ b/esphome/components/mqtt_subscribe/sensor/__init__.py @@ -32,12 +32,12 @@ CONFIG_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) - parent = yield cg.get_variable(config[CONF_MQTT_PARENT_ID]) + parent = await cg.get_variable(config[CONF_MQTT_PARENT_ID]) cg.add(var.set_parent(parent)) cg.add(var.set_topic(config[CONF_TOPIC])) cg.add(var.set_qos(config[CONF_QOS])) diff --git a/esphome/components/mqtt_subscribe/text_sensor/__init__.py b/esphome/components/mqtt_subscribe/text_sensor/__init__.py index b5f2c4307b..477e4dec45 100644 --- a/esphome/components/mqtt_subscribe/text_sensor/__init__.py +++ b/esphome/components/mqtt_subscribe/text_sensor/__init__.py @@ -21,12 +21,12 @@ CONFIG_SCHEMA = text_sensor.TEXT_SENSOR_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield text_sensor.register_text_sensor(var, config) + await cg.register_component(var, config) + await text_sensor.register_text_sensor(var, config) - parent = yield cg.get_variable(config[CONF_MQTT_PARENT_ID]) + parent = await cg.get_variable(config[CONF_MQTT_PARENT_ID]) cg.add(var.set_parent(parent)) cg.add(var.set_topic(config[CONF_TOPIC])) cg.add(var.set_qos(config[CONF_QOS])) diff --git a/esphome/components/ms5611/sensor.py b/esphome/components/ms5611/sensor.py index d180008140..ebf1a949e7 100644 --- a/esphome/components/ms5611/sensor.py +++ b/esphome/components/ms5611/sensor.py @@ -37,15 +37,15 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, 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_sensor(sens)) if CONF_PRESSURE in config: - sens = yield sensor.new_sensor(config[CONF_PRESSURE]) + sens = await sensor.new_sensor(config[CONF_PRESSURE]) cg.add(var.set_pressure_sensor(sens)) diff --git a/esphome/components/my9231/__init__.py b/esphome/components/my9231/__init__.py index ed1edd7b2d..58419450cd 100644 --- a/esphome/components/my9231/__init__.py +++ b/esphome/components/my9231/__init__.py @@ -27,13 +27,13 @@ CONFIG_SCHEMA = cv.Schema( ).extend(cv.COMPONENT_SCHEMA) -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) - di = yield cg.gpio_pin_expression(config[CONF_DATA_PIN]) + di = await cg.gpio_pin_expression(config[CONF_DATA_PIN]) cg.add(var.set_pin_di(di)) - dcki = yield cg.gpio_pin_expression(config[CONF_CLOCK_PIN]) + dcki = await cg.gpio_pin_expression(config[CONF_CLOCK_PIN]) cg.add(var.set_pin_dcki(dcki)) cg.add(var.set_num_channels(config[CONF_NUM_CHANNELS])) diff --git a/esphome/components/my9231/output.py b/esphome/components/my9231/output.py index 30db84064d..a3c16fd49a 100644 --- a/esphome/components/my9231/output.py +++ b/esphome/components/my9231/output.py @@ -18,10 +18,10 @@ CONFIG_SCHEMA = output.FLOAT_OUTPUT_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield output.register_output(var, config) + await output.register_output(var, config) - parent = yield cg.get_variable(config[CONF_MY9231_ID]) + parent = await cg.get_variable(config[CONF_MY9231_ID]) cg.add(var.set_parent(parent)) cg.add(var.set_channel(config[CONF_CHANNEL])) diff --git a/esphome/components/neopixelbus/light.py b/esphome/components/neopixelbus/light.py index ae3a941bf9..f643b476e8 100644 --- a/esphome/components/neopixelbus/light.py +++ b/esphome/components/neopixelbus/light.py @@ -181,7 +181,7 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): has_white = "W" in config[CONF_TYPE] template = cg.TemplateArguments(getattr(cg.global_ns, format_method(config))) if has_white: @@ -190,8 +190,8 @@ def to_code(config): out_type = NeoPixelRGBLightOutput.template(template) rhs = out_type.new() var = cg.Pvariable(config[CONF_OUTPUT_ID], rhs, out_type) - yield light.register_light(var, config) - yield cg.register_component(var, config) + await light.register_light(var, config) + await cg.register_component(var, config) if CONF_PIN in config: cg.add(var.add_leds(config[CONF_NUM_LEDS], config[CONF_PIN])) diff --git a/esphome/components/nextion/binary_sensor.py b/esphome/components/nextion/binary_sensor.py index e822b65eb5..ed4e8d832a 100644 --- a/esphome/components/nextion/binary_sensor.py +++ b/esphome/components/nextion/binary_sensor.py @@ -23,11 +23,11 @@ CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield binary_sensor.register_binary_sensor(var, config) + await binary_sensor.register_binary_sensor(var, config) - hub = yield cg.get_variable(config[CONF_NEXTION_ID]) + hub = await cg.get_variable(config[CONF_NEXTION_ID]) cg.add(hub.register_touch_component(var)) cg.add(var.set_component_id(config[CONF_COMPONENT_ID])) diff --git a/esphome/components/nextion/display.py b/esphome/components/nextion/display.py index 483395fe2f..7d7018a4c4 100644 --- a/esphome/components/nextion/display.py +++ b/esphome/components/nextion/display.py @@ -22,17 +22,17 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield uart.register_uart_device(var, config) + await cg.register_component(var, config) + await uart.register_uart_device(var, config) if CONF_BRIGHTNESS in config: cg.add(var.set_brightness(config[CONF_BRIGHTNESS])) if CONF_LAMBDA in config: - lambda_ = yield cg.process_lambda( + lambda_ = await cg.process_lambda( config[CONF_LAMBDA], [(NextionRef, "it")], return_type=cg.void ) cg.add(var.set_writer(lambda_)) - yield display.register_display(var, config) + await display.register_display(var, config) diff --git a/esphome/components/ntc/sensor.py b/esphome/components/ntc/sensor.py index f3505eec53..d83afae350 100644 --- a/esphome/components/ntc/sensor.py +++ b/esphome/components/ntc/sensor.py @@ -130,12 +130,12 @@ CONFIG_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) - sens = yield cg.get_variable(config[CONF_SENSOR]) + sens = await cg.get_variable(config[CONF_SENSOR]) cg.add(var.set_sensor(sens)) calib = config[CONF_CALIBRATION] cg.add(var.set_a(calib[CONF_A])) diff --git a/esphome/components/output/__init__.py b/esphome/components/output/__init__.py index 975fe8adbe..4471794033 100644 --- a/esphome/components/output/__init__.py +++ b/esphome/components/output/__init__.py @@ -100,5 +100,5 @@ async def output_set_level_to_code(config, action_id, template_arg, args): return var -def to_code(config): +async def to_code(config): cg.add_global(output_ns.using) diff --git a/esphome/components/output/switch/__init__.py b/esphome/components/output/switch/__init__.py index 14027de74c..11d073d28c 100644 --- a/esphome/components/output/switch/__init__.py +++ b/esphome/components/output/switch/__init__.py @@ -14,10 +14,10 @@ CONFIG_SCHEMA = switch.SWITCH_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield switch.register_switch(var, config) + await cg.register_component(var, config) + await switch.register_switch(var, config) - output_ = yield cg.get_variable(config[CONF_OUTPUT]) + output_ = await cg.get_variable(config[CONF_OUTPUT]) cg.add(var.set_output(output_)) diff --git a/esphome/components/partition/light.py b/esphome/components/partition/light.py index c366aea033..5ded6b906c 100644 --- a/esphome/components/partition/light.py +++ b/esphome/components/partition/light.py @@ -45,10 +45,10 @@ CONFIG_SCHEMA = light.ADDRESSABLE_LIGHT_SCHEMA.extend( ) -def to_code(config): +async def to_code(config): segments = [] for conf in config[CONF_SEGMENTS]: - var = yield cg.get_variable(conf[CONF_ID]) + var = await cg.get_variable(conf[CONF_ID]) segments.append( AddressableSegment( var, @@ -59,5 +59,5 @@ def to_code(config): ) var = cg.new_Pvariable(config[CONF_OUTPUT_ID], segments) - yield cg.register_component(var, config) - yield light.register_light(var, config) + await cg.register_component(var, config) + await light.register_light(var, config) diff --git a/esphome/components/pca9685/__init__.py b/esphome/components/pca9685/__init__.py index d88012a1cd..1a5ccc3247 100644 --- a/esphome/components/pca9685/__init__.py +++ b/esphome/components/pca9685/__init__.py @@ -23,7 +23,7 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID], config[CONF_FREQUENCY]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) diff --git a/esphome/components/pca9685/output.py b/esphome/components/pca9685/output.py index c3cb88eeaf..40f7b3cd74 100644 --- a/esphome/components/pca9685/output.py +++ b/esphome/components/pca9685/output.py @@ -18,8 +18,8 @@ CONFIG_SCHEMA = output.FLOAT_OUTPUT_SCHEMA.extend( ) -def to_code(config): - paren = yield cg.get_variable(config[CONF_PCA9685_ID]) +async def to_code(config): + paren = await cg.get_variable(config[CONF_PCA9685_ID]) rhs = paren.create_channel(config[CONF_CHANNEL]) var = cg.Pvariable(config[CONF_ID], rhs) - yield output.register_output(var, config) + await output.register_output(var, config) diff --git a/esphome/components/pcd8544/display.py b/esphome/components/pcd8544/display.py index 50cc1b02a8..d0184a58d3 100644 --- a/esphome/components/pcd8544/display.py +++ b/esphome/components/pcd8544/display.py @@ -36,22 +36,22 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield display.register_display(var, config) - yield spi.register_spi_device(var, config) + await cg.register_component(var, config) + await display.register_display(var, config) + await spi.register_spi_device(var, config) - dc = yield cg.gpio_pin_expression(config[CONF_DC_PIN]) + dc = await cg.gpio_pin_expression(config[CONF_DC_PIN]) cg.add(var.set_dc_pin(dc)) - reset = yield cg.gpio_pin_expression(config[CONF_RESET_PIN]) + reset = await cg.gpio_pin_expression(config[CONF_RESET_PIN]) cg.add(var.set_reset_pin(reset)) cg.add(var.set_contrast(config[CONF_CONTRAST])) if CONF_LAMBDA in config: - lambda_ = yield cg.process_lambda( + lambda_ = await cg.process_lambda( config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void ) cg.add(var.set_writer(lambda_)) diff --git a/esphome/components/pcf8574/__init__.py b/esphome/components/pcf8574/__init__.py index 8c028fabc1..9c0aeb2e12 100644 --- a/esphome/components/pcf8574/__init__.py +++ b/esphome/components/pcf8574/__init__.py @@ -31,10 +31,10 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) cg.add(var.set_pcf8575(config[CONF_PCF8575])) diff --git a/esphome/components/pid/climate.py b/esphome/components/pid/climate.py index c16f1726ae..8b9b090893 100644 --- a/esphome/components/pid/climate.py +++ b/esphome/components/pid/climate.py @@ -51,19 +51,19 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield climate.register_climate(var, config) + await cg.register_component(var, config) + await climate.register_climate(var, config) - sens = yield cg.get_variable(config[CONF_SENSOR]) + sens = await cg.get_variable(config[CONF_SENSOR]) cg.add(var.set_sensor(sens)) if CONF_COOL_OUTPUT in config: - out = yield cg.get_variable(config[CONF_COOL_OUTPUT]) + out = await cg.get_variable(config[CONF_COOL_OUTPUT]) cg.add(var.set_cool_output(out)) if CONF_HEAT_OUTPUT in config: - out = yield cg.get_variable(config[CONF_HEAT_OUTPUT]) + out = await cg.get_variable(config[CONF_HEAT_OUTPUT]) cg.add(var.set_heat_output(out)) params = config[CONF_CONTROL_PARAMETERS] cg.add(var.set_kp(params[CONF_KP])) diff --git a/esphome/components/pid/sensor/__init__.py b/esphome/components/pid/sensor/__init__.py index d29fb6b662..d958f239de 100644 --- a/esphome/components/pid/sensor/__init__.py +++ b/esphome/components/pid/sensor/__init__.py @@ -40,11 +40,11 @@ CONFIG_SCHEMA = ( ) -def to_code(config): - parent = yield cg.get_variable(config[CONF_CLIMATE_ID]) +async def to_code(config): + parent = await cg.get_variable(config[CONF_CLIMATE_ID]) var = cg.new_Pvariable(config[CONF_ID]) - yield sensor.register_sensor(var, config) - yield cg.register_component(var, config) + await sensor.register_sensor(var, config) + await cg.register_component(var, config) cg.add(var.set_parent(parent)) cg.add(var.set_type(config[CONF_TYPE])) diff --git a/esphome/components/pmsx003/sensor.py b/esphome/components/pmsx003/sensor.py index 05becfb71f..bdbe2b1811 100644 --- a/esphome/components/pmsx003/sensor.py +++ b/esphome/components/pmsx003/sensor.py @@ -98,33 +98,33 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield uart.register_uart_device(var, config) + await cg.register_component(var, config) + await uart.register_uart_device(var, config) cg.add(var.set_type(config[CONF_TYPE])) if CONF_PM_1_0 in config: - sens = yield sensor.new_sensor(config[CONF_PM_1_0]) + sens = await sensor.new_sensor(config[CONF_PM_1_0]) cg.add(var.set_pm_1_0_sensor(sens)) if CONF_PM_2_5 in config: - sens = yield sensor.new_sensor(config[CONF_PM_2_5]) + sens = await sensor.new_sensor(config[CONF_PM_2_5]) cg.add(var.set_pm_2_5_sensor(sens)) if CONF_PM_10_0 in config: - sens = yield sensor.new_sensor(config[CONF_PM_10_0]) + sens = await sensor.new_sensor(config[CONF_PM_10_0]) cg.add(var.set_pm_10_0_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)) if CONF_FORMALDEHYDE in config: - sens = yield sensor.new_sensor(config[CONF_FORMALDEHYDE]) + sens = await sensor.new_sensor(config[CONF_FORMALDEHYDE]) cg.add(var.set_formaldehyde_sensor(sens)) diff --git a/esphome/components/pn532/binary_sensor.py b/esphome/components/pn532/binary_sensor.py index 5e6bf6c2b9..9a5816b322 100644 --- a/esphome/components/pn532/binary_sensor.py +++ b/esphome/components/pn532/binary_sensor.py @@ -40,11 +40,11 @@ CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield binary_sensor.register_binary_sensor(var, config) + await binary_sensor.register_binary_sensor(var, config) - hub = yield cg.get_variable(config[CONF_PN532_ID]) + hub = await cg.get_variable(config[CONF_PN532_ID]) cg.add(hub.register_tag(var)) addr = [HexInt(int(x, 16)) for x in config[CONF_UID].split("-")] cg.add(var.set_uid(addr)) diff --git a/esphome/components/pn532_i2c/__init__.py b/esphome/components/pn532_i2c/__init__.py index 80995bd018..36af2f8aa0 100644 --- a/esphome/components/pn532_i2c/__init__.py +++ b/esphome/components/pn532_i2c/__init__.py @@ -19,7 +19,7 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield pn532.setup_pn532(var, config) - yield i2c.register_i2c_device(var, config) + await pn532.setup_pn532(var, config) + await i2c.register_i2c_device(var, config) diff --git a/esphome/components/pn532_spi/__init__.py b/esphome/components/pn532_spi/__init__.py index 2abe436291..2683f34ad5 100644 --- a/esphome/components/pn532_spi/__init__.py +++ b/esphome/components/pn532_spi/__init__.py @@ -19,7 +19,7 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield pn532.setup_pn532(var, config) - yield spi.register_spi_device(var, config) + await pn532.setup_pn532(var, config) + await spi.register_spi_device(var, config) diff --git a/esphome/components/power_supply/__init__.py b/esphome/components/power_supply/__init__.py index efed5e0d81..f7dd8bca84 100644 --- a/esphome/components/power_supply/__init__.py +++ b/esphome/components/power_supply/__init__.py @@ -22,11 +22,11 @@ CONFIG_SCHEMA = cv.Schema( ).extend(cv.COMPONENT_SCHEMA) -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 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_enable_time(config[CONF_ENABLE_TIME])) cg.add(var.set_keep_on_time(config[CONF_KEEP_ON_TIME])) diff --git a/esphome/components/prometheus/__init__.py b/esphome/components/prometheus/__init__.py index a1b376c763..f5f166d085 100644 --- a/esphome/components/prometheus/__init__.py +++ b/esphome/components/prometheus/__init__.py @@ -19,10 +19,10 @@ CONFIG_SCHEMA = cv.Schema( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): - paren = yield cg.get_variable(config[CONF_WEB_SERVER_BASE_ID]) +async def to_code(config): + paren = await cg.get_variable(config[CONF_WEB_SERVER_BASE_ID]) cg.add_define("USE_PROMETHEUS") var = cg.new_Pvariable(config[CONF_ID], paren) - yield cg.register_component(var, config) + await cg.register_component(var, config) diff --git a/esphome/components/pulse_counter/sensor.py b/esphome/components/pulse_counter/sensor.py index 0dff2959e8..d6e4dfc1a3 100644 --- a/esphome/components/pulse_counter/sensor.py +++ b/esphome/components/pulse_counter/sensor.py @@ -94,12 +94,12 @@ CONFIG_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)) count = config[CONF_COUNT_MODE] cg.add(var.set_rising_edge_mode(count[CONF_RISING_EDGE])) @@ -107,5 +107,5 @@ def to_code(config): cg.add(var.set_filter_us(config[CONF_INTERNAL_FILTER])) 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)) diff --git a/esphome/components/pulse_meter/sensor.py b/esphome/components/pulse_meter/sensor.py index c7256b2987..9bf4bfddd6 100644 --- a/esphome/components/pulse_meter/sensor.py +++ b/esphome/components/pulse_meter/sensor.py @@ -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)) diff --git a/esphome/components/pulse_width/sensor.py b/esphome/components/pulse_width/sensor.py index 228c5f8dfe..358ffd2962 100644 --- a/esphome/components/pulse_width/sensor.py +++ b/esphome/components/pulse_width/sensor.py @@ -24,10 +24,10 @@ CONFIG_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)) diff --git a/esphome/components/pzem004t/sensor.py b/esphome/components/pzem004t/sensor.py index 1228fc4ab6..b463e58f94 100644 --- a/esphome/components/pzem004t/sensor.py +++ b/esphome/components/pzem004t/sensor.py @@ -46,24 +46,24 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield uart.register_uart_device(var, config) + await cg.register_component(var, config) + await uart.register_uart_device(var, config) if CONF_VOLTAGE in config: conf = config[CONF_VOLTAGE] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_voltage_sensor(sens)) if CONF_CURRENT in config: conf = config[CONF_CURRENT] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_current_sensor(sens)) if CONF_POWER in config: conf = config[CONF_POWER] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_power_sensor(sens)) if CONF_ENERGY in config: conf = config[CONF_ENERGY] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_energy_sensor(sens)) diff --git a/esphome/components/pzemac/sensor.py b/esphome/components/pzemac/sensor.py index aa30549c25..bac2f1b60e 100644 --- a/esphome/components/pzemac/sensor.py +++ b/esphome/components/pzemac/sensor.py @@ -59,32 +59,32 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield modbus.register_modbus_device(var, config) + await cg.register_component(var, config) + await modbus.register_modbus_device(var, config) if CONF_VOLTAGE in config: conf = config[CONF_VOLTAGE] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_voltage_sensor(sens)) if CONF_CURRENT in config: conf = config[CONF_CURRENT] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_current_sensor(sens)) if CONF_POWER in config: conf = config[CONF_POWER] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_power_sensor(sens)) if CONF_ENERGY in config: conf = config[CONF_ENERGY] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_energy_sensor(sens)) if CONF_FREQUENCY in config: conf = config[CONF_FREQUENCY] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_frequency_sensor(sens)) if CONF_POWER_FACTOR in config: conf = config[CONF_POWER_FACTOR] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_power_factor_sensor(sens)) diff --git a/esphome/components/pzemdc/sensor.py b/esphome/components/pzemdc/sensor.py index 962c970359..0bf4c9ba2a 100644 --- a/esphome/components/pzemdc/sensor.py +++ b/esphome/components/pzemdc/sensor.py @@ -40,20 +40,20 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield modbus.register_modbus_device(var, config) + await cg.register_component(var, config) + await modbus.register_modbus_device(var, config) if CONF_VOLTAGE in config: conf = config[CONF_VOLTAGE] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_voltage_sensor(sens)) if CONF_CURRENT in config: conf = config[CONF_CURRENT] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_current_sensor(sens)) if CONF_POWER in config: conf = config[CONF_POWER] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_power_sensor(sens)) diff --git a/esphome/components/qmc5883l/sensor.py b/esphome/components/qmc5883l/sensor.py index 4359427628..395cb681a3 100644 --- a/esphome/components/qmc5883l/sensor.py +++ b/esphome/components/qmc5883l/sensor.py @@ -106,23 +106,23 @@ def auto_data_rate(config): return QMC5883LDatarates[200] -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) cg.add(var.set_oversampling(config[CONF_OVERSAMPLING])) cg.add(var.set_datarate(auto_data_rate(config))) cg.add(var.set_range(config[CONF_RANGE])) if CONF_FIELD_STRENGTH_X in config: - sens = yield sensor.new_sensor(config[CONF_FIELD_STRENGTH_X]) + sens = await sensor.new_sensor(config[CONF_FIELD_STRENGTH_X]) cg.add(var.set_x_sensor(sens)) if CONF_FIELD_STRENGTH_Y in config: - sens = yield sensor.new_sensor(config[CONF_FIELD_STRENGTH_Y]) + sens = await sensor.new_sensor(config[CONF_FIELD_STRENGTH_Y]) cg.add(var.set_y_sensor(sens)) if CONF_FIELD_STRENGTH_Z in config: - sens = yield sensor.new_sensor(config[CONF_FIELD_STRENGTH_Z]) + sens = await sensor.new_sensor(config[CONF_FIELD_STRENGTH_Z]) cg.add(var.set_z_sensor(sens)) if CONF_HEADING in config: - sens = yield sensor.new_sensor(config[CONF_HEADING]) + sens = await sensor.new_sensor(config[CONF_HEADING]) cg.add(var.set_heading_sensor(sens)) diff --git a/esphome/components/rc522/binary_sensor.py b/esphome/components/rc522/binary_sensor.py index 89eef2f976..67d3068599 100644 --- a/esphome/components/rc522/binary_sensor.py +++ b/esphome/components/rc522/binary_sensor.py @@ -2,7 +2,7 @@ import esphome.codegen as cg import esphome.config_validation as cv from esphome.components import binary_sensor from esphome.const import CONF_UID, CONF_ID -from esphome.core import HexInt, coroutine +from esphome.core import HexInt from . import rc522_ns, RC522, CONF_RC522_ID DEPENDENCIES = ["rc522"] @@ -40,12 +40,11 @@ CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend( ) -@coroutine -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield binary_sensor.register_binary_sensor(var, config) + await binary_sensor.register_binary_sensor(var, config) - hub = yield cg.get_variable(config[CONF_RC522_ID]) + hub = await cg.get_variable(config[CONF_RC522_ID]) cg.add(hub.register_tag(var)) addr = [HexInt(int(x, 16)) for x in config[CONF_UID].split("-")] cg.add(var.set_uid(addr)) diff --git a/esphome/components/rc522_i2c/__init__.py b/esphome/components/rc522_i2c/__init__.py index 081536b6b1..e42817352c 100644 --- a/esphome/components/rc522_i2c/__init__.py +++ b/esphome/components/rc522_i2c/__init__.py @@ -20,7 +20,7 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield rc522.setup_rc522(var, config) - yield i2c.register_i2c_device(var, config) + await rc522.setup_rc522(var, config) + await i2c.register_i2c_device(var, config) diff --git a/esphome/components/rc522_spi/__init__.py b/esphome/components/rc522_spi/__init__.py index 2e5630f46d..b21af1d07f 100644 --- a/esphome/components/rc522_spi/__init__.py +++ b/esphome/components/rc522_spi/__init__.py @@ -20,7 +20,7 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield rc522.setup_rc522(var, config) - yield spi.register_spi_device(var, config) + await rc522.setup_rc522(var, config) + await spi.register_spi_device(var, config) diff --git a/esphome/components/rc522_spi/binary_sensor.py b/esphome/components/rc522_spi/binary_sensor.py index f5400a2331..8139f6d2ac 100644 --- a/esphome/components/rc522_spi/binary_sensor.py +++ b/esphome/components/rc522_spi/binary_sensor.py @@ -5,5 +5,5 @@ DEPENDENCIES = ["rc522"] CONFIG_SCHEMA = rc522_binary_sensor.CONFIG_SCHEMA -def to_code(config): - yield rc522_binary_sensor.to_code(config) +async def to_code(config): + await rc522_binary_sensor.to_code(config) diff --git a/esphome/components/rdm6300/__init__.py b/esphome/components/rdm6300/__init__.py index a416d95a12..37ebcb49a9 100644 --- a/esphome/components/rdm6300/__init__.py +++ b/esphome/components/rdm6300/__init__.py @@ -29,12 +29,12 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield uart.register_uart_device(var, config) + await cg.register_component(var, config) + await uart.register_uart_device(var, config) for conf in config.get(CONF_ON_TAG, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID]) cg.add(var.register_trigger(trigger)) - yield automation.build_automation(trigger, [(cg.uint32, "x")], conf) + await automation.build_automation(trigger, [(cg.uint32, "x")], conf) diff --git a/esphome/components/rdm6300/binary_sensor.py b/esphome/components/rdm6300/binary_sensor.py index 02e0b6ceb6..c99a2bfc06 100644 --- a/esphome/components/rdm6300/binary_sensor.py +++ b/esphome/components/rdm6300/binary_sensor.py @@ -20,10 +20,10 @@ CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield binary_sensor.register_binary_sensor(var, config) + await binary_sensor.register_binary_sensor(var, config) - hub = yield cg.get_variable(config[CONF_RDM6300_ID]) + hub = await cg.get_variable(config[CONF_RDM6300_ID]) cg.add(hub.register_card(var)) cg.add(var.set_id(config[CONF_UID])) diff --git a/esphome/components/remote_receiver/__init__.py b/esphome/components/remote_receiver/__init__.py index f29c59b3f8..fed52803cb 100644 --- a/esphome/components/remote_receiver/__init__.py +++ b/esphome/components/remote_receiver/__init__.py @@ -47,16 +47,16 @@ CONFIG_SCHEMA = remote_base.validate_triggers( ) -def to_code(config): - pin = yield cg.gpio_pin_expression(config[CONF_PIN]) +async def to_code(config): + pin = await cg.gpio_pin_expression(config[CONF_PIN]) if CORE.is_esp32: var = cg.new_Pvariable(config[CONF_ID], pin, config[CONF_MEMORY_BLOCKS]) else: var = cg.new_Pvariable(config[CONF_ID], pin) - yield remote_base.build_dumpers(config[CONF_DUMP]) - yield remote_base.build_triggers(config) - yield cg.register_component(var, config) + await remote_base.build_dumpers(config[CONF_DUMP]) + await remote_base.build_triggers(config) + await cg.register_component(var, config) cg.add(var.set_tolerance(config[CONF_TOLERANCE])) cg.add(var.set_buffer_size(config[CONF_BUFFER_SIZE])) diff --git a/esphome/components/remote_receiver/binary_sensor.py b/esphome/components/remote_receiver/binary_sensor.py index 522333584c..62c1d9cb27 100644 --- a/esphome/components/remote_receiver/binary_sensor.py +++ b/esphome/components/remote_receiver/binary_sensor.py @@ -7,7 +7,7 @@ DEPENDENCIES = ["remote_receiver"] CONFIG_SCHEMA = remote_base.validate_binary_sensor -def to_code(config): - var = yield remote_base.build_binary_sensor(config) +async def to_code(config): + var = await remote_base.build_binary_sensor(config) cg.add(var.set_name(config[CONF_NAME])) - yield binary_sensor.register_binary_sensor(var, config) + await binary_sensor.register_binary_sensor(var, config) diff --git a/esphome/components/remote_transmitter/__init__.py b/esphome/components/remote_transmitter/__init__.py index 123af7db97..e09e4c7f55 100644 --- a/esphome/components/remote_transmitter/__init__.py +++ b/esphome/components/remote_transmitter/__init__.py @@ -22,9 +22,9 @@ CONFIG_SCHEMA = cv.Schema( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): - pin = yield cg.gpio_pin_expression(config[CONF_PIN]) +async def to_code(config): + pin = await cg.gpio_pin_expression(config[CONF_PIN]) var = cg.new_Pvariable(config[CONF_ID], pin) - yield cg.register_component(var, config) + await cg.register_component(var, config) cg.add(var.set_carrier_duty_percent(config[CONF_CARRIER_DUTY_PERCENT])) diff --git a/esphome/components/resistance/sensor.py b/esphome/components/resistance/sensor.py index 92a564f68e..8ee00b25be 100644 --- a/esphome/components/resistance/sensor.py +++ b/esphome/components/resistance/sensor.py @@ -31,12 +31,12 @@ CONFIG_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) - sens = yield cg.get_variable(config[CONF_SENSOR]) + sens = await cg.get_variable(config[CONF_SENSOR]) cg.add(var.set_sensor(sens)) cg.add(var.set_configuration(config[CONF_CONFIGURATION])) cg.add(var.set_resistor(config[CONF_RESISTOR])) diff --git a/esphome/components/restart/switch.py b/esphome/components/restart/switch.py index fe170aee61..4f1904e273 100644 --- a/esphome/components/restart/switch.py +++ b/esphome/components/restart/switch.py @@ -17,7 +17,7 @@ CONFIG_SCHEMA = switch.SWITCH_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield switch.register_switch(var, config) + await cg.register_component(var, config) + await switch.register_switch(var, config) diff --git a/esphome/components/rf_bridge/__init__.py b/esphome/components/rf_bridge/__init__.py index b24e19b4bf..1eda99e7af 100644 --- a/esphome/components/rf_bridge/__init__.py +++ b/esphome/components/rf_bridge/__init__.py @@ -79,18 +79,18 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield uart.register_uart_device(var, config) + await cg.register_component(var, config) + await uart.register_uart_device(var, config) for conf in config.get(CONF_ON_CODE_RECEIVED, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) - yield automation.build_automation(trigger, [(RFBridgeData, "data")], conf) + await automation.build_automation(trigger, [(RFBridgeData, "data")], conf) for conf in config.get(CONF_ON_ADVANCED_CODE_RECEIVED, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) - yield automation.build_automation( + await automation.build_automation( trigger, [(RFBridgeAdvancedData, "data")], conf ) diff --git a/esphome/components/rgb/light.py b/esphome/components/rgb/light.py index 33e381d59e..3d07855b8e 100644 --- a/esphome/components/rgb/light.py +++ b/esphome/components/rgb/light.py @@ -16,13 +16,13 @@ CONFIG_SCHEMA = light.RGB_LIGHT_SCHEMA.extend( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_OUTPUT_ID]) - yield light.register_light(var, config) + await light.register_light(var, config) - red = yield cg.get_variable(config[CONF_RED]) + red = await cg.get_variable(config[CONF_RED]) cg.add(var.set_red(red)) - green = yield cg.get_variable(config[CONF_GREEN]) + green = await cg.get_variable(config[CONF_GREEN]) cg.add(var.set_green(green)) - blue = yield cg.get_variable(config[CONF_BLUE]) + blue = await cg.get_variable(config[CONF_BLUE]) cg.add(var.set_blue(blue)) diff --git a/esphome/components/rgbw/light.py b/esphome/components/rgbw/light.py index a922a7de37..de26edf7d5 100644 --- a/esphome/components/rgbw/light.py +++ b/esphome/components/rgbw/light.py @@ -19,16 +19,16 @@ CONFIG_SCHEMA = light.RGB_LIGHT_SCHEMA.extend( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_OUTPUT_ID]) - yield light.register_light(var, config) + await light.register_light(var, config) - red = yield cg.get_variable(config[CONF_RED]) + red = await cg.get_variable(config[CONF_RED]) cg.add(var.set_red(red)) - green = yield cg.get_variable(config[CONF_GREEN]) + green = await cg.get_variable(config[CONF_GREEN]) cg.add(var.set_green(green)) - blue = yield cg.get_variable(config[CONF_BLUE]) + blue = await cg.get_variable(config[CONF_BLUE]) cg.add(var.set_blue(blue)) - white = yield cg.get_variable(config[CONF_WHITE]) + white = await cg.get_variable(config[CONF_WHITE]) cg.add(var.set_white(white)) cg.add(var.set_color_interlock(config[CONF_COLOR_INTERLOCK])) diff --git a/esphome/components/rgbww/light.py b/esphome/components/rgbww/light.py index d7d0d7fb15..d152fbc6db 100644 --- a/esphome/components/rgbww/light.py +++ b/esphome/components/rgbww/light.py @@ -34,22 +34,22 @@ CONFIG_SCHEMA = light.RGB_LIGHT_SCHEMA.extend( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_OUTPUT_ID]) - yield light.register_light(var, config) + await light.register_light(var, config) - red = yield cg.get_variable(config[CONF_RED]) + red = await cg.get_variable(config[CONF_RED]) cg.add(var.set_red(red)) - green = yield cg.get_variable(config[CONF_GREEN]) + green = await cg.get_variable(config[CONF_GREEN]) cg.add(var.set_green(green)) - blue = yield cg.get_variable(config[CONF_BLUE]) + blue = await cg.get_variable(config[CONF_BLUE]) cg.add(var.set_blue(blue)) - cwhite = yield cg.get_variable(config[CONF_COLD_WHITE]) + cwhite = await cg.get_variable(config[CONF_COLD_WHITE]) cg.add(var.set_cold_white(cwhite)) cg.add(var.set_cold_white_temperature(config[CONF_COLD_WHITE_COLOR_TEMPERATURE])) - wwhite = yield cg.get_variable(config[CONF_WARM_WHITE]) + wwhite = await cg.get_variable(config[CONF_WARM_WHITE]) cg.add(var.set_warm_white(wwhite)) cg.add(var.set_warm_white_temperature(config[CONF_WARM_WHITE_COLOR_TEMPERATURE])) cg.add(var.set_constant_brightness(config[CONF_CONSTANT_BRIGHTNESS])) diff --git a/esphome/components/rotary_encoder/sensor.py b/esphome/components/rotary_encoder/sensor.py index bcc4a5c930..4af1d75139 100644 --- a/esphome/components/rotary_encoder/sensor.py +++ b/esphome/components/rotary_encoder/sensor.py @@ -91,17 +91,17 @@ CONFIG_SCHEMA = cv.All( ) -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) - pin_a = yield cg.gpio_pin_expression(config[CONF_PIN_A]) + await cg.register_component(var, config) + await sensor.register_sensor(var, config) + pin_a = await cg.gpio_pin_expression(config[CONF_PIN_A]) cg.add(var.set_pin_a(pin_a)) - pin_b = yield cg.gpio_pin_expression(config[CONF_PIN_B]) + pin_b = await cg.gpio_pin_expression(config[CONF_PIN_B]) cg.add(var.set_pin_b(pin_b)) if CONF_PIN_RESET in config: - pin_i = yield cg.gpio_pin_expression(config[CONF_PIN_RESET]) + pin_i = await cg.gpio_pin_expression(config[CONF_PIN_RESET]) cg.add(var.set_reset_pin(pin_i)) cg.add(var.set_resolution(config[CONF_RESOLUTION])) if CONF_MIN_VALUE in config: @@ -111,10 +111,10 @@ def to_code(config): for conf in config.get(CONF_ON_CLOCKWISE, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) - yield automation.build_automation(trigger, [], conf) + await automation.build_automation(trigger, [], conf) for conf in config.get(CONF_ON_ANTICLOCKWISE, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) - yield automation.build_automation(trigger, [], conf) + await automation.build_automation(trigger, [], conf) @automation.register_action( diff --git a/esphome/components/rtttl/__init__.py b/esphome/components/rtttl/__init__.py index 97b7405c63..fb193c5b92 100644 --- a/esphome/components/rtttl/__init__.py +++ b/esphome/components/rtttl/__init__.py @@ -33,16 +33,16 @@ CONFIG_SCHEMA = cv.Schema( ).extend(cv.COMPONENT_SCHEMA) -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) - out = yield cg.get_variable(config[CONF_OUTPUT]) + out = await cg.get_variable(config[CONF_OUTPUT]) cg.add(var.set_output(out)) for conf in config.get(CONF_ON_FINISHED_PLAYBACK, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) - yield automation.build_automation(trigger, [], conf) + await automation.build_automation(trigger, [], conf) @automation.register_action( diff --git a/esphome/components/ruuvi_ble/__init__.py b/esphome/components/ruuvi_ble/__init__.py index 74aec457bb..1e3fb4b003 100644 --- a/esphome/components/ruuvi_ble/__init__.py +++ b/esphome/components/ruuvi_ble/__init__.py @@ -17,6 +17,6 @@ CONFIG_SCHEMA = cv.Schema( ).extend(esp32_ble_tracker.ESP_BLE_DEVICE_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield esp32_ble_tracker.register_ble_device(var, config) + await esp32_ble_tracker.register_ble_device(var, config) diff --git a/esphome/components/ruuvitag/sensor.py b/esphome/components/ruuvitag/sensor.py index 2bde7b485c..d59dc094fb 100644 --- a/esphome/components/ruuvitag/sensor.py +++ b/esphome/components/ruuvitag/sensor.py @@ -89,43 +89,43 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield esp32_ble_tracker.register_ble_device(var, config) + await cg.register_component(var, config) + await esp32_ble_tracker.register_ble_device(var, config) cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex)) 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)) 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)) if CONF_PRESSURE in config: - sens = yield sensor.new_sensor(config[CONF_PRESSURE]) + sens = await sensor.new_sensor(config[CONF_PRESSURE]) cg.add(var.set_pressure(sens)) if CONF_ACCELERATION in config: - sens = yield sensor.new_sensor(config[CONF_ACCELERATION]) + sens = await sensor.new_sensor(config[CONF_ACCELERATION]) cg.add(var.set_acceleration(sens)) if CONF_ACCELERATION_X in config: - sens = yield sensor.new_sensor(config[CONF_ACCELERATION_X]) + sens = await sensor.new_sensor(config[CONF_ACCELERATION_X]) cg.add(var.set_acceleration_x(sens)) if CONF_ACCELERATION_Y in config: - sens = yield sensor.new_sensor(config[CONF_ACCELERATION_Y]) + sens = await sensor.new_sensor(config[CONF_ACCELERATION_Y]) cg.add(var.set_acceleration_y(sens)) if CONF_ACCELERATION_Z in config: - sens = yield sensor.new_sensor(config[CONF_ACCELERATION_Z]) + sens = await sensor.new_sensor(config[CONF_ACCELERATION_Z]) cg.add(var.set_acceleration_z(sens)) 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)) if CONF_TX_POWER in config: - sens = yield sensor.new_sensor(config[CONF_TX_POWER]) + sens = await sensor.new_sensor(config[CONF_TX_POWER]) cg.add(var.set_tx_power(sens)) if CONF_MOVEMENT_COUNTER in config: - sens = yield sensor.new_sensor(config[CONF_MOVEMENT_COUNTER]) + sens = await sensor.new_sensor(config[CONF_MOVEMENT_COUNTER]) cg.add(var.set_movement_counter(sens)) if CONF_MEASUREMENT_SEQUENCE_NUMBER in config: - sens = yield sensor.new_sensor(config[CONF_MEASUREMENT_SEQUENCE_NUMBER]) + sens = await sensor.new_sensor(config[CONF_MEASUREMENT_SEQUENCE_NUMBER]) cg.add(var.set_measurement_sequence_number(sens)) diff --git a/esphome/components/scd30/sensor.py b/esphome/components/scd30/sensor.py index aa3e5b65ba..a5eb5d8ca4 100644 --- a/esphome/components/scd30/sensor.py +++ b/esphome/components/scd30/sensor.py @@ -59,10 +59,10 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) cg.add(var.set_automatic_self_calibration(config[CONF_AUTOMATIC_SELF_CALIBRATION])) if CONF_ALTITUDE_COMPENSATION in config: @@ -79,13 +79,13 @@ def to_code(config): cg.add(var.set_temperature_offset(config[CONF_TEMPERATURE_OFFSET])) 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_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)) 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)) diff --git a/esphome/components/script/__init__.py b/esphome/components/script/__init__.py index 45b01778da..a14f48a547 100644 --- a/esphome/components/script/__init__.py +++ b/esphome/components/script/__init__.py @@ -61,7 +61,7 @@ CONFIG_SCHEMA = automation.validate_automation( ) -def to_code(config): +async def to_code(config): # Register all variables first, so that scripts can use other scripts triggers = [] for conf in config: @@ -73,12 +73,12 @@ def to_code(config): cg.add(trigger.set_max_runs(conf[CONF_MAX_RUNS])) if conf[CONF_MODE] == CONF_QUEUED: - yield cg.register_component(trigger, conf) + await cg.register_component(trigger, conf) triggers.append((trigger, conf)) for trigger, conf in triggers: - yield automation.build_automation(trigger, [], conf) + await automation.build_automation(trigger, [], conf) @automation.register_action( diff --git a/esphome/components/sds011/sensor.py b/esphome/components/sds011/sensor.py index fcee6fe7d2..5655533b21 100644 --- a/esphome/components/sds011/sensor.py +++ b/esphome/components/sds011/sensor.py @@ -59,19 +59,19 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield uart.register_uart_device(var, config) + await cg.register_component(var, config) + await uart.register_uart_device(var, config) if CONF_UPDATE_INTERVAL in config: cg.add(var.set_update_interval_min(config[CONF_UPDATE_INTERVAL])) cg.add(var.set_rx_mode_only(config[CONF_RX_ONLY])) if CONF_PM_2_5 in config: - sens = yield sensor.new_sensor(config[CONF_PM_2_5]) + sens = await sensor.new_sensor(config[CONF_PM_2_5]) cg.add(var.set_pm_2_5_sensor(sens)) if CONF_PM_10_0 in config: - sens = yield sensor.new_sensor(config[CONF_PM_10_0]) + sens = await sensor.new_sensor(config[CONF_PM_10_0]) cg.add(var.set_pm_10_0_sensor(sens)) diff --git a/esphome/components/senseair/sensor.py b/esphome/components/senseair/sensor.py index 6f48651563..a2690f37ed 100644 --- a/esphome/components/senseair/sensor.py +++ b/esphome/components/senseair/sensor.py @@ -47,13 +47,13 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield uart.register_uart_device(var, config) + await cg.register_component(var, config) + await uart.register_uart_device(var, config) 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)) diff --git a/esphome/components/servo/__init__.py b/esphome/components/servo/__init__.py index 489c295255..e54dd27dea 100644 --- a/esphome/components/servo/__init__.py +++ b/esphome/components/servo/__init__.py @@ -39,11 +39,11 @@ CONFIG_SCHEMA = cv.Schema( ).extend(cv.COMPONENT_SCHEMA) -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) - out = yield cg.get_variable(config[CONF_OUTPUT]) + out = await cg.get_variable(config[CONF_OUTPUT]) cg.add(var.set_output(out)) cg.add(var.set_min_level(config[CONF_MIN_LEVEL])) cg.add(var.set_idle_level(config[CONF_IDLE_LEVEL])) diff --git a/esphome/components/sgp30/sensor.py b/esphome/components/sgp30/sensor.py index 31b40840e3..7046605f3b 100644 --- a/esphome/components/sgp30/sensor.py +++ b/esphome/components/sgp30/sensor.py @@ -54,17 +54,17 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) if CONF_ECO2 in config: - sens = yield sensor.new_sensor(config[CONF_ECO2]) + sens = await sensor.new_sensor(config[CONF_ECO2]) cg.add(var.set_eco2_sensor(sens)) if CONF_TVOC in config: - sens = yield sensor.new_sensor(config[CONF_TVOC]) + sens = await sensor.new_sensor(config[CONF_TVOC]) cg.add(var.set_tvoc_sensor(sens)) if CONF_BASELINE in config: @@ -74,7 +74,7 @@ def to_code(config): if CONF_COMPENSATION in config: compensation_config = config[CONF_COMPENSATION] - sens = yield cg.get_variable(compensation_config[CONF_HUMIDITY_SOURCE]) + sens = await cg.get_variable(compensation_config[CONF_HUMIDITY_SOURCE]) cg.add(var.set_humidity_sensor(sens)) - sens = yield cg.get_variable(compensation_config[CONF_TEMPERATURE_SOURCE]) + sens = await cg.get_variable(compensation_config[CONF_TEMPERATURE_SOURCE]) cg.add(var.set_temperature_sensor(sens)) diff --git a/esphome/components/sgp40/sensor.py b/esphome/components/sgp40/sensor.py index 40bc07389b..a308d7bb79 100644 --- a/esphome/components/sgp40/sensor.py +++ b/esphome/components/sgp40/sensor.py @@ -38,17 +38,17 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) - yield sensor.register_sensor(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) + await sensor.register_sensor(var, config) if CONF_COMPENSATION in config: compensation_config = config[CONF_COMPENSATION] - sens = yield cg.get_variable(compensation_config[CONF_HUMIDITY_SOURCE]) + sens = await cg.get_variable(compensation_config[CONF_HUMIDITY_SOURCE]) cg.add(var.set_humidity_sensor(sens)) - sens = yield cg.get_variable(compensation_config[CONF_TEMPERATURE_SOURCE]) + sens = await cg.get_variable(compensation_config[CONF_TEMPERATURE_SOURCE]) cg.add(var.set_temperature_sensor(sens)) cg.add(var.set_store_baseline(config[CONF_STORE_BASELINE])) diff --git a/esphome/components/sht3xd/sensor.py b/esphome/components/sht3xd/sensor.py index 0b30d6780b..cac53e47e3 100644 --- a/esphome/components/sht3xd/sensor.py +++ b/esphome/components/sht3xd/sensor.py @@ -36,15 +36,15 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, 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_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)) diff --git a/esphome/components/sht4x/sensor.py b/esphome/components/sht4x/sensor.py index bd3e5c108c..fdc4029e41 100644 --- a/esphome/components/sht4x/sensor.py +++ b/esphome/components/sht4x/sensor.py @@ -75,10 +75,10 @@ TYPES = { } -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) cg.add(var.set_precision_value(config[CONF_PRECISION])) cg.add(var.set_heater_power_value(config[CONF_HEATER_POWER])) @@ -88,5 +88,5 @@ def to_code(config): for key, funcName in TYPES.items(): if key in config: - sens = yield sensor.new_sensor(config[key]) + sens = await sensor.new_sensor(config[key]) cg.add(getattr(var, funcName)(sens)) diff --git a/esphome/components/shtcx/sensor.py b/esphome/components/shtcx/sensor.py index 4b1c6c7afe..7156029488 100644 --- a/esphome/components/shtcx/sensor.py +++ b/esphome/components/shtcx/sensor.py @@ -36,15 +36,15 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, 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_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)) diff --git a/esphome/components/shutdown/switch.py b/esphome/components/shutdown/switch.py index e35029afd7..30c2bc2b74 100644 --- a/esphome/components/shutdown/switch.py +++ b/esphome/components/shutdown/switch.py @@ -17,7 +17,7 @@ CONFIG_SCHEMA = switch.SWITCH_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield switch.register_switch(var, config) + await cg.register_component(var, config) + await switch.register_switch(var, config) diff --git a/esphome/components/sim800l/__init__.py b/esphome/components/sim800l/__init__.py index 3b06ca6d89..4fa1661d21 100644 --- a/esphome/components/sim800l/__init__.py +++ b/esphome/components/sim800l/__init__.py @@ -42,14 +42,14 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield uart.register_uart_device(var, config) + await cg.register_component(var, config) + await uart.register_uart_device(var, config) for conf in config.get(CONF_ON_SMS_RECEIVED, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) - yield automation.build_automation( + await automation.build_automation( trigger, [(cg.std_string, "message"), (cg.std_string, "sender")], conf ) diff --git a/esphome/components/slow_pwm/output.py b/esphome/components/slow_pwm/output.py index f7b26a953a..4f44582eba 100644 --- a/esphome/components/slow_pwm/output.py +++ b/esphome/components/slow_pwm/output.py @@ -19,11 +19,11 @@ CONFIG_SCHEMA = output.FLOAT_OUTPUT_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield output.register_output(var, config) + await cg.register_component(var, config) + await output.register_output(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_period(config[CONF_PERIOD])) diff --git a/esphome/components/sm16716/__init__.py b/esphome/components/sm16716/__init__.py index 8030f78f41..ec8ed722f3 100644 --- a/esphome/components/sm16716/__init__.py +++ b/esphome/components/sm16716/__init__.py @@ -25,13 +25,13 @@ CONFIG_SCHEMA = cv.Schema( ).extend(cv.COMPONENT_SCHEMA) -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) - data = yield cg.gpio_pin_expression(config[CONF_DATA_PIN]) + data = await cg.gpio_pin_expression(config[CONF_DATA_PIN]) cg.add(var.set_data_pin(data)) - clock = yield cg.gpio_pin_expression(config[CONF_CLOCK_PIN]) + clock = await cg.gpio_pin_expression(config[CONF_CLOCK_PIN]) cg.add(var.set_clock_pin(clock)) cg.add(var.set_num_channels(config[CONF_NUM_CHANNELS])) diff --git a/esphome/components/sm16716/output.py b/esphome/components/sm16716/output.py index 033bd86e9c..e9b92f68f8 100644 --- a/esphome/components/sm16716/output.py +++ b/esphome/components/sm16716/output.py @@ -18,10 +18,10 @@ CONFIG_SCHEMA = output.FLOAT_OUTPUT_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield output.register_output(var, config) + await output.register_output(var, config) - parent = yield cg.get_variable(config[CONF_SM16716_ID]) + parent = await cg.get_variable(config[CONF_SM16716_ID]) cg.add(var.set_parent(parent)) cg.add(var.set_channel(config[CONF_CHANNEL])) diff --git a/esphome/components/sm2135/__init__.py b/esphome/components/sm2135/__init__.py index 019a1c68c1..68a9094518 100644 --- a/esphome/components/sm2135/__init__.py +++ b/esphome/components/sm2135/__init__.py @@ -23,11 +23,11 @@ CONFIG_SCHEMA = cv.Schema( ).extend(cv.COMPONENT_SCHEMA) -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) - data = yield cg.gpio_pin_expression(config[CONF_DATA_PIN]) + data = await cg.gpio_pin_expression(config[CONF_DATA_PIN]) cg.add(var.set_data_pin(data)) - clock = yield cg.gpio_pin_expression(config[CONF_CLOCK_PIN]) + clock = await cg.gpio_pin_expression(config[CONF_CLOCK_PIN]) cg.add(var.set_clock_pin(clock)) diff --git a/esphome/components/sm2135/output.py b/esphome/components/sm2135/output.py index 86f6db1bb4..5cd969c6a5 100644 --- a/esphome/components/sm2135/output.py +++ b/esphome/components/sm2135/output.py @@ -19,10 +19,10 @@ CONFIG_SCHEMA = output.FLOAT_OUTPUT_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield output.register_output(var, config) + await output.register_output(var, config) - parent = yield cg.get_variable(config[CONF_SM2135_ID]) + parent = await cg.get_variable(config[CONF_SM2135_ID]) cg.add(var.set_parent(parent)) cg.add(var.set_channel(config[CONF_CHANNEL])) diff --git a/esphome/components/sm300d2/sensor.py b/esphome/components/sm300d2/sensor.py index b1df1fb1b8..7618136bd9 100644 --- a/esphome/components/sm300d2/sensor.py +++ b/esphome/components/sm300d2/sensor.py @@ -64,29 +64,29 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield uart.register_uart_device(var, config) + await cg.register_component(var, config) + await uart.register_uart_device(var, config) 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_FORMALDEHYDE in config: - sens = yield sensor.new_sensor(config[CONF_FORMALDEHYDE]) + sens = await sensor.new_sensor(config[CONF_FORMALDEHYDE]) cg.add(var.set_formaldehyde_sensor(sens)) if CONF_TVOC in config: - sens = yield sensor.new_sensor(config[CONF_TVOC]) + sens = await sensor.new_sensor(config[CONF_TVOC]) cg.add(var.set_tvoc_sensor(sens)) if CONF_PM_2_5 in config: - sens = yield sensor.new_sensor(config[CONF_PM_2_5]) + sens = await sensor.new_sensor(config[CONF_PM_2_5]) cg.add(var.set_pm_2_5_sensor(sens)) if CONF_PM_10_0 in config: - sens = yield sensor.new_sensor(config[CONF_PM_10_0]) + sens = await sensor.new_sensor(config[CONF_PM_10_0]) cg.add(var.set_pm_10_0_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)) diff --git a/esphome/components/sn74hc595/__init__.py b/esphome/components/sn74hc595/__init__.py index 152ac02106..67d759cadd 100644 --- a/esphome/components/sn74hc595/__init__.py +++ b/esphome/components/sn74hc595/__init__.py @@ -33,17 +33,17 @@ CONFIG_SCHEMA = cv.Schema( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - data_pin = yield cg.gpio_pin_expression(config[CONF_DATA_PIN]) + await cg.register_component(var, config) + data_pin = await cg.gpio_pin_expression(config[CONF_DATA_PIN]) cg.add(var.set_data_pin(data_pin)) - clock_pin = yield cg.gpio_pin_expression(config[CONF_CLOCK_PIN]) + clock_pin = await cg.gpio_pin_expression(config[CONF_CLOCK_PIN]) cg.add(var.set_clock_pin(clock_pin)) - latch_pin = yield cg.gpio_pin_expression(config[CONF_LATCH_PIN]) + latch_pin = await cg.gpio_pin_expression(config[CONF_LATCH_PIN]) cg.add(var.set_latch_pin(latch_pin)) if CONF_OE_PIN in config: - oe_pin = yield cg.gpio_pin_expression(config[CONF_OE_PIN]) + oe_pin = await cg.gpio_pin_expression(config[CONF_OE_PIN]) cg.add(var.set_oe_pin(oe_pin)) cg.add(var.set_sr_count(config[CONF_SR_COUNT])) diff --git a/esphome/components/sntp/time.py b/esphome/components/sntp/time.py index a142ad72d7..5475dc0a1f 100644 --- a/esphome/components/sntp/time.py +++ b/esphome/components/sntp/time.py @@ -22,15 +22,15 @@ CONFIG_SCHEMA = time_.TIME_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) servers = config[CONF_SERVERS] servers += [""] * (3 - len(servers)) cg.add(var.set_servers(*servers)) - yield cg.register_component(var, config) - yield time_.register_time(var, config) + await cg.register_component(var, config) + await time_.register_time(var, config) if CORE.is_esp8266 and len(servers) > 1: # We need LwIP features enabled to get 3 SNTP servers (not just one) diff --git a/esphome/components/speed/fan/__init__.py b/esphome/components/speed/fan/__init__.py index fdb0a9af09..0ee31c76a0 100644 --- a/esphome/components/speed/fan/__init__.py +++ b/esphome/components/speed/fan/__init__.py @@ -27,18 +27,18 @@ CONFIG_SCHEMA = fan.FAN_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): - output_ = yield cg.get_variable(config[CONF_OUTPUT]) - state = yield fan.create_fan_state(config) +async def to_code(config): + output_ = await cg.get_variable(config[CONF_OUTPUT]) + state = await fan.create_fan_state(config) var = cg.new_Pvariable( config[CONF_OUTPUT_ID], state, output_, config[CONF_SPEED_COUNT] ) - yield cg.register_component(var, config) + await cg.register_component(var, config) if CONF_OSCILLATION_OUTPUT in config: - oscillation_output = yield cg.get_variable(config[CONF_OSCILLATION_OUTPUT]) + oscillation_output = await cg.get_variable(config[CONF_OSCILLATION_OUTPUT]) cg.add(var.set_oscillating(oscillation_output)) if CONF_DIRECTION_OUTPUT in config: - direction_output = yield cg.get_variable(config[CONF_DIRECTION_OUTPUT]) + direction_output = await cg.get_variable(config[CONF_DIRECTION_OUTPUT]) cg.add(var.set_direction(direction_output)) diff --git a/esphome/components/sps30/sensor.py b/esphome/components/sps30/sensor.py index 5bc586ea8b..32c55b969c 100644 --- a/esphome/components/sps30/sensor.py +++ b/esphome/components/sps30/sensor.py @@ -80,47 +80,47 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) if CONF_PM_1_0 in config: - sens = yield sensor.new_sensor(config[CONF_PM_1_0]) + sens = await sensor.new_sensor(config[CONF_PM_1_0]) cg.add(var.set_pm_1_0_sensor(sens)) if CONF_PM_2_5 in config: - sens = yield sensor.new_sensor(config[CONF_PM_2_5]) + sens = await sensor.new_sensor(config[CONF_PM_2_5]) cg.add(var.set_pm_2_5_sensor(sens)) if CONF_PM_4_0 in config: - sens = yield sensor.new_sensor(config[CONF_PM_4_0]) + sens = await sensor.new_sensor(config[CONF_PM_4_0]) cg.add(var.set_pm_4_0_sensor(sens)) if CONF_PM_10_0 in config: - sens = yield sensor.new_sensor(config[CONF_PM_10_0]) + sens = await sensor.new_sensor(config[CONF_PM_10_0]) cg.add(var.set_pm_10_0_sensor(sens)) if CONF_PMC_0_5 in config: - sens = yield sensor.new_sensor(config[CONF_PMC_0_5]) + sens = await sensor.new_sensor(config[CONF_PMC_0_5]) cg.add(var.set_pmc_0_5_sensor(sens)) if CONF_PMC_1_0 in config: - sens = yield sensor.new_sensor(config[CONF_PMC_1_0]) + sens = await sensor.new_sensor(config[CONF_PMC_1_0]) cg.add(var.set_pmc_1_0_sensor(sens)) if CONF_PMC_2_5 in config: - sens = yield sensor.new_sensor(config[CONF_PMC_2_5]) + sens = await sensor.new_sensor(config[CONF_PMC_2_5]) cg.add(var.set_pmc_2_5_sensor(sens)) if CONF_PMC_4_0 in config: - sens = yield sensor.new_sensor(config[CONF_PMC_4_0]) + sens = await sensor.new_sensor(config[CONF_PMC_4_0]) cg.add(var.set_pmc_4_0_sensor(sens)) if CONF_PMC_10_0 in config: - sens = yield sensor.new_sensor(config[CONF_PMC_10_0]) + sens = await sensor.new_sensor(config[CONF_PMC_10_0]) cg.add(var.set_pmc_10_0_sensor(sens)) if CONF_PM_SIZE in config: - sens = yield sensor.new_sensor(config[CONF_PM_SIZE]) + sens = await sensor.new_sensor(config[CONF_PM_SIZE]) cg.add(var.set_pm_size_sensor(sens)) diff --git a/esphome/components/ssd1306_i2c/display.py b/esphome/components/ssd1306_i2c/display.py index c51ef1cfba..4b51a90431 100644 --- a/esphome/components/ssd1306_i2c/display.py +++ b/esphome/components/ssd1306_i2c/display.py @@ -21,7 +21,7 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield ssd1306_base.setup_ssd1036(var, config) - yield i2c.register_i2c_device(var, config) + await ssd1306_base.setup_ssd1036(var, config) + await i2c.register_i2c_device(var, config) diff --git a/esphome/components/ssd1306_spi/display.py b/esphome/components/ssd1306_spi/display.py index b1558ac413..f7dd1553ba 100644 --- a/esphome/components/ssd1306_spi/display.py +++ b/esphome/components/ssd1306_spi/display.py @@ -23,10 +23,10 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield ssd1306_base.setup_ssd1036(var, config) - yield spi.register_spi_device(var, config) + await ssd1306_base.setup_ssd1036(var, config) + await spi.register_spi_device(var, config) - dc = yield cg.gpio_pin_expression(config[CONF_DC_PIN]) + dc = await cg.gpio_pin_expression(config[CONF_DC_PIN]) cg.add(var.set_dc_pin(dc)) diff --git a/esphome/components/ssd1322_spi/display.py b/esphome/components/ssd1322_spi/display.py index fa094acc5f..88b3a53355 100644 --- a/esphome/components/ssd1322_spi/display.py +++ b/esphome/components/ssd1322_spi/display.py @@ -25,10 +25,10 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield ssd1322_base.setup_ssd1322(var, config) - yield spi.register_spi_device(var, config) + await ssd1322_base.setup_ssd1322(var, config) + await spi.register_spi_device(var, config) - dc = yield cg.gpio_pin_expression(config[CONF_DC_PIN]) + dc = await cg.gpio_pin_expression(config[CONF_DC_PIN]) cg.add(var.set_dc_pin(dc)) diff --git a/esphome/components/ssd1325_spi/display.py b/esphome/components/ssd1325_spi/display.py index 6ce133bec1..a86dc751d5 100644 --- a/esphome/components/ssd1325_spi/display.py +++ b/esphome/components/ssd1325_spi/display.py @@ -25,10 +25,10 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield ssd1325_base.setup_ssd1325(var, config) - yield spi.register_spi_device(var, config) + await ssd1325_base.setup_ssd1325(var, config) + await spi.register_spi_device(var, config) - dc = yield cg.gpio_pin_expression(config[CONF_DC_PIN]) + dc = await cg.gpio_pin_expression(config[CONF_DC_PIN]) cg.add(var.set_dc_pin(dc)) diff --git a/esphome/components/ssd1327_i2c/display.py b/esphome/components/ssd1327_i2c/display.py index f13ed003ad..7b581cc92c 100644 --- a/esphome/components/ssd1327_i2c/display.py +++ b/esphome/components/ssd1327_i2c/display.py @@ -23,7 +23,7 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield ssd1327_base.setup_ssd1327(var, config) - yield i2c.register_i2c_device(var, config) + await ssd1327_base.setup_ssd1327(var, config) + await i2c.register_i2c_device(var, config) diff --git a/esphome/components/ssd1327_spi/display.py b/esphome/components/ssd1327_spi/display.py index fe119836a3..138e85eecd 100644 --- a/esphome/components/ssd1327_spi/display.py +++ b/esphome/components/ssd1327_spi/display.py @@ -25,10 +25,10 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield ssd1327_base.setup_ssd1327(var, config) - yield spi.register_spi_device(var, config) + await ssd1327_base.setup_ssd1327(var, config) + await spi.register_spi_device(var, config) - dc = yield cg.gpio_pin_expression(config[CONF_DC_PIN]) + dc = await cg.gpio_pin_expression(config[CONF_DC_PIN]) cg.add(var.set_dc_pin(dc)) diff --git a/esphome/components/ssd1331_spi/display.py b/esphome/components/ssd1331_spi/display.py index c4e9dad8bc..c32ac60578 100644 --- a/esphome/components/ssd1331_spi/display.py +++ b/esphome/components/ssd1331_spi/display.py @@ -25,10 +25,10 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield ssd1331_base.setup_ssd1331(var, config) - yield spi.register_spi_device(var, config) + await ssd1331_base.setup_ssd1331(var, config) + await spi.register_spi_device(var, config) - dc = yield cg.gpio_pin_expression(config[CONF_DC_PIN]) + dc = await cg.gpio_pin_expression(config[CONF_DC_PIN]) cg.add(var.set_dc_pin(dc)) diff --git a/esphome/components/ssd1351_spi/display.py b/esphome/components/ssd1351_spi/display.py index 66e4fad02c..3f3409226c 100644 --- a/esphome/components/ssd1351_spi/display.py +++ b/esphome/components/ssd1351_spi/display.py @@ -25,10 +25,10 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield ssd1351_base.setup_ssd1351(var, config) - yield spi.register_spi_device(var, config) + await ssd1351_base.setup_ssd1351(var, config) + await spi.register_spi_device(var, config) - dc = yield cg.gpio_pin_expression(config[CONF_DC_PIN]) + dc = await cg.gpio_pin_expression(config[CONF_DC_PIN]) cg.add(var.set_dc_pin(dc)) diff --git a/esphome/components/st7735/display.py b/esphome/components/st7735/display.py index f1e7d37d51..bbacc5f55e 100644 --- a/esphome/components/st7735/display.py +++ b/esphome/components/st7735/display.py @@ -1,100 +1,100 @@ -import esphome.codegen as cg -import esphome.config_validation as cv -from esphome import pins -from esphome.components import spi -from esphome.components import display -from esphome.core import coroutine -from esphome.const import ( - CONF_DC_PIN, - CONF_ID, - CONF_LAMBDA, - CONF_MODEL, - CONF_RESET_PIN, - CONF_PAGES, -) -from . import st7735_ns - -CODEOWNERS = ["@SenexCrenshaw"] - -DEPENDENCIES = ["spi"] - -CONF_DEVICE_WIDTH = "device_width" -CONF_DEVICE_HEIGHT = "device_height" -CONF_ROW_START = "row_start" -CONF_COL_START = "col_start" -CONF_EIGHT_BIT_COLOR = "eight_bit_color" -CONF_USE_BGR = "use_bgr" - -SPIST7735 = st7735_ns.class_( - "ST7735", cg.PollingComponent, display.DisplayBuffer, spi.SPIDevice -) -ST7735Model = st7735_ns.enum("ST7735Model") - -MODELS = { - "INITR_GREENTAB": ST7735Model.ST7735_INITR_GREENTAB, - "INITR_REDTAB": ST7735Model.ST7735_INITR_REDTAB, - "INITR_BLACKTAB": ST7735Model.ST7735_INITR_BLACKTAB, - "INITR_MINI160X80": ST7735Model.ST7735_INITR_MINI_160X80, - "INITR_18BLACKTAB": ST7735Model.ST7735_INITR_18BLACKTAB, - "INITR_18REDTAB": ST7735Model.ST7735_INITR_18REDTAB, -} -ST7735_MODEL = cv.enum(MODELS, upper=True, space="_") - - -ST7735_SCHEMA = display.FULL_DISPLAY_SCHEMA.extend( - { - cv.Required(CONF_MODEL): ST7735_MODEL, - cv.Optional(CONF_RESET_PIN): pins.gpio_output_pin_schema, - } -).extend(cv.polling_component_schema("1s")) - -CONFIG_SCHEMA = cv.All( - ST7735_SCHEMA.extend( - { - cv.GenerateID(): cv.declare_id(SPIST7735), - cv.Required(CONF_DC_PIN): pins.gpio_output_pin_schema, - cv.Required(CONF_DEVICE_WIDTH): cv.int_, - cv.Required(CONF_DEVICE_HEIGHT): cv.int_, - cv.Required(CONF_COL_START): cv.int_, - cv.Required(CONF_ROW_START): cv.int_, - cv.Optional(CONF_EIGHT_BIT_COLOR, default=False): cv.boolean, - cv.Optional(CONF_USE_BGR, default=False): cv.boolean, - } - ) - .extend(cv.COMPONENT_SCHEMA) - .extend(spi.spi_device_schema()), - cv.has_at_most_one_key(CONF_PAGES, CONF_LAMBDA), -) - - -@coroutine -def setup_st7735(var, config): - yield cg.register_component(var, config) - yield display.register_display(var, config) - - if CONF_RESET_PIN in config: - reset = yield cg.gpio_pin_expression(config[CONF_RESET_PIN]) - cg.add(var.set_reset_pin(reset)) - if CONF_LAMBDA in config: - lambda_ = yield cg.process_lambda( - config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void - ) - cg.add(var.set_writer(lambda_)) - - -def to_code(config): - var = cg.new_Pvariable( - config[CONF_ID], - config[CONF_MODEL], - config[CONF_DEVICE_WIDTH], - config[CONF_DEVICE_HEIGHT], - config[CONF_COL_START], - config[CONF_ROW_START], - config[CONF_EIGHT_BIT_COLOR], - config[CONF_USE_BGR], - ) - yield setup_st7735(var, config) - yield spi.register_spi_device(var, config) - - dc = yield cg.gpio_pin_expression(config[CONF_DC_PIN]) - cg.add(var.set_dc_pin(dc)) +import esphome.codegen as cg +import esphome.config_validation as cv +from esphome import pins +from esphome.components import spi +from esphome.components import display +from esphome.core import coroutine +from esphome.const import ( + CONF_DC_PIN, + CONF_ID, + CONF_LAMBDA, + CONF_MODEL, + CONF_RESET_PIN, + CONF_PAGES, +) +from . import st7735_ns + +CODEOWNERS = ["@SenexCrenshaw"] + +DEPENDENCIES = ["spi"] + +CONF_DEVICE_WIDTH = "device_width" +CONF_DEVICE_HEIGHT = "device_height" +CONF_ROW_START = "row_start" +CONF_COL_START = "col_start" +CONF_EIGHT_BIT_COLOR = "eight_bit_color" +CONF_USE_BGR = "use_bgr" + +SPIST7735 = st7735_ns.class_( + "ST7735", cg.PollingComponent, display.DisplayBuffer, spi.SPIDevice +) +ST7735Model = st7735_ns.enum("ST7735Model") + +MODELS = { + "INITR_GREENTAB": ST7735Model.ST7735_INITR_GREENTAB, + "INITR_REDTAB": ST7735Model.ST7735_INITR_REDTAB, + "INITR_BLACKTAB": ST7735Model.ST7735_INITR_BLACKTAB, + "INITR_MINI160X80": ST7735Model.ST7735_INITR_MINI_160X80, + "INITR_18BLACKTAB": ST7735Model.ST7735_INITR_18BLACKTAB, + "INITR_18REDTAB": ST7735Model.ST7735_INITR_18REDTAB, +} +ST7735_MODEL = cv.enum(MODELS, upper=True, space="_") + + +ST7735_SCHEMA = display.FULL_DISPLAY_SCHEMA.extend( + { + cv.Required(CONF_MODEL): ST7735_MODEL, + cv.Optional(CONF_RESET_PIN): pins.gpio_output_pin_schema, + } +).extend(cv.polling_component_schema("1s")) + +CONFIG_SCHEMA = cv.All( + ST7735_SCHEMA.extend( + { + cv.GenerateID(): cv.declare_id(SPIST7735), + cv.Required(CONF_DC_PIN): pins.gpio_output_pin_schema, + cv.Required(CONF_DEVICE_WIDTH): cv.int_, + cv.Required(CONF_DEVICE_HEIGHT): cv.int_, + cv.Required(CONF_COL_START): cv.int_, + cv.Required(CONF_ROW_START): cv.int_, + cv.Optional(CONF_EIGHT_BIT_COLOR, default=False): cv.boolean, + cv.Optional(CONF_USE_BGR, default=False): cv.boolean, + } + ) + .extend(cv.COMPONENT_SCHEMA) + .extend(spi.spi_device_schema()), + cv.has_at_most_one_key(CONF_PAGES, CONF_LAMBDA), +) + + +@coroutine +def setup_st7735(var, config): + yield cg.register_component(var, config) + yield display.register_display(var, config) + + if CONF_RESET_PIN in config: + reset = yield cg.gpio_pin_expression(config[CONF_RESET_PIN]) + cg.add(var.set_reset_pin(reset)) + if CONF_LAMBDA in config: + lambda_ = yield cg.process_lambda( + config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void + ) + cg.add(var.set_writer(lambda_)) + + +async def to_code(config): + var = cg.new_Pvariable( + config[CONF_ID], + config[CONF_MODEL], + config[CONF_DEVICE_WIDTH], + config[CONF_DEVICE_HEIGHT], + config[CONF_COL_START], + config[CONF_ROW_START], + config[CONF_EIGHT_BIT_COLOR], + config[CONF_USE_BGR], + ) + await setup_st7735(var, config) + await spi.register_spi_device(var, config) + + dc = await cg.gpio_pin_expression(config[CONF_DC_PIN]) + cg.add(var.set_dc_pin(dc)) diff --git a/esphome/components/st7789v/display.py b/esphome/components/st7789v/display.py index 9b3d550374..a053d00ea2 100644 --- a/esphome/components/st7789v/display.py +++ b/esphome/components/st7789v/display.py @@ -38,24 +38,24 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield spi.register_spi_device(var, config) + await cg.register_component(var, config) + await spi.register_spi_device(var, config) - dc = yield cg.gpio_pin_expression(config[CONF_DC_PIN]) + dc = await cg.gpio_pin_expression(config[CONF_DC_PIN]) cg.add(var.set_dc_pin(dc)) - reset = yield cg.gpio_pin_expression(config[CONF_RESET_PIN]) + reset = await cg.gpio_pin_expression(config[CONF_RESET_PIN]) cg.add(var.set_reset_pin(reset)) - bl = yield cg.gpio_pin_expression(config[CONF_BACKLIGHT_PIN]) + bl = await cg.gpio_pin_expression(config[CONF_BACKLIGHT_PIN]) cg.add(var.set_backlight_pin(bl)) if CONF_LAMBDA in config: - lambda_ = yield cg.process_lambda( + lambda_ = await cg.process_lambda( config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void ) cg.add(var.set_writer(lambda_)) - yield display.register_display(var, config) + await display.register_display(var, config) diff --git a/esphome/components/status/binary_sensor.py b/esphome/components/status/binary_sensor.py index 3a52b0b617..e462bc5385 100644 --- a/esphome/components/status/binary_sensor.py +++ b/esphome/components/status/binary_sensor.py @@ -18,7 +18,7 @@ CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield binary_sensor.register_binary_sensor(var, config) + await cg.register_component(var, config) + await binary_sensor.register_binary_sensor(var, config) diff --git a/esphome/components/stepper/__init__.py b/esphome/components/stepper/__init__.py index 53ddc82e09..ce7b7ae6f9 100644 --- a/esphome/components/stepper/__init__.py +++ b/esphome/components/stepper/__init__.py @@ -146,5 +146,5 @@ def stepper_set_speed_to_code(config, action_id, template_arg, args): @coroutine_with_priority(100.0) -def to_code(config): +async def to_code(config): cg.add_global(stepper_ns.using) diff --git a/esphome/components/sts3x/sensor.py b/esphome/components/sts3x/sensor.py index 5e44c3ca3c..9fb798e7f1 100644 --- a/esphome/components/sts3x/sensor.py +++ b/esphome/components/sts3x/sensor.py @@ -23,8 +23,8 @@ CONFIG_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) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await sensor.register_sensor(var, config) + await i2c.register_i2c_device(var, config) diff --git a/esphome/components/substitutions/__init__.py b/esphome/components/substitutions/__init__.py index 61ad4a698a..e7a5e24ee6 100644 --- a/esphome/components/substitutions/__init__.py +++ b/esphome/components/substitutions/__init__.py @@ -38,7 +38,7 @@ CONFIG_SCHEMA = cv.Schema( ) -def to_code(config): +async def to_code(config): pass diff --git a/esphome/components/sun/__init__.py b/esphome/components/sun/__init__.py index 8cc911529b..296f2027dc 100644 --- a/esphome/components/sun/__init__.py +++ b/esphome/components/sun/__init__.py @@ -115,28 +115,28 @@ CONFIG_SCHEMA = cv.Schema( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - time_ = yield cg.get_variable(config[CONF_TIME_ID]) + time_ = await cg.get_variable(config[CONF_TIME_ID]) cg.add(var.set_time(time_)) cg.add(var.set_latitude(config[CONF_LATITUDE])) cg.add(var.set_longitude(config[CONF_LONGITUDE])) for conf in config.get(CONF_ON_SUNRISE, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID]) - yield cg.register_component(trigger, conf) - yield cg.register_parented(trigger, var) + await cg.register_component(trigger, conf) + await cg.register_parented(trigger, var) cg.add(trigger.set_sunrise(True)) cg.add(trigger.set_elevation(conf[CONF_ELEVATION])) - yield automation.build_automation(trigger, [], conf) + await automation.build_automation(trigger, [], conf) for conf in config.get(CONF_ON_SUNSET, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID]) - yield cg.register_component(trigger, conf) - yield cg.register_parented(trigger, var) + await cg.register_component(trigger, conf) + await cg.register_parented(trigger, var) cg.add(trigger.set_sunrise(False)) cg.add(trigger.set_elevation(conf[CONF_ELEVATION])) - yield automation.build_automation(trigger, [], conf) + await automation.build_automation(trigger, [], conf) @automation.register_condition( diff --git a/esphome/components/sun/sensor/__init__.py b/esphome/components/sun/sensor/__init__.py index 02e1ef28eb..3e72a2a04e 100644 --- a/esphome/components/sun/sensor/__init__.py +++ b/esphome/components/sun/sensor/__init__.py @@ -32,11 +32,11 @@ CONFIG_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) cg.add(var.set_type(config[CONF_TYPE])) - paren = yield cg.get_variable(config[CONF_SUN_ID]) + paren = await cg.get_variable(config[CONF_SUN_ID]) cg.add(var.set_parent(paren)) diff --git a/esphome/components/sun/text_sensor/__init__.py b/esphome/components/sun/text_sensor/__init__.py index b527da699b..ac1ce223d1 100644 --- a/esphome/components/sun/text_sensor/__init__.py +++ b/esphome/components/sun/text_sensor/__init__.py @@ -46,12 +46,12 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield text_sensor.register_text_sensor(var, config) + await cg.register_component(var, config) + await text_sensor.register_text_sensor(var, config) - paren = yield cg.get_variable(config[CONF_SUN_ID]) + paren = await cg.get_variable(config[CONF_SUN_ID]) cg.add(var.set_parent(paren)) cg.add(var.set_sunrise(SUN_TYPES[config[CONF_TYPE]])) cg.add(var.set_elevation(config[CONF_ELEVATION])) diff --git a/esphome/components/sx1509/__init__.py b/esphome/components/sx1509/__init__.py index 06ee364e1b..fd0b5befb6 100644 --- a/esphome/components/sx1509/__init__.py +++ b/esphome/components/sx1509/__init__.py @@ -47,10 +47,10 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) if CONF_KEYPAD in config: keypad = config[CONF_KEYPAD] cg.add(var.set_rows_cols(keypad[CONF_KEY_ROWS], keypad[CONF_KEY_COLUMNS])) diff --git a/esphome/components/sx1509/binary_sensor/__init__.py b/esphome/components/sx1509/binary_sensor/__init__.py index e2344cd4af..1560af8e99 100644 --- a/esphome/components/sx1509/binary_sensor/__init__.py +++ b/esphome/components/sx1509/binary_sensor/__init__.py @@ -21,10 +21,10 @@ CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield binary_sensor.register_binary_sensor(var, config) - hub = yield cg.get_variable(config[CONF_SX1509_ID]) + await binary_sensor.register_binary_sensor(var, config) + hub = await cg.get_variable(config[CONF_SX1509_ID]) cg.add(var.set_row_col(config[CONF_ROW], config[CONF_COL])) cg.add(hub.register_keypad_binary_sensor(var)) diff --git a/esphome/components/sx1509/output/__init__.py b/esphome/components/sx1509/output/__init__.py index 878534e829..7afea0fbf8 100644 --- a/esphome/components/sx1509/output/__init__.py +++ b/esphome/components/sx1509/output/__init__.py @@ -19,10 +19,10 @@ CONFIG_SCHEMA = output.FLOAT_OUTPUT_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): - parent = yield cg.get_variable(config[CONF_SX1509_ID]) +async def to_code(config): + parent = await cg.get_variable(config[CONF_SX1509_ID]) var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield output.register_output(var, config) + await cg.register_component(var, config) + await output.register_output(var, config) cg.add(var.set_pin(config[CONF_PIN])) cg.add(var.set_parent(parent)) diff --git a/esphome/components/tca9548a/__init__.py b/esphome/components/tca9548a/__init__.py index aedd751086..62cbace56a 100644 --- a/esphome/components/tca9548a/__init__.py +++ b/esphome/components/tca9548a/__init__.py @@ -22,9 +22,9 @@ CONFIG_SCHEMA = cv.Schema( ).extend(i2c.i2c_device_schema(0x70)) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) cg.add_define("USE_I2C_MULTIPLEXER") - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) cg.add(var.set_scan(config[CONF_SCAN])) diff --git a/esphome/components/tcl112/climate.py b/esphome/components/tcl112/climate.py index 587bdcfbe9..9facd6b8db 100644 --- a/esphome/components/tcl112/climate.py +++ b/esphome/components/tcl112/climate.py @@ -16,6 +16,6 @@ CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield climate_ir.register_climate_ir(var, config) + await climate_ir.register_climate_ir(var, config) diff --git a/esphome/components/tcs34725/sensor.py b/esphome/components/tcs34725/sensor.py index 84e3c290bf..2b02f7b296 100644 --- a/esphome/components/tcs34725/sensor.py +++ b/esphome/components/tcs34725/sensor.py @@ -78,29 +78,29 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) cg.add(var.set_integration_time(config[CONF_INTEGRATION_TIME])) cg.add(var.set_gain(config[CONF_GAIN])) if CONF_RED_CHANNEL in config: - sens = yield sensor.new_sensor(config[CONF_RED_CHANNEL]) + sens = await sensor.new_sensor(config[CONF_RED_CHANNEL]) cg.add(var.set_red_sensor(sens)) if CONF_GREEN_CHANNEL in config: - sens = yield sensor.new_sensor(config[CONF_GREEN_CHANNEL]) + sens = await sensor.new_sensor(config[CONF_GREEN_CHANNEL]) cg.add(var.set_green_sensor(sens)) if CONF_BLUE_CHANNEL in config: - sens = yield sensor.new_sensor(config[CONF_BLUE_CHANNEL]) + sens = await sensor.new_sensor(config[CONF_BLUE_CHANNEL]) cg.add(var.set_blue_sensor(sens)) if CONF_CLEAR_CHANNEL in config: - sens = yield sensor.new_sensor(config[CONF_CLEAR_CHANNEL]) + sens = await sensor.new_sensor(config[CONF_CLEAR_CHANNEL]) cg.add(var.set_clear_sensor(sens)) if CONF_ILLUMINANCE in config: - sens = yield sensor.new_sensor(config[CONF_ILLUMINANCE]) + sens = await sensor.new_sensor(config[CONF_ILLUMINANCE]) cg.add(var.set_illuminance_sensor(sens)) if CONF_COLOR_TEMPERATURE in config: - sens = yield sensor.new_sensor(config[CONF_COLOR_TEMPERATURE]) + sens = await sensor.new_sensor(config[CONF_COLOR_TEMPERATURE]) cg.add(var.set_color_temperature_sensor(sens)) diff --git a/esphome/components/teleinfo/sensor.py b/esphome/components/teleinfo/sensor.py index 9f6c2c8e89..d8b4dbade7 100644 --- a/esphome/components/teleinfo/sensor.py +++ b/esphome/components/teleinfo/sensor.py @@ -39,12 +39,12 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID], config[CONF_HISTORICAL_MODE]) - yield cg.register_component(var, config) - yield uart.register_uart_device(var, config) + await cg.register_component(var, config) + await uart.register_uart_device(var, config) if CONF_TAGS in config: for tag in config[CONF_TAGS]: - sens = yield sensor.new_sensor(tag[CONF_SENSOR]) + sens = await sensor.new_sensor(tag[CONF_SENSOR]) cg.add(var.register_teleinfo_sensor(tag[CONF_TAG_NAME], sens)) diff --git a/esphome/components/template/binary_sensor/__init__.py b/esphome/components/template/binary_sensor/__init__.py index d23e6423a1..754b7a4a43 100644 --- a/esphome/components/template/binary_sensor/__init__.py +++ b/esphome/components/template/binary_sensor/__init__.py @@ -17,13 +17,13 @@ CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield binary_sensor.register_binary_sensor(var, config) + await cg.register_component(var, config) + await binary_sensor.register_binary_sensor(var, config) if CONF_LAMBDA in config: - template_ = yield cg.process_lambda( + template_ = await cg.process_lambda( config[CONF_LAMBDA], [], return_type=cg.optional.template(bool) ) cg.add(var.set_template(template_)) diff --git a/esphome/components/template/cover/__init__.py b/esphome/components/template/cover/__init__.py index 14050cb7c6..3d28e839ad 100644 --- a/esphome/components/template/cover/__init__.py +++ b/esphome/components/template/cover/__init__.py @@ -52,39 +52,39 @@ CONFIG_SCHEMA = cover.COVER_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield cover.register_cover(var, config) + await cg.register_component(var, config) + await cover.register_cover(var, config) if CONF_LAMBDA in config: - template_ = yield cg.process_lambda( + template_ = await cg.process_lambda( config[CONF_LAMBDA], [], return_type=cg.optional.template(float) ) cg.add(var.set_state_lambda(template_)) if CONF_OPEN_ACTION in config: - yield automation.build_automation( + await automation.build_automation( var.get_open_trigger(), [], config[CONF_OPEN_ACTION] ) if CONF_CLOSE_ACTION in config: - yield automation.build_automation( + await automation.build_automation( var.get_close_trigger(), [], config[CONF_CLOSE_ACTION] ) if CONF_STOP_ACTION in config: - yield automation.build_automation( + await automation.build_automation( var.get_stop_trigger(), [], config[CONF_STOP_ACTION] ) if CONF_TILT_ACTION in config: - yield automation.build_automation( + await automation.build_automation( var.get_tilt_trigger(), [(float, "tilt")], config[CONF_TILT_ACTION] ) cg.add(var.set_has_tilt(True)) if CONF_TILT_LAMBDA in config: - tilt_template_ = yield cg.process_lambda( + tilt_template_ = await cg.process_lambda( config[CONF_TILT_LAMBDA], [], return_type=cg.optional.template(float) ) cg.add(var.set_tilt_lambda(tilt_template_)) if CONF_POSITION_ACTION in config: - yield automation.build_automation( + await automation.build_automation( var.get_position_trigger(), [(float, "pos")], config[CONF_POSITION_ACTION] ) cg.add(var.set_has_position(True)) diff --git a/esphome/components/template/output/__init__.py b/esphome/components/template/output/__init__.py index 61286772d2..b42a4be166 100644 --- a/esphome/components/template/output/__init__.py +++ b/esphome/components/template/output/__init__.py @@ -34,14 +34,14 @@ CONFIG_SCHEMA = cv.typed_schema( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) if config[CONF_TYPE] == CONF_BINARY: - yield automation.build_automation( + await automation.build_automation( var.get_trigger(), [(bool, "state")], config[CONF_WRITE_ACTION] ) else: - yield automation.build_automation( + await automation.build_automation( var.get_trigger(), [(float, "state")], config[CONF_WRITE_ACTION] ) - yield output.register_output(var, config) + await output.register_output(var, config) diff --git a/esphome/components/template/sensor/__init__.py b/esphome/components/template/sensor/__init__.py index 21ef5db32d..ea776f6705 100644 --- a/esphome/components/template/sensor/__init__.py +++ b/esphome/components/template/sensor/__init__.py @@ -28,13 +28,13 @@ CONFIG_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) if CONF_LAMBDA in config: - template_ = yield cg.process_lambda( + template_ = await cg.process_lambda( config[CONF_LAMBDA], [], return_type=cg.optional.template(float) ) cg.add(var.set_template(template_)) diff --git a/esphome/components/template/switch/__init__.py b/esphome/components/template/switch/__init__.py index 7698e4f2a9..9fd4baeb3a 100644 --- a/esphome/components/template/switch/__init__.py +++ b/esphome/components/template/switch/__init__.py @@ -29,22 +29,22 @@ CONFIG_SCHEMA = switch.SWITCH_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield switch.register_switch(var, config) + await cg.register_component(var, config) + await switch.register_switch(var, config) if CONF_LAMBDA in config: - template_ = yield cg.process_lambda( + template_ = await cg.process_lambda( config[CONF_LAMBDA], [], return_type=cg.optional.template(bool) ) cg.add(var.set_state_lambda(template_)) if CONF_TURN_OFF_ACTION in config: - yield automation.build_automation( + await automation.build_automation( var.get_turn_off_trigger(), [], config[CONF_TURN_OFF_ACTION] ) if CONF_TURN_ON_ACTION in config: - yield automation.build_automation( + await automation.build_automation( var.get_turn_on_trigger(), [], config[CONF_TURN_ON_ACTION] ) cg.add(var.set_optimistic(config[CONF_OPTIMISTIC])) diff --git a/esphome/components/template/text_sensor/__init__.py b/esphome/components/template/text_sensor/__init__.py index cae00e3932..e97632025d 100644 --- a/esphome/components/template/text_sensor/__init__.py +++ b/esphome/components/template/text_sensor/__init__.py @@ -18,13 +18,13 @@ CONFIG_SCHEMA = text_sensor.TEXT_SENSOR_SCHEMA.extend( ).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) - yield text_sensor.register_text_sensor(var, config) + await cg.register_component(var, config) + await text_sensor.register_text_sensor(var, config) if CONF_LAMBDA in config: - template_ = yield cg.process_lambda( + template_ = await cg.process_lambda( config[CONF_LAMBDA], [], return_type=cg.optional.template(cg.std_string) ) cg.add(var.set_template(template_)) diff --git a/esphome/components/thermostat/climate.py b/esphome/components/thermostat/climate.py index 04584583af..4a371ec165 100644 --- a/esphome/components/thermostat/climate.py +++ b/esphome/components/thermostat/climate.py @@ -222,17 +222,17 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield climate.register_climate(var, config) + await cg.register_component(var, config) + await climate.register_climate(var, config) auto_mode_available = CONF_HEAT_ACTION in config and CONF_COOL_ACTION in config two_points_available = CONF_HEAT_ACTION in config and ( CONF_COOL_ACTION in config or CONF_FAN_ONLY_ACTION in config ) - sens = yield cg.get_variable(config[CONF_SENSOR]) + sens = await cg.get_variable(config[CONF_SENSOR]) cg.add(var.set_sensor(sens)) cg.add(var.set_hysteresis(config[CONF_HYSTERESIS])) @@ -254,7 +254,7 @@ def to_code(config): ) cg.add(var.set_normal_config(normal_config)) - yield automation.build_automation( + await automation.build_automation( var.get_idle_action_trigger(), [], config[CONF_IDLE_ACTION] ) @@ -264,117 +264,117 @@ def to_code(config): cg.add(var.set_supports_auto(False)) if CONF_COOL_ACTION in config: - yield automation.build_automation( + await automation.build_automation( var.get_cool_action_trigger(), [], config[CONF_COOL_ACTION] ) cg.add(var.set_supports_cool(True)) if CONF_DRY_ACTION in config: - yield automation.build_automation( + await automation.build_automation( var.get_dry_action_trigger(), [], config[CONF_DRY_ACTION] ) cg.add(var.set_supports_dry(True)) if CONF_FAN_ONLY_ACTION in config: - yield automation.build_automation( + await automation.build_automation( var.get_fan_only_action_trigger(), [], config[CONF_FAN_ONLY_ACTION] ) cg.add(var.set_supports_fan_only(True)) if CONF_HEAT_ACTION in config: - yield automation.build_automation( + await automation.build_automation( var.get_heat_action_trigger(), [], config[CONF_HEAT_ACTION] ) cg.add(var.set_supports_heat(True)) if CONF_AUTO_MODE in config: - yield automation.build_automation( + await automation.build_automation( var.get_auto_mode_trigger(), [], config[CONF_AUTO_MODE] ) if CONF_COOL_MODE in config: - yield automation.build_automation( + await automation.build_automation( var.get_cool_mode_trigger(), [], config[CONF_COOL_MODE] ) cg.add(var.set_supports_cool(True)) if CONF_DRY_MODE in config: - yield automation.build_automation( + await automation.build_automation( var.get_dry_mode_trigger(), [], config[CONF_DRY_MODE] ) cg.add(var.set_supports_dry(True)) if CONF_FAN_ONLY_MODE in config: - yield automation.build_automation( + await automation.build_automation( var.get_fan_only_mode_trigger(), [], config[CONF_FAN_ONLY_MODE] ) cg.add(var.set_supports_fan_only(True)) if CONF_HEAT_MODE in config: - yield automation.build_automation( + await automation.build_automation( var.get_heat_mode_trigger(), [], config[CONF_HEAT_MODE] ) cg.add(var.set_supports_heat(True)) if CONF_OFF_MODE in config: - yield automation.build_automation( + await automation.build_automation( var.get_off_mode_trigger(), [], config[CONF_OFF_MODE] ) if CONF_FAN_MODE_ON_ACTION in config: - yield automation.build_automation( + await automation.build_automation( var.get_fan_mode_on_trigger(), [], config[CONF_FAN_MODE_ON_ACTION] ) cg.add(var.set_supports_fan_mode_on(True)) if CONF_FAN_MODE_OFF_ACTION in config: - yield automation.build_automation( + await automation.build_automation( var.get_fan_mode_off_trigger(), [], config[CONF_FAN_MODE_OFF_ACTION] ) cg.add(var.set_supports_fan_mode_off(True)) if CONF_FAN_MODE_AUTO_ACTION in config: - yield automation.build_automation( + await automation.build_automation( var.get_fan_mode_auto_trigger(), [], config[CONF_FAN_MODE_AUTO_ACTION] ) cg.add(var.set_supports_fan_mode_auto(True)) if CONF_FAN_MODE_LOW_ACTION in config: - yield automation.build_automation( + await automation.build_automation( var.get_fan_mode_low_trigger(), [], config[CONF_FAN_MODE_LOW_ACTION] ) cg.add(var.set_supports_fan_mode_low(True)) if CONF_FAN_MODE_MEDIUM_ACTION in config: - yield automation.build_automation( + await automation.build_automation( var.get_fan_mode_medium_trigger(), [], config[CONF_FAN_MODE_MEDIUM_ACTION] ) cg.add(var.set_supports_fan_mode_medium(True)) if CONF_FAN_MODE_HIGH_ACTION in config: - yield automation.build_automation( + await automation.build_automation( var.get_fan_mode_high_trigger(), [], config[CONF_FAN_MODE_HIGH_ACTION] ) cg.add(var.set_supports_fan_mode_high(True)) if CONF_FAN_MODE_MIDDLE_ACTION in config: - yield automation.build_automation( + await automation.build_automation( var.get_fan_mode_middle_trigger(), [], config[CONF_FAN_MODE_MIDDLE_ACTION] ) cg.add(var.set_supports_fan_mode_middle(True)) if CONF_FAN_MODE_FOCUS_ACTION in config: - yield automation.build_automation( + await automation.build_automation( var.get_fan_mode_focus_trigger(), [], config[CONF_FAN_MODE_FOCUS_ACTION] ) cg.add(var.set_supports_fan_mode_focus(True)) if CONF_FAN_MODE_DIFFUSE_ACTION in config: - yield automation.build_automation( + await automation.build_automation( var.get_fan_mode_diffuse_trigger(), [], config[CONF_FAN_MODE_DIFFUSE_ACTION] ) cg.add(var.set_supports_fan_mode_diffuse(True)) if CONF_SWING_BOTH_ACTION in config: - yield automation.build_automation( + await automation.build_automation( var.get_swing_mode_both_trigger(), [], config[CONF_SWING_BOTH_ACTION] ) cg.add(var.set_supports_swing_mode_both(True)) if CONF_SWING_HORIZONTAL_ACTION in config: - yield automation.build_automation( + await automation.build_automation( var.get_swing_mode_horizontal_trigger(), [], config[CONF_SWING_HORIZONTAL_ACTION], ) cg.add(var.set_supports_swing_mode_horizontal(True)) if CONF_SWING_OFF_ACTION in config: - yield automation.build_automation( + await automation.build_automation( var.get_swing_mode_off_trigger(), [], config[CONF_SWING_OFF_ACTION] ) cg.add(var.set_supports_swing_mode_off(True)) if CONF_SWING_VERTICAL_ACTION in config: - yield automation.build_automation( + await automation.build_automation( var.get_swing_mode_vertical_trigger(), [], config[CONF_SWING_VERTICAL_ACTION], diff --git a/esphome/components/time_based/cover.py b/esphome/components/time_based/cover.py index 9246f78884..9625781c96 100644 --- a/esphome/components/time_based/cover.py +++ b/esphome/components/time_based/cover.py @@ -31,22 +31,22 @@ CONFIG_SCHEMA = cover.COVER_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield cover.register_cover(var, config) + await cg.register_component(var, config) + await cover.register_cover(var, config) - yield automation.build_automation( + await automation.build_automation( var.get_stop_trigger(), [], config[CONF_STOP_ACTION] ) cg.add(var.set_open_duration(config[CONF_OPEN_DURATION])) - yield automation.build_automation( + await automation.build_automation( var.get_open_trigger(), [], config[CONF_OPEN_ACTION] ) cg.add(var.set_close_duration(config[CONF_CLOSE_DURATION])) - yield automation.build_automation( + await automation.build_automation( var.get_close_trigger(), [], config[CONF_CLOSE_ACTION] ) diff --git a/esphome/components/tlc59208f/__init__.py b/esphome/components/tlc59208f/__init__.py index ff5b75954b..419fa397b7 100644 --- a/esphome/components/tlc59208f/__init__.py +++ b/esphome/components/tlc59208f/__init__.py @@ -20,7 +20,7 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) diff --git a/esphome/components/tlc59208f/output.py b/esphome/components/tlc59208f/output.py index 94cf529a75..f7cc89b252 100644 --- a/esphome/components/tlc59208f/output.py +++ b/esphome/components/tlc59208f/output.py @@ -18,8 +18,8 @@ CONFIG_SCHEMA = output.FLOAT_OUTPUT_SCHEMA.extend( ) -def to_code(config): - paren = yield cg.get_variable(config[CONF_TLC59208F_ID]) +async def to_code(config): + paren = await cg.get_variable(config[CONF_TLC59208F_ID]) rhs = paren.create_channel(config[CONF_CHANNEL]) var = cg.Pvariable(config[CONF_ID], rhs) - yield output.register_output(var, config) + await output.register_output(var, config) diff --git a/esphome/components/tm1637/display.py b/esphome/components/tm1637/display.py index 06a9716e59..7999029f5a 100644 --- a/esphome/components/tm1637/display.py +++ b/esphome/components/tm1637/display.py @@ -28,20 +28,20 @@ CONFIG_SCHEMA = display.BASIC_DISPLAY_SCHEMA.extend( ).extend(cv.polling_component_schema("1s")) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield display.register_display(var, config) + await cg.register_component(var, config) + await display.register_display(var, config) - clk = yield cg.gpio_pin_expression(config[CONF_CLK_PIN]) + clk = await cg.gpio_pin_expression(config[CONF_CLK_PIN]) cg.add(var.set_clk_pin(clk)) - dio = yield cg.gpio_pin_expression(config[CONF_DIO_PIN]) + dio = await cg.gpio_pin_expression(config[CONF_DIO_PIN]) cg.add(var.set_dio_pin(dio)) cg.add(var.set_intensity(config[CONF_INTENSITY])) if CONF_LAMBDA in config: - lambda_ = yield cg.process_lambda( + lambda_ = await cg.process_lambda( config[CONF_LAMBDA], [(TM1637DisplayRef, "it")], return_type=cg.void ) cg.add(var.set_writer(lambda_)) diff --git a/esphome/components/tm1651/__init__.py b/esphome/components/tm1651/__init__.py index 97c1e472e9..e8c1425d83 100644 --- a/esphome/components/tm1651/__init__.py +++ b/esphome/components/tm1651/__init__.py @@ -40,13 +40,13 @@ validate_level = cv.All(cv.int_range(min=0, max=7)) validate_brightness = cv.enum(TM1651_BRIGHTNESS_OPTIONS, int=True) -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) - clk_pin = yield cg.gpio_pin_expression(config[CONF_CLK_PIN]) + clk_pin = await cg.gpio_pin_expression(config[CONF_CLK_PIN]) cg.add(var.set_clk_pin(clk_pin)) - dio_pin = yield cg.gpio_pin_expression(config[CONF_DIO_PIN]) + dio_pin = await cg.gpio_pin_expression(config[CONF_DIO_PIN]) cg.add(var.set_dio_pin(dio_pin)) # https://platformio.org/lib/show/6865/TM1651 diff --git a/esphome/components/tmp102/sensor.py b/esphome/components/tmp102/sensor.py index 4c04271d96..6a0d3cd73e 100644 --- a/esphome/components/tmp102/sensor.py +++ b/esphome/components/tmp102/sensor.py @@ -32,8 +32,8 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) - yield sensor.register_sensor(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) + await sensor.register_sensor(var, config) diff --git a/esphome/components/tmp117/sensor.py b/esphome/components/tmp117/sensor.py index 33c13e3f3b..81a9569ca5 100644 --- a/esphome/components/tmp117/sensor.py +++ b/esphome/components/tmp117/sensor.py @@ -70,11 +70,11 @@ def determine_config_register(polling_period): return 0x0000 -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) - yield sensor.register_sensor(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) + await sensor.register_sensor(var, config) update_period = config[CONF_UPDATE_INTERVAL].total_seconds cg.add(var.set_config(determine_config_register(update_period))) diff --git a/esphome/components/tof10120/sensor.py b/esphome/components/tof10120/sensor.py index 91a15960b4..5ff8c23cc6 100644 --- a/esphome/components/tof10120/sensor.py +++ b/esphome/components/tof10120/sensor.py @@ -19,8 +19,8 @@ CONFIG_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) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await sensor.register_sensor(var, config) + await i2c.register_i2c_device(var, config) diff --git a/esphome/components/toshiba/climate.py b/esphome/components/toshiba/climate.py index 3021697f21..95c9f1f127 100644 --- a/esphome/components/toshiba/climate.py +++ b/esphome/components/toshiba/climate.py @@ -15,6 +15,6 @@ CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield climate_ir.register_climate_ir(var, config) + await climate_ir.register_climate_ir(var, config) diff --git a/esphome/components/total_daily_energy/sensor.py b/esphome/components/total_daily_energy/sensor.py index 150cab77b4..b70a0cece9 100644 --- a/esphome/components/total_daily_energy/sensor.py +++ b/esphome/components/total_daily_energy/sensor.py @@ -20,13 +20,13 @@ CONFIG_SCHEMA = sensor.SENSOR_SCHEMA.extend( ).extend(cv.COMPONENT_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) - sens = yield cg.get_variable(config[CONF_POWER_ID]) + sens = await cg.get_variable(config[CONF_POWER_ID]) cg.add(var.set_parent(sens)) - time_ = yield cg.get_variable(config[CONF_TIME_ID]) + time_ = await cg.get_variable(config[CONF_TIME_ID]) cg.add(var.set_time(time_)) diff --git a/esphome/components/tsl2561/sensor.py b/esphome/components/tsl2561/sensor.py index d0219fc078..a49c776447 100644 --- a/esphome/components/tsl2561/sensor.py +++ b/esphome/components/tsl2561/sensor.py @@ -55,11 +55,11 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) - yield sensor.register_sensor(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) + await sensor.register_sensor(var, config) cg.add(var.set_integration_time(config[CONF_INTEGRATION_TIME])) cg.add(var.set_gain(config[CONF_GAIN])) diff --git a/esphome/components/ttp229_bsf/__init__.py b/esphome/components/ttp229_bsf/__init__.py index 8707c9efe3..f1f86c929e 100644 --- a/esphome/components/ttp229_bsf/__init__.py +++ b/esphome/components/ttp229_bsf/__init__.py @@ -21,11 +21,11 @@ CONFIG_SCHEMA = cv.Schema( ).extend(cv.COMPONENT_SCHEMA) -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) - sdo = yield cg.gpio_pin_expression(config[CONF_SDO_PIN]) + sdo = await cg.gpio_pin_expression(config[CONF_SDO_PIN]) cg.add(var.set_sdo_pin(sdo)) - scl = yield cg.gpio_pin_expression(config[CONF_SCL_PIN]) + scl = await cg.gpio_pin_expression(config[CONF_SCL_PIN]) cg.add(var.set_scl_pin(scl)) diff --git a/esphome/components/ttp229_bsf/binary_sensor.py b/esphome/components/ttp229_bsf/binary_sensor.py index 7351e73d80..75540fe0e8 100644 --- a/esphome/components/ttp229_bsf/binary_sensor.py +++ b/esphome/components/ttp229_bsf/binary_sensor.py @@ -16,10 +16,10 @@ CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield binary_sensor.register_binary_sensor(var, config) + await binary_sensor.register_binary_sensor(var, config) cg.add(var.set_channel(config[CONF_CHANNEL])) - hub = yield cg.get_variable(config[CONF_TTP229_ID]) + hub = await cg.get_variable(config[CONF_TTP229_ID]) cg.add(hub.register_channel(var)) diff --git a/esphome/components/ttp229_lsf/__init__.py b/esphome/components/ttp229_lsf/__init__.py index 1d7efea205..cba41a7938 100644 --- a/esphome/components/ttp229_lsf/__init__.py +++ b/esphome/components/ttp229_lsf/__init__.py @@ -25,7 +25,7 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield i2c.register_i2c_device(var, config) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) diff --git a/esphome/components/ttp229_lsf/binary_sensor.py b/esphome/components/ttp229_lsf/binary_sensor.py index 09a8a1e207..b52a9e8575 100644 --- a/esphome/components/ttp229_lsf/binary_sensor.py +++ b/esphome/components/ttp229_lsf/binary_sensor.py @@ -16,10 +16,10 @@ CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield binary_sensor.register_binary_sensor(var, config) + await binary_sensor.register_binary_sensor(var, config) cg.add(var.set_channel(config[CONF_CHANNEL])) - hub = yield cg.get_variable(config[CONF_TTP229_ID]) + hub = await cg.get_variable(config[CONF_TTP229_ID]) cg.add(hub.register_channel(var)) diff --git a/esphome/components/tuya/__init__.py b/esphome/components/tuya/__init__.py index 58dad13257..436759979a 100644 --- a/esphome/components/tuya/__init__.py +++ b/esphome/components/tuya/__init__.py @@ -27,12 +27,12 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield uart.register_uart_device(var, config) + await cg.register_component(var, config) + await uart.register_uart_device(var, config) if CONF_TIME_ID in config: - time_ = yield cg.get_variable(config[CONF_TIME_ID]) + time_ = await cg.get_variable(config[CONF_TIME_ID]) cg.add(var.set_time_id(time_)) if CONF_IGNORE_MCU_UPDATE_ON_DATAPOINTS in config: for dp in config[CONF_IGNORE_MCU_UPDATE_ON_DATAPOINTS]: diff --git a/esphome/components/tuya/binary_sensor/__init__.py b/esphome/components/tuya/binary_sensor/__init__.py index 45f918ff24..65f13ea422 100644 --- a/esphome/components/tuya/binary_sensor/__init__.py +++ b/esphome/components/tuya/binary_sensor/__init__.py @@ -22,12 +22,12 @@ CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield binary_sensor.register_binary_sensor(var, config) + await cg.register_component(var, config) + await binary_sensor.register_binary_sensor(var, config) - paren = yield cg.get_variable(config[CONF_TUYA_ID]) + paren = await cg.get_variable(config[CONF_TUYA_ID]) cg.add(var.set_tuya_parent(paren)) cg.add(var.set_sensor_id(config[CONF_SENSOR_DATAPOINT])) diff --git a/esphome/components/tuya/climate/__init__.py b/esphome/components/tuya/climate/__init__.py index 8ac42f7c8f..a24ae23edc 100644 --- a/esphome/components/tuya/climate/__init__.py +++ b/esphome/components/tuya/climate/__init__.py @@ -77,12 +77,12 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield climate.register_climate(var, config) + await cg.register_component(var, config) + await climate.register_climate(var, config) - paren = yield cg.get_variable(config[CONF_TUYA_ID]) + paren = await cg.get_variable(config[CONF_TUYA_ID]) cg.add(var.set_tuya_parent(paren)) if CONF_SWITCH_DATAPOINT in config: diff --git a/esphome/components/tuya/fan/__init__.py b/esphome/components/tuya/fan/__init__.py index 5d3345a5c4..6d660e6d29 100644 --- a/esphome/components/tuya/fan/__init__.py +++ b/esphome/components/tuya/fan/__init__.py @@ -28,14 +28,14 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): - parent = yield cg.get_variable(config[CONF_TUYA_ID]) - state = yield fan.create_fan_state(config) +async def to_code(config): + parent = await cg.get_variable(config[CONF_TUYA_ID]) + state = await fan.create_fan_state(config) var = cg.new_Pvariable( config[CONF_OUTPUT_ID], parent, state, config[CONF_SPEED_COUNT] ) - yield cg.register_component(var, config) + await cg.register_component(var, config) if CONF_SPEED_DATAPOINT in config: cg.add(var.set_speed_id(config[CONF_SPEED_DATAPOINT])) diff --git a/esphome/components/tuya/light/__init__.py b/esphome/components/tuya/light/__init__.py index f8026e47e8..6dd8b6b775 100644 --- a/esphome/components/tuya/light/__init__.py +++ b/esphome/components/tuya/light/__init__.py @@ -40,10 +40,10 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_OUTPUT_ID]) - yield cg.register_component(var, config) - yield light.register_light(var, config) + await cg.register_component(var, config) + await light.register_light(var, config) if CONF_DIMMER_DATAPOINT in config: cg.add(var.set_dimmer_id(config[CONF_DIMMER_DATAPOINT])) @@ -55,5 +55,5 @@ def to_code(config): cg.add(var.set_min_value(config[CONF_MIN_VALUE])) if CONF_MAX_VALUE in config: cg.add(var.set_max_value(config[CONF_MAX_VALUE])) - paren = yield cg.get_variable(config[CONF_TUYA_ID]) + paren = await cg.get_variable(config[CONF_TUYA_ID]) cg.add(var.set_tuya_parent(paren)) diff --git a/esphome/components/tuya/sensor/__init__.py b/esphome/components/tuya/sensor/__init__.py index 0a02fb77a1..d87a2e7ce4 100644 --- a/esphome/components/tuya/sensor/__init__.py +++ b/esphome/components/tuya/sensor/__init__.py @@ -20,12 +20,12 @@ CONFIG_SCHEMA = sensor.SENSOR_SCHEMA.extend( ).extend(cv.COMPONENT_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) - paren = yield cg.get_variable(config[CONF_TUYA_ID]) + paren = await cg.get_variable(config[CONF_TUYA_ID]) cg.add(var.set_tuya_parent(paren)) cg.add(var.set_sensor_id(config[CONF_SENSOR_DATAPOINT])) diff --git a/esphome/components/tuya/switch/__init__.py b/esphome/components/tuya/switch/__init__.py index 4c4ccbf814..4df6bba713 100644 --- a/esphome/components/tuya/switch/__init__.py +++ b/esphome/components/tuya/switch/__init__.py @@ -18,12 +18,12 @@ CONFIG_SCHEMA = switch.SWITCH_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield switch.register_switch(var, config) + await cg.register_component(var, config) + await switch.register_switch(var, config) - paren = yield cg.get_variable(config[CONF_TUYA_ID]) + paren = await cg.get_variable(config[CONF_TUYA_ID]) cg.add(var.set_tuya_parent(paren)) cg.add(var.set_switch_id(config[CONF_SWITCH_DATAPOINT])) diff --git a/esphome/components/tx20/sensor.py b/esphome/components/tx20/sensor.py index 434257470b..5b275505fd 100644 --- a/esphome/components/tx20/sensor.py +++ b/esphome/components/tx20/sensor.py @@ -33,19 +33,19 @@ CONFIG_SCHEMA = cv.Schema( ).extend(cv.COMPONENT_SCHEMA) -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) if CONF_WIND_SPEED in config: conf = config[CONF_WIND_SPEED] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_wind_speed_sensor(sens)) if CONF_WIND_DIRECTION_DEGREES in config: conf = config[CONF_WIND_DIRECTION_DEGREES] - sens = yield sensor.new_sensor(conf) + sens = await sensor.new_sensor(conf) cg.add(var.set_wind_direction_degrees_sensor(sens)) - pin = yield cg.gpio_pin_expression(config[CONF_PIN]) + pin = await cg.gpio_pin_expression(config[CONF_PIN]) cg.add(var.set_pin(pin)) diff --git a/esphome/components/uart/switch/__init__.py b/esphome/components/uart/switch/__init__.py index e84035aa3e..9e7f95bd2a 100644 --- a/esphome/components/uart/switch/__init__.py +++ b/esphome/components/uart/switch/__init__.py @@ -26,11 +26,11 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield switch.register_switch(var, config) - yield uart.register_uart_device(var, config) + await cg.register_component(var, config) + await switch.register_switch(var, config) + await uart.register_uart_device(var, config) data = config[CONF_DATA] if isinstance(data, bytes): diff --git a/esphome/components/uln2003/stepper.py b/esphome/components/uln2003/stepper.py index 4d2e5ab518..88252ead73 100644 --- a/esphome/components/uln2003/stepper.py +++ b/esphome/components/uln2003/stepper.py @@ -38,18 +38,18 @@ CONFIG_SCHEMA = stepper.STEPPER_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield stepper.register_stepper(var, config) + await cg.register_component(var, config) + await stepper.register_stepper(var, config) - pin_a = yield cg.gpio_pin_expression(config[CONF_PIN_A]) + pin_a = await cg.gpio_pin_expression(config[CONF_PIN_A]) cg.add(var.set_pin_a(pin_a)) - pin_b = yield cg.gpio_pin_expression(config[CONF_PIN_B]) + pin_b = await cg.gpio_pin_expression(config[CONF_PIN_B]) cg.add(var.set_pin_b(pin_b)) - pin_c = yield cg.gpio_pin_expression(config[CONF_PIN_C]) + pin_c = await cg.gpio_pin_expression(config[CONF_PIN_C]) cg.add(var.set_pin_c(pin_c)) - pin_d = yield cg.gpio_pin_expression(config[CONF_PIN_D]) + pin_d = await cg.gpio_pin_expression(config[CONF_PIN_D]) cg.add(var.set_pin_d(pin_d)) cg.add(var.set_sleep_when_done(config[CONF_SLEEP_WHEN_DONE])) diff --git a/esphome/components/ultrasonic/sensor.py b/esphome/components/ultrasonic/sensor.py index d5d8dec6f4..43492a7a2e 100644 --- a/esphome/components/ultrasonic/sensor.py +++ b/esphome/components/ultrasonic/sensor.py @@ -43,14 +43,14 @@ CONFIG_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) - trigger = yield cg.gpio_pin_expression(config[CONF_TRIGGER_PIN]) + trigger = await cg.gpio_pin_expression(config[CONF_TRIGGER_PIN]) cg.add(var.set_trigger_pin(trigger)) - echo = yield cg.gpio_pin_expression(config[CONF_ECHO_PIN]) + echo = await cg.gpio_pin_expression(config[CONF_ECHO_PIN]) cg.add(var.set_echo_pin(echo)) cg.add(var.set_timeout_us(config[CONF_TIMEOUT] / (0.000343 / 2))) diff --git a/esphome/components/uptime/sensor.py b/esphome/components/uptime/sensor.py index c2e35ddfef..86bd58e739 100644 --- a/esphome/components/uptime/sensor.py +++ b/esphome/components/uptime/sensor.py @@ -17,7 +17,7 @@ CONFIG_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) diff --git a/esphome/components/version/text_sensor.py b/esphome/components/version/text_sensor.py index 711800136c..e67f881d32 100644 --- a/esphome/components/version/text_sensor.py +++ b/esphome/components/version/text_sensor.py @@ -17,8 +17,8 @@ CONFIG_SCHEMA = text_sensor.TEXT_SENSOR_SCHEMA.extend( ).extend(cv.COMPONENT_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield text_sensor.register_text_sensor(var, config) - yield cg.register_component(var, config) + await text_sensor.register_text_sensor(var, config) + await cg.register_component(var, config) cg.add(var.set_hide_timestamp(config[CONF_HIDE_TIMESTAMP])) diff --git a/esphome/components/vl53l0x/sensor.py b/esphome/components/vl53l0x/sensor.py index 309d4cf8b3..775532dc9e 100644 --- a/esphome/components/vl53l0x/sensor.py +++ b/esphome/components/vl53l0x/sensor.py @@ -58,16 +58,16 @@ CONFIG_SCHEMA = cv.All( ) -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) cg.add(var.set_signal_rate_limit(config[CONF_SIGNAL_RATE_LIMIT])) cg.add(var.set_long_range(config[CONF_LONG_RANGE])) cg.add(var.set_timeout_us(config[CONF_TIMEOUT])) if CONF_ENABLE_PIN in config: - enable = yield cg.gpio_pin_expression(config[CONF_ENABLE_PIN]) + enable = await cg.gpio_pin_expression(config[CONF_ENABLE_PIN]) cg.add(var.set_enable_pin(enable)) - yield sensor.register_sensor(var, config) - yield i2c.register_i2c_device(var, config) + await sensor.register_sensor(var, config) + await i2c.register_i2c_device(var, config) diff --git a/esphome/components/waveshare_epaper/display.py b/esphome/components/waveshare_epaper/display.py index 16f234563c..42509f39f1 100644 --- a/esphome/components/waveshare_epaper/display.py +++ b/esphome/components/waveshare_epaper/display.py @@ -90,7 +90,7 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): model_type, model = MODELS[config[CONF_MODEL]] if model_type == "a": rhs = WaveshareEPaperTypeA.new(model) @@ -101,23 +101,23 @@ def to_code(config): else: raise NotImplementedError() - yield cg.register_component(var, config) - yield display.register_display(var, config) - yield spi.register_spi_device(var, config) + await cg.register_component(var, config) + await display.register_display(var, config) + await spi.register_spi_device(var, config) - dc = yield cg.gpio_pin_expression(config[CONF_DC_PIN]) + dc = await cg.gpio_pin_expression(config[CONF_DC_PIN]) cg.add(var.set_dc_pin(dc)) if CONF_LAMBDA in config: - lambda_ = yield cg.process_lambda( + lambda_ = await cg.process_lambda( config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void ) cg.add(var.set_writer(lambda_)) if CONF_RESET_PIN in config: - reset = yield cg.gpio_pin_expression(config[CONF_RESET_PIN]) + reset = await cg.gpio_pin_expression(config[CONF_RESET_PIN]) cg.add(var.set_reset_pin(reset)) if CONF_BUSY_PIN in config: - reset = yield cg.gpio_pin_expression(config[CONF_BUSY_PIN]) + reset = await cg.gpio_pin_expression(config[CONF_BUSY_PIN]) cg.add(var.set_busy_pin(reset)) if CONF_FULL_UPDATE_EVERY in config: cg.add(var.set_full_update_every(config[CONF_FULL_UPDATE_EVERY])) diff --git a/esphome/components/whirlpool/climate.py b/esphome/components/whirlpool/climate.py index d6d9f3e111..c5b953c46f 100644 --- a/esphome/components/whirlpool/climate.py +++ b/esphome/components/whirlpool/climate.py @@ -23,7 +23,7 @@ CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield climate_ir.register_climate_ir(var, config) + await climate_ir.register_climate_ir(var, config) cg.add(var.set_model(config[CONF_MODEL])) diff --git a/esphome/components/wifi_info/text_sensor.py b/esphome/components/wifi_info/text_sensor.py index 07af63524c..11978f7bfe 100644 --- a/esphome/components/wifi_info/text_sensor.py +++ b/esphome/components/wifi_info/text_sensor.py @@ -59,8 +59,8 @@ def setup_conf(config, key): yield text_sensor.register_text_sensor(var, conf) -def to_code(config): - yield setup_conf(config, CONF_IP_ADDRESS) - yield setup_conf(config, CONF_SSID) - yield setup_conf(config, CONF_BSSID) - yield setup_conf(config, CONF_MAC_ADDRESS) +async def to_code(config): + await setup_conf(config, CONF_IP_ADDRESS) + await setup_conf(config, CONF_SSID) + await setup_conf(config, CONF_BSSID) + await setup_conf(config, CONF_MAC_ADDRESS) diff --git a/esphome/components/wifi_signal/sensor.py b/esphome/components/wifi_signal/sensor.py index 891d95d33e..be7f32b0d4 100644 --- a/esphome/components/wifi_signal/sensor.py +++ b/esphome/components/wifi_signal/sensor.py @@ -27,7 +27,7 @@ CONFIG_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) diff --git a/esphome/components/xiaomi_ble/__init__.py b/esphome/components/xiaomi_ble/__init__.py index 3d11ea8125..046adc6248 100644 --- a/esphome/components/xiaomi_ble/__init__.py +++ b/esphome/components/xiaomi_ble/__init__.py @@ -17,6 +17,6 @@ CONFIG_SCHEMA = cv.Schema( ).extend(esp32_ble_tracker.ESP_BLE_DEVICE_SCHEMA) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield esp32_ble_tracker.register_ble_device(var, config) + await esp32_ble_tracker.register_ble_device(var, config) diff --git a/esphome/components/xiaomi_cgd1/sensor.py b/esphome/components/xiaomi_cgd1/sensor.py index 25d1f93674..e8a27660fd 100644 --- a/esphome/components/xiaomi_cgd1/sensor.py +++ b/esphome/components/xiaomi_cgd1/sensor.py @@ -46,20 +46,20 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield esp32_ble_tracker.register_ble_device(var, config) + await cg.register_component(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_bindkey(config[CONF_BINDKEY])) 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)) 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)) 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)) diff --git a/esphome/components/xiaomi_cgg1/sensor.py b/esphome/components/xiaomi_cgg1/sensor.py index cedf04d8a6..978393d2d4 100644 --- a/esphome/components/xiaomi_cgg1/sensor.py +++ b/esphome/components/xiaomi_cgg1/sensor.py @@ -46,21 +46,21 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield esp32_ble_tracker.register_ble_device(var, config) + await cg.register_component(var, config) + await esp32_ble_tracker.register_ble_device(var, config) cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex)) if CONF_BINDKEY in config: cg.add(var.set_bindkey(config[CONF_BINDKEY])) 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)) 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)) 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)) diff --git a/esphome/components/xiaomi_gcls002/sensor.py b/esphome/components/xiaomi_gcls002/sensor.py index b838371155..8789378824 100644 --- a/esphome/components/xiaomi_gcls002/sensor.py +++ b/esphome/components/xiaomi_gcls002/sensor.py @@ -52,22 +52,22 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield esp32_ble_tracker.register_ble_device(var, config) + await cg.register_component(var, config) + await esp32_ble_tracker.register_ble_device(var, config) cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex)) 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)) if CONF_MOISTURE in config: - sens = yield sensor.new_sensor(config[CONF_MOISTURE]) + sens = await sensor.new_sensor(config[CONF_MOISTURE]) cg.add(var.set_moisture(sens)) if CONF_ILLUMINANCE in config: - sens = yield sensor.new_sensor(config[CONF_ILLUMINANCE]) + sens = await sensor.new_sensor(config[CONF_ILLUMINANCE]) cg.add(var.set_illuminance(sens)) if CONF_CONDUCTIVITY in config: - sens = yield sensor.new_sensor(config[CONF_CONDUCTIVITY]) + sens = await sensor.new_sensor(config[CONF_CONDUCTIVITY]) cg.add(var.set_conductivity(sens)) diff --git a/esphome/components/xiaomi_hhccjcy01/sensor.py b/esphome/components/xiaomi_hhccjcy01/sensor.py index f657ec9373..13f6e5685c 100644 --- a/esphome/components/xiaomi_hhccjcy01/sensor.py +++ b/esphome/components/xiaomi_hhccjcy01/sensor.py @@ -57,25 +57,25 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield esp32_ble_tracker.register_ble_device(var, config) + await cg.register_component(var, config) + await esp32_ble_tracker.register_ble_device(var, config) cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex)) 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)) if CONF_MOISTURE in config: - sens = yield sensor.new_sensor(config[CONF_MOISTURE]) + sens = await sensor.new_sensor(config[CONF_MOISTURE]) cg.add(var.set_moisture(sens)) if CONF_ILLUMINANCE in config: - sens = yield sensor.new_sensor(config[CONF_ILLUMINANCE]) + sens = await sensor.new_sensor(config[CONF_ILLUMINANCE]) cg.add(var.set_illuminance(sens)) if CONF_CONDUCTIVITY in config: - sens = yield sensor.new_sensor(config[CONF_CONDUCTIVITY]) + sens = await sensor.new_sensor(config[CONF_CONDUCTIVITY]) cg.add(var.set_conductivity(sens)) 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)) diff --git a/esphome/components/xiaomi_hhccpot002/sensor.py b/esphome/components/xiaomi_hhccpot002/sensor.py index 820cda173d..d2493f77c6 100644 --- a/esphome/components/xiaomi_hhccpot002/sensor.py +++ b/esphome/components/xiaomi_hhccpot002/sensor.py @@ -39,16 +39,16 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield esp32_ble_tracker.register_ble_device(var, config) + await cg.register_component(var, config) + await esp32_ble_tracker.register_ble_device(var, config) cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex)) if CONF_MOISTURE in config: - sens = yield sensor.new_sensor(config[CONF_MOISTURE]) + sens = await sensor.new_sensor(config[CONF_MOISTURE]) cg.add(var.set_moisture(sens)) if CONF_CONDUCTIVITY in config: - sens = yield sensor.new_sensor(config[CONF_CONDUCTIVITY]) + sens = await sensor.new_sensor(config[CONF_CONDUCTIVITY]) cg.add(var.set_conductivity(sens)) diff --git a/esphome/components/xiaomi_jqjcy01ym/sensor.py b/esphome/components/xiaomi_jqjcy01ym/sensor.py index ce5e8e2b37..e2c2bce40e 100644 --- a/esphome/components/xiaomi_jqjcy01ym/sensor.py +++ b/esphome/components/xiaomi_jqjcy01ym/sensor.py @@ -54,22 +54,22 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield esp32_ble_tracker.register_ble_device(var, config) + await cg.register_component(var, config) + await esp32_ble_tracker.register_ble_device(var, config) cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex)) 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)) 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)) if CONF_FORMALDEHYDE in config: - sens = yield sensor.new_sensor(config[CONF_FORMALDEHYDE]) + sens = await sensor.new_sensor(config[CONF_FORMALDEHYDE]) cg.add(var.set_formaldehyde(sens)) 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)) diff --git a/esphome/components/xiaomi_lywsd02/sensor.py b/esphome/components/xiaomi_lywsd02/sensor.py index c17eb17a5f..5ea633dfa3 100644 --- a/esphome/components/xiaomi_lywsd02/sensor.py +++ b/esphome/components/xiaomi_lywsd02/sensor.py @@ -44,19 +44,19 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield esp32_ble_tracker.register_ble_device(var, config) + await cg.register_component(var, config) + await esp32_ble_tracker.register_ble_device(var, config) cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex)) 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)) 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)) 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)) diff --git a/esphome/components/xiaomi_lywsd03mmc/sensor.py b/esphome/components/xiaomi_lywsd03mmc/sensor.py index b9de3f0bcc..24bd8d78c6 100644 --- a/esphome/components/xiaomi_lywsd03mmc/sensor.py +++ b/esphome/components/xiaomi_lywsd03mmc/sensor.py @@ -48,20 +48,20 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield esp32_ble_tracker.register_ble_device(var, config) + await cg.register_component(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_bindkey(config[CONF_BINDKEY])) 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)) 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)) 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)) diff --git a/esphome/components/xiaomi_lywsdcgq/sensor.py b/esphome/components/xiaomi_lywsdcgq/sensor.py index a4a03a3fb0..b36a03e455 100644 --- a/esphome/components/xiaomi_lywsdcgq/sensor.py +++ b/esphome/components/xiaomi_lywsdcgq/sensor.py @@ -44,19 +44,19 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield esp32_ble_tracker.register_ble_device(var, config) + await cg.register_component(var, config) + await esp32_ble_tracker.register_ble_device(var, config) cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex)) 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)) 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)) 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)) diff --git a/esphome/components/xiaomi_mhoc401/sensor.py b/esphome/components/xiaomi_mhoc401/sensor.py index ee0e06b3a8..94c594621e 100644 --- a/esphome/components/xiaomi_mhoc401/sensor.py +++ b/esphome/components/xiaomi_mhoc401/sensor.py @@ -47,20 +47,20 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield esp32_ble_tracker.register_ble_device(var, config) + await cg.register_component(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_bindkey(config[CONF_BINDKEY])) 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)) 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)) 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)) diff --git a/esphome/components/xiaomi_miscale/sensor.py b/esphome/components/xiaomi_miscale/sensor.py index cd225e4853..4423dc13cd 100644 --- a/esphome/components/xiaomi_miscale/sensor.py +++ b/esphome/components/xiaomi_miscale/sensor.py @@ -32,13 +32,13 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield esp32_ble_tracker.register_ble_device(var, config) + await cg.register_component(var, config) + await esp32_ble_tracker.register_ble_device(var, config) cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex)) if CONF_WEIGHT in config: - sens = yield sensor.new_sensor(config[CONF_WEIGHT]) + sens = await sensor.new_sensor(config[CONF_WEIGHT]) cg.add(var.set_weight(sens)) diff --git a/esphome/components/xiaomi_miscale2/sensor.py b/esphome/components/xiaomi_miscale2/sensor.py index fa124e8860..f20ef38c87 100644 --- a/esphome/components/xiaomi_miscale2/sensor.py +++ b/esphome/components/xiaomi_miscale2/sensor.py @@ -38,16 +38,16 @@ CONFIG_SCHEMA = ( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield esp32_ble_tracker.register_ble_device(var, config) + await cg.register_component(var, config) + await esp32_ble_tracker.register_ble_device(var, config) cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex)) if CONF_WEIGHT in config: - sens = yield sensor.new_sensor(config[CONF_WEIGHT]) + sens = await sensor.new_sensor(config[CONF_WEIGHT]) cg.add(var.set_weight(sens)) if CONF_IMPEDANCE in config: - sens = yield sensor.new_sensor(config[CONF_IMPEDANCE]) + sens = await sensor.new_sensor(config[CONF_IMPEDANCE]) cg.add(var.set_impedance(sens)) diff --git a/esphome/components/xiaomi_mjyd02yla/binary_sensor.py b/esphome/components/xiaomi_mjyd02yla/binary_sensor.py index 1b0ad03f1a..a1c26b62a8 100644 --- a/esphome/components/xiaomi_mjyd02yla/binary_sensor.py +++ b/esphome/components/xiaomi_mjyd02yla/binary_sensor.py @@ -63,24 +63,24 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield esp32_ble_tracker.register_ble_device(var, config) - yield binary_sensor.register_binary_sensor(var, config) + await cg.register_component(var, config) + await esp32_ble_tracker.register_ble_device(var, config) + await binary_sensor.register_binary_sensor(var, config) cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex)) cg.add(var.set_bindkey(config[CONF_BINDKEY])) if CONF_IDLE_TIME in config: - sens = yield sensor.new_sensor(config[CONF_IDLE_TIME]) + sens = await sensor.new_sensor(config[CONF_IDLE_TIME]) cg.add(var.set_idle_time(sens)) 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)) if CONF_ILLUMINANCE in config: - sens = yield sensor.new_sensor(config[CONF_ILLUMINANCE]) + sens = await sensor.new_sensor(config[CONF_ILLUMINANCE]) cg.add(var.set_illuminance(sens)) if CONF_LIGHT in config: - sens = yield binary_sensor.new_binary_sensor(config[CONF_LIGHT]) + sens = await binary_sensor.new_binary_sensor(config[CONF_LIGHT]) cg.add(var.set_light(sens)) diff --git a/esphome/components/xiaomi_mue4094rt/binary_sensor.py b/esphome/components/xiaomi_mue4094rt/binary_sensor.py index 353e9aa3a6..5d19263c9c 100644 --- a/esphome/components/xiaomi_mue4094rt/binary_sensor.py +++ b/esphome/components/xiaomi_mue4094rt/binary_sensor.py @@ -33,11 +33,11 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield esp32_ble_tracker.register_ble_device(var, config) - yield binary_sensor.register_binary_sensor(var, config) + await cg.register_component(var, config) + await esp32_ble_tracker.register_ble_device(var, config) + await binary_sensor.register_binary_sensor(var, config) cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex)) cg.add(var.set_time(config[CONF_TIMEOUT])) diff --git a/esphome/components/xiaomi_wx08zm/binary_sensor.py b/esphome/components/xiaomi_wx08zm/binary_sensor.py index c13085b5eb..d538d4fbd7 100644 --- a/esphome/components/xiaomi_wx08zm/binary_sensor.py +++ b/esphome/components/xiaomi_wx08zm/binary_sensor.py @@ -43,17 +43,17 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield esp32_ble_tracker.register_ble_device(var, config) - yield binary_sensor.register_binary_sensor(var, config) + await cg.register_component(var, config) + await esp32_ble_tracker.register_ble_device(var, config) + await binary_sensor.register_binary_sensor(var, config) cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex)) if CONF_TABLET in config: - sens = yield sensor.new_sensor(config[CONF_TABLET]) + sens = await sensor.new_sensor(config[CONF_TABLET]) cg.add(var.set_tablet(sens)) 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)) diff --git a/esphome/components/xpt2046/__init__.py b/esphome/components/xpt2046/__init__.py index fc440bcbba..3de89a6425 100644 --- a/esphome/components/xpt2046/__init__.py +++ b/esphome/components/xpt2046/__init__.py @@ -97,10 +97,10 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield spi.register_spi_device(var, config) + await cg.register_component(var, config) + await spi.register_spi_device(var, config) cg.add(var.set_threshold(config[CONF_THRESHOLD])) cg.add(var.set_report_interval(config[CONF_REPORT_INTERVAL])) @@ -118,11 +118,11 @@ def to_code(config): cg.add(var.set_swap_x_y(config[CONF_SWAP_X_Y])) if CONF_IRQ_PIN in config: - pin = yield cg.gpio_pin_expression(config[CONF_IRQ_PIN]) + pin = await cg.gpio_pin_expression(config[CONF_IRQ_PIN]) cg.add(var.set_irq_pin(pin)) for conf in config.get(CONF_ON_STATE, []): - yield automation.build_automation( + await automation.build_automation( var.get_on_state_trigger(), [(cg.int_, "x"), (cg.int_, "y"), (cg.bool_, "touched")], conf, diff --git a/esphome/components/xpt2046/binary_sensor.py b/esphome/components/xpt2046/binary_sensor.py index 457b706caf..6959d6c342 100644 --- a/esphome/components/xpt2046/binary_sensor.py +++ b/esphome/components/xpt2046/binary_sensor.py @@ -41,10 +41,10 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield binary_sensor.register_binary_sensor(var, config) - hub = yield cg.get_variable(config[CONF_XPT2046_ID]) + await binary_sensor.register_binary_sensor(var, config) + hub = await cg.get_variable(config[CONF_XPT2046_ID]) cg.add( var.set_area( config[CONF_X_MIN], diff --git a/esphome/components/yashima/climate.py b/esphome/components/yashima/climate.py index 2965d4cdb8..8cafd468ac 100644 --- a/esphome/components/yashima/climate.py +++ b/esphome/components/yashima/climate.py @@ -24,16 +24,16 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): +async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield climate.register_climate(var, config) + await cg.register_component(var, config) + await climate.register_climate(var, config) cg.add(var.set_supports_cool(config[CONF_SUPPORTS_COOL])) cg.add(var.set_supports_heat(config[CONF_SUPPORTS_HEAT])) if CONF_SENSOR in config: - sens = yield cg.get_variable(config[CONF_SENSOR]) + sens = await cg.get_variable(config[CONF_SENSOR]) cg.add(var.set_sensor(sens)) - transmitter = yield cg.get_variable(config[CONF_TRANSMITTER_ID]) + transmitter = await cg.get_variable(config[CONF_TRANSMITTER_ID]) cg.add(var.set_transmitter(transmitter)) diff --git a/esphome/components/zyaura/sensor.py b/esphome/components/zyaura/sensor.py index e9035ce106..ebd43af630 100644 --- a/esphome/components/zyaura/sensor.py +++ b/esphome/components/zyaura/sensor.py @@ -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))