mirror of
https://github.com/esphome/esphome.git
synced 2025-09-15 01:32:19 +01:00
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:
@@ -3,7 +3,6 @@ import esphome.config_validation as cv
|
||||
from esphome import automation, pins
|
||||
from esphome.components import i2c
|
||||
from esphome.const import CONF_ON_TAG, CONF_TRIGGER_ID, CONF_RESET_PIN
|
||||
from esphome.core import coroutine
|
||||
|
||||
CODEOWNERS = ["@glmnet"]
|
||||
AUTO_LOAD = ["binary_sensor"]
|
||||
@@ -29,15 +28,14 @@ RC522_SCHEMA = cv.Schema(
|
||||
).extend(cv.polling_component_schema("1s"))
|
||||
|
||||
|
||||
@coroutine
|
||||
def setup_rc522(var, config):
|
||||
yield cg.register_component(var, config)
|
||||
async def setup_rc522(var, config):
|
||||
await cg.register_component(var, config)
|
||||
|
||||
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))
|
||||
|
||||
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.std_string, "x")], conf)
|
||||
await automation.build_automation(trigger, [(cg.std_string, "x")], conf)
|
||||
|
Reference in New Issue
Block a user