1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-29 22:24:26 +00: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:
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

View File

@@ -151,13 +151,13 @@ async def to_code(config):
}
),
)
def sun_above_horizon_to_code(config, condition_id, template_arg, args):
async def sun_above_horizon_to_code(config, condition_id, template_arg, args):
var = cg.new_Pvariable(condition_id, template_arg)
yield cg.register_parented(var, config[CONF_ID])
templ = yield cg.templatable(config[CONF_ELEVATION], args, cg.double)
await cg.register_parented(var, config[CONF_ID])
templ = await cg.templatable(config[CONF_ELEVATION], args, cg.double)
cg.add(var.set_elevation(templ))
cg.add(var.set_above(True))
yield var
return var
@automation.register_condition(
@@ -172,10 +172,10 @@ def sun_above_horizon_to_code(config, condition_id, template_arg, args):
}
),
)
def sun_below_horizon_to_code(config, condition_id, template_arg, args):
async def sun_below_horizon_to_code(config, condition_id, template_arg, args):
var = cg.new_Pvariable(condition_id, template_arg)
yield cg.register_parented(var, config[CONF_ID])
templ = yield cg.templatable(config[CONF_ELEVATION], args, cg.double)
await cg.register_parented(var, config[CONF_ID])
templ = await cg.templatable(config[CONF_ELEVATION], args, cg.double)
cg.add(var.set_elevation(templ))
cg.add(var.set_above(False))
yield var
return var