mirror of
https://github.com/esphome/esphome.git
synced 2025-09-11 07:42:26 +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
@@ -7,14 +7,18 @@ from esphome.core import coroutine, coroutine_with_priority
|
||||
|
||||
IS_PLATFORM_COMPONENT = True
|
||||
|
||||
display_ns = cg.esphome_ns.namespace('display')
|
||||
DisplayBuffer = display_ns.class_('DisplayBuffer')
|
||||
DisplayPage = display_ns.class_('DisplayPage')
|
||||
DisplayPagePtr = DisplayPage.operator('ptr')
|
||||
DisplayBufferRef = DisplayBuffer.operator('ref')
|
||||
DisplayPageShowAction = display_ns.class_('DisplayPageShowAction', automation.Action)
|
||||
DisplayPageShowNextAction = display_ns.class_('DisplayPageShowNextAction', automation.Action)
|
||||
DisplayPageShowPrevAction = display_ns.class_('DisplayPageShowPrevAction', automation.Action)
|
||||
display_ns = cg.esphome_ns.namespace("display")
|
||||
DisplayBuffer = display_ns.class_("DisplayBuffer")
|
||||
DisplayPage = display_ns.class_("DisplayPage")
|
||||
DisplayPagePtr = DisplayPage.operator("ptr")
|
||||
DisplayBufferRef = DisplayBuffer.operator("ref")
|
||||
DisplayPageShowAction = display_ns.class_("DisplayPageShowAction", automation.Action)
|
||||
DisplayPageShowNextAction = display_ns.class_(
|
||||
"DisplayPageShowNextAction", automation.Action
|
||||
)
|
||||
DisplayPageShowPrevAction = display_ns.class_(
|
||||
"DisplayPageShowPrevAction", automation.Action
|
||||
)
|
||||
|
||||
DISPLAY_ROTATIONS = {
|
||||
0: display_ns.DISPLAY_ROTATION_0_DEGREES,
|
||||
@@ -31,17 +35,26 @@ def validate_rotation(value):
|
||||
return cv.enum(DISPLAY_ROTATIONS, int=True)(value)
|
||||
|
||||
|
||||
BASIC_DISPLAY_SCHEMA = cv.Schema({
|
||||
cv.Optional(CONF_LAMBDA): cv.lambda_,
|
||||
})
|
||||
BASIC_DISPLAY_SCHEMA = cv.Schema(
|
||||
{
|
||||
cv.Optional(CONF_LAMBDA): cv.lambda_,
|
||||
}
|
||||
)
|
||||
|
||||
FULL_DISPLAY_SCHEMA = BASIC_DISPLAY_SCHEMA.extend({
|
||||
cv.Optional(CONF_ROTATION): validate_rotation,
|
||||
cv.Optional(CONF_PAGES): cv.All(cv.ensure_list({
|
||||
cv.GenerateID(): cv.declare_id(DisplayPage),
|
||||
cv.Required(CONF_LAMBDA): cv.lambda_,
|
||||
}), cv.Length(min=1)),
|
||||
})
|
||||
FULL_DISPLAY_SCHEMA = BASIC_DISPLAY_SCHEMA.extend(
|
||||
{
|
||||
cv.Optional(CONF_ROTATION): validate_rotation,
|
||||
cv.Optional(CONF_PAGES): cv.All(
|
||||
cv.ensure_list(
|
||||
{
|
||||
cv.GenerateID(): cv.declare_id(DisplayPage),
|
||||
cv.Required(CONF_LAMBDA): cv.lambda_,
|
||||
}
|
||||
),
|
||||
cv.Length(min=1),
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@coroutine
|
||||
@@ -51,8 +64,9 @@ def setup_display_core_(var, config):
|
||||
if CONF_PAGES in config:
|
||||
pages = []
|
||||
for conf in config[CONF_PAGES]:
|
||||
lambda_ = yield cg.process_lambda(conf[CONF_LAMBDA], [(DisplayBufferRef, 'it')],
|
||||
return_type=cg.void)
|
||||
lambda_ = yield cg.process_lambda(
|
||||
conf[CONF_LAMBDA], [(DisplayBufferRef, "it")], return_type=cg.void
|
||||
)
|
||||
page = cg.new_Pvariable(conf[CONF_ID], lambda_)
|
||||
pages.append(page)
|
||||
cg.add(var.set_pages(pages))
|
||||
@@ -63,9 +77,15 @@ def register_display(var, config):
|
||||
yield setup_display_core_(var, config)
|
||||
|
||||
|
||||
@automation.register_action('display.page.show', DisplayPageShowAction, maybe_simple_id({
|
||||
cv.Required(CONF_ID): cv.templatable(cv.use_id(DisplayPage)),
|
||||
}))
|
||||
@automation.register_action(
|
||||
"display.page.show",
|
||||
DisplayPageShowAction,
|
||||
maybe_simple_id(
|
||||
{
|
||||
cv.Required(CONF_ID): cv.templatable(cv.use_id(DisplayPage)),
|
||||
}
|
||||
),
|
||||
)
|
||||
def display_page_show_to_code(config, action_id, template_arg, args):
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
if isinstance(config[CONF_ID], core.Lambda):
|
||||
@@ -77,18 +97,29 @@ def display_page_show_to_code(config, action_id, template_arg, args):
|
||||
yield var
|
||||
|
||||
|
||||
@automation.register_action('display.page.show_next', DisplayPageShowNextAction, maybe_simple_id({
|
||||
cv.Required(CONF_ID): cv.templatable(cv.use_id(DisplayBuffer)),
|
||||
}))
|
||||
@automation.register_action(
|
||||
"display.page.show_next",
|
||||
DisplayPageShowNextAction,
|
||||
maybe_simple_id(
|
||||
{
|
||||
cv.Required(CONF_ID): cv.templatable(cv.use_id(DisplayBuffer)),
|
||||
}
|
||||
),
|
||||
)
|
||||
def display_page_show_next_to_code(config, action_id, template_arg, args):
|
||||
paren = yield cg.get_variable(config[CONF_ID])
|
||||
yield cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
@automation.register_action('display.page.show_previous', DisplayPageShowPrevAction,
|
||||
maybe_simple_id({
|
||||
cv.Required(CONF_ID): cv.templatable(cv.use_id(DisplayBuffer)),
|
||||
}))
|
||||
@automation.register_action(
|
||||
"display.page.show_previous",
|
||||
DisplayPageShowPrevAction,
|
||||
maybe_simple_id(
|
||||
{
|
||||
cv.Required(CONF_ID): cv.templatable(cv.use_id(DisplayBuffer)),
|
||||
}
|
||||
),
|
||||
)
|
||||
def display_page_show_previous_to_code(config, action_id, template_arg, args):
|
||||
paren = yield cg.get_variable(config[CONF_ID])
|
||||
yield cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
Reference in New Issue
Block a user