Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
31 lines
802 B
Python
31 lines
802 B
Python
import esphome.codegen as cg
|
|
import esphome.config_validation as cv
|
|
from esphome.components import button
|
|
from esphome.const import (
|
|
CONF_ID,
|
|
DEVICE_CLASS_RESTART,
|
|
ENTITY_CATEGORY_CONFIG,
|
|
ICON_RESTART_ALERT,
|
|
)
|
|
from .. import factory_reset_ns
|
|
|
|
FactoryResetButton = factory_reset_ns.class_(
|
|
"FactoryResetButton", button.Button, cg.Component
|
|
)
|
|
|
|
CONFIG_SCHEMA = (
|
|
button.button_schema(
|
|
device_class=DEVICE_CLASS_RESTART,
|
|
entity_category=ENTITY_CATEGORY_CONFIG,
|
|
icon=ICON_RESTART_ALERT,
|
|
)
|
|
.extend({cv.GenerateID(): cv.declare_id(FactoryResetButton)})
|
|
.extend(cv.COMPONENT_SCHEMA)
|
|
)
|
|
|
|
|
|
async def to_code(config):
|
|
var = cg.new_Pvariable(config[CONF_ID])
|
|
await cg.register_component(var, config)
|
|
await button.register_button(var, config)
|