mirror of
https://github.com/esphome/esphome.git
synced 2025-09-20 04:02:21 +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:
@@ -39,9 +39,9 @@ async def to_code(config):
|
||||
}
|
||||
),
|
||||
)
|
||||
def binary_sensor_template_publish_to_code(config, action_id, template_arg, args):
|
||||
paren = yield cg.get_variable(config[CONF_ID])
|
||||
async def binary_sensor_template_publish_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
template_ = yield cg.templatable(config[CONF_STATE], args, bool)
|
||||
template_ = await cg.templatable(config[CONF_STATE], args, bool)
|
||||
cg.add(var.set_state(template_))
|
||||
yield var
|
||||
return var
|
||||
|
@@ -111,21 +111,21 @@ async def to_code(config):
|
||||
}
|
||||
),
|
||||
)
|
||||
def cover_template_publish_to_code(config, action_id, template_arg, args):
|
||||
paren = yield cg.get_variable(config[CONF_ID])
|
||||
async def cover_template_publish_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
if CONF_STATE in config:
|
||||
template_ = yield cg.templatable(config[CONF_STATE], args, float)
|
||||
template_ = await cg.templatable(config[CONF_STATE], args, float)
|
||||
cg.add(var.set_position(template_))
|
||||
if CONF_POSITION in config:
|
||||
template_ = yield cg.templatable(config[CONF_POSITION], args, float)
|
||||
template_ = await cg.templatable(config[CONF_POSITION], args, float)
|
||||
cg.add(var.set_position(template_))
|
||||
if CONF_TILT in config:
|
||||
template_ = yield cg.templatable(config[CONF_TILT], args, float)
|
||||
template_ = await cg.templatable(config[CONF_TILT], args, float)
|
||||
cg.add(var.set_tilt(template_))
|
||||
if CONF_CURRENT_OPERATION in config:
|
||||
template_ = yield cg.templatable(
|
||||
template_ = await cg.templatable(
|
||||
config[CONF_CURRENT_OPERATION], args, cover.CoverOperation
|
||||
)
|
||||
cg.add(var.set_current_operation(template_))
|
||||
yield var
|
||||
return var
|
||||
|
@@ -50,9 +50,9 @@ async def to_code(config):
|
||||
}
|
||||
),
|
||||
)
|
||||
def sensor_template_publish_to_code(config, action_id, template_arg, args):
|
||||
paren = yield cg.get_variable(config[CONF_ID])
|
||||
async def sensor_template_publish_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
template_ = yield cg.templatable(config[CONF_STATE], args, float)
|
||||
template_ = await cg.templatable(config[CONF_STATE], args, float)
|
||||
cg.add(var.set_state(template_))
|
||||
yield var
|
||||
return var
|
||||
|
@@ -62,9 +62,9 @@ async def to_code(config):
|
||||
}
|
||||
),
|
||||
)
|
||||
def switch_template_publish_to_code(config, action_id, template_arg, args):
|
||||
paren = yield cg.get_variable(config[CONF_ID])
|
||||
async def switch_template_publish_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
template_ = yield cg.templatable(config[CONF_STATE], args, bool)
|
||||
template_ = await cg.templatable(config[CONF_STATE], args, bool)
|
||||
cg.add(var.set_state(template_))
|
||||
yield var
|
||||
return var
|
||||
|
@@ -40,9 +40,9 @@ async def to_code(config):
|
||||
}
|
||||
),
|
||||
)
|
||||
def text_sensor_template_publish_to_code(config, action_id, template_arg, args):
|
||||
paren = yield cg.get_variable(config[CONF_ID])
|
||||
async def text_sensor_template_publish_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
template_ = yield cg.templatable(config[CONF_STATE], args, cg.std_string)
|
||||
template_ = await cg.templatable(config[CONF_STATE], args, cg.std_string)
|
||||
cg.add(var.set_state(template_))
|
||||
yield var
|
||||
return var
|
||||
|
Reference in New Issue
Block a user