mirror of
https://github.com/esphome/esphome.git
synced 2025-09-29 16:42:19 +01:00
add-black (#1593)
* Add black Update pre commit Update pre commit add empty line * Format with black
This commit is contained in:
committed by
GitHub
parent
2b60b0f1fa
commit
69879920eb
@@ -6,13 +6,16 @@ from esphome.components.text_sensor import TextSensorPublishAction
|
||||
from esphome.const import CONF_ID, CONF_LAMBDA, CONF_STATE
|
||||
from .. import template_ns
|
||||
|
||||
TemplateTextSensor = template_ns.class_('TemplateTextSensor', text_sensor.TextSensor,
|
||||
cg.PollingComponent)
|
||||
TemplateTextSensor = template_ns.class_(
|
||||
"TemplateTextSensor", text_sensor.TextSensor, cg.PollingComponent
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA = text_sensor.TEXT_SENSOR_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_id(TemplateTextSensor),
|
||||
cv.Optional(CONF_LAMBDA): cv.returning_lambda,
|
||||
}).extend(cv.polling_component_schema('60s'))
|
||||
CONFIG_SCHEMA = text_sensor.TEXT_SENSOR_SCHEMA.extend(
|
||||
{
|
||||
cv.GenerateID(): cv.declare_id(TemplateTextSensor),
|
||||
cv.Optional(CONF_LAMBDA): cv.returning_lambda,
|
||||
}
|
||||
).extend(cv.polling_component_schema("60s"))
|
||||
|
||||
|
||||
def to_code(config):
|
||||
@@ -21,15 +24,22 @@ def to_code(config):
|
||||
yield text_sensor.register_text_sensor(var, config)
|
||||
|
||||
if CONF_LAMBDA in config:
|
||||
template_ = yield cg.process_lambda(config[CONF_LAMBDA], [],
|
||||
return_type=cg.optional.template(cg.std_string))
|
||||
template_ = yield cg.process_lambda(
|
||||
config[CONF_LAMBDA], [], return_type=cg.optional.template(cg.std_string)
|
||||
)
|
||||
cg.add(var.set_template(template_))
|
||||
|
||||
|
||||
@automation.register_action('text_sensor.template.publish', TextSensorPublishAction, cv.Schema({
|
||||
cv.Required(CONF_ID): cv.use_id(text_sensor.TextSensor),
|
||||
cv.Required(CONF_STATE): cv.templatable(cv.string_strict),
|
||||
}))
|
||||
@automation.register_action(
|
||||
"text_sensor.template.publish",
|
||||
TextSensorPublishAction,
|
||||
cv.Schema(
|
||||
{
|
||||
cv.Required(CONF_ID): cv.use_id(text_sensor.TextSensor),
|
||||
cv.Required(CONF_STATE): cv.templatable(cv.string_strict),
|
||||
}
|
||||
),
|
||||
)
|
||||
def text_sensor_template_publish_to_code(config, action_id, template_arg, args):
|
||||
paren = yield cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
Reference in New Issue
Block a user