Simplify button_schema function (#4468)

This commit is contained in:
Jesse Hills
2023-02-20 10:13:37 +13:00
committed by GitHub
parent add40c7652
commit 04c12823b5
4 changed files with 26 additions and 38 deletions
+10 -7
View File
@@ -6,13 +6,16 @@ from .. import output_ns
OutputButton = output_ns.class_("OutputButton", button.Button, cg.Component)
CONFIG_SCHEMA = button.BUTTON_SCHEMA.extend(
{
cv.GenerateID(): cv.declare_id(OutputButton),
cv.Required(CONF_OUTPUT): cv.use_id(output.BinaryOutput),
cv.Required(CONF_DURATION): cv.positive_time_period_milliseconds,
}
).extend(cv.COMPONENT_SCHEMA)
CONFIG_SCHEMA = (
button.button_schema(OutputButton)
.extend(
{
cv.Required(CONF_OUTPUT): cv.use_id(output.BinaryOutput),
cv.Required(CONF_DURATION): cv.positive_time_period_milliseconds,
}
)
.extend(cv.COMPONENT_SCHEMA)
)
async def to_code(config):