Convert components to async-def syntax (#1823)

* Convert components to async-def syntax

* Remove stray @coroutine

* Manual part

* Convert complexer components code to async-def

* Manual cleanup

* More manual cleanup
This commit is contained in:
Otto Winter
2021-05-24 21:45:31 +02:00
committed by GitHub
parent 93d9d4b50a
commit a33bb32874
60 changed files with 592 additions and 633 deletions
+5 -7
View File
@@ -9,7 +9,6 @@ from esphome.const import (
CONF_MODEL,
CONF_RESET_PIN,
)
from esphome.core import coroutine
CODEOWNERS = ["@kbx81"]
@@ -37,21 +36,20 @@ SSD1325_SCHEMA = display.FULL_DISPLAY_SCHEMA.extend(
).extend(cv.polling_component_schema("1s"))
@coroutine
def setup_ssd1325(var, config):
yield cg.register_component(var, config)
yield display.register_display(var, config)
async def setup_ssd1325(var, config):
await cg.register_component(var, config)
await display.register_display(var, config)
cg.add(var.set_model(config[CONF_MODEL]))
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_BRIGHTNESS in config:
cg.add(var.init_brightness(config[CONF_BRIGHTNESS]))
if CONF_EXTERNAL_VCC in config:
cg.add(var.set_external_vcc(config[CONF_EXTERNAL_VCC]))
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_))