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
+18 -18
View File
@@ -61,19 +61,19 @@ BINARY_OUTPUT_ACTION_SCHEMA = maybe_simple_id(
@automation.register_action("tm1651.turn_on", TurnOnAction, BINARY_OUTPUT_ACTION_SCHEMA)
def output_turn_on_to_code(config, action_id, template_arg, args):
async def output_turn_on_to_code(config, action_id, template_arg, args):
var = cg.new_Pvariable(action_id, template_arg)
yield cg.register_parented(var, config[CONF_ID])
yield var
await cg.register_parented(var, config[CONF_ID])
return var
@automation.register_action(
"tm1651.turn_off", TurnOffAction, BINARY_OUTPUT_ACTION_SCHEMA
)
def output_turn_off_to_code(config, action_id, template_arg, args):
async def output_turn_off_to_code(config, action_id, template_arg, args):
var = cg.new_Pvariable(action_id, template_arg)
yield cg.register_parented(var, config[CONF_ID])
yield var
await cg.register_parented(var, config[CONF_ID])
return var
@automation.register_action(
@@ -87,12 +87,12 @@ def output_turn_off_to_code(config, action_id, template_arg, args):
key=CONF_LEVEL_PERCENT,
),
)
def tm1651_set_level_percent_to_code(config, action_id, template_arg, args):
async def tm1651_set_level_percent_to_code(config, action_id, template_arg, args):
var = cg.new_Pvariable(action_id, template_arg)
yield cg.register_parented(var, config[CONF_ID])
template_ = yield cg.templatable(config[CONF_LEVEL_PERCENT], args, cg.uint8)
await cg.register_parented(var, config[CONF_ID])
template_ = await cg.templatable(config[CONF_LEVEL_PERCENT], args, cg.uint8)
cg.add(var.set_level_percent(template_))
yield var
return var
@automation.register_action(
@@ -106,12 +106,12 @@ def tm1651_set_level_percent_to_code(config, action_id, template_arg, args):
key=CONF_LEVEL,
),
)
def tm1651_set_level_to_code(config, action_id, template_arg, args):
async def tm1651_set_level_to_code(config, action_id, template_arg, args):
var = cg.new_Pvariable(action_id, template_arg)
yield cg.register_parented(var, config[CONF_ID])
template_ = yield cg.templatable(config[CONF_LEVEL], args, cg.uint8)
await cg.register_parented(var, config[CONF_ID])
template_ = await cg.templatable(config[CONF_LEVEL], args, cg.uint8)
cg.add(var.set_level(template_))
yield var
return var
@automation.register_action(
@@ -125,9 +125,9 @@ def tm1651_set_level_to_code(config, action_id, template_arg, args):
key=CONF_BRIGHTNESS,
),
)
def tm1651_set_brightness_to_code(config, action_id, template_arg, args):
async def tm1651_set_brightness_to_code(config, action_id, template_arg, args):
var = cg.new_Pvariable(action_id, template_arg)
yield cg.register_parented(var, config[CONF_ID])
template_ = yield cg.templatable(config[CONF_BRIGHTNESS], args, cg.uint8)
await cg.register_parented(var, config[CONF_ID])
template_ = await cg.templatable(config[CONF_BRIGHTNESS], args, cg.uint8)
cg.add(var.set_brightness(template_))
yield var
return var