Fix template button after abstract press_action (#3250)

This commit is contained in:
Jesse Hills 2022-02-22 13:47:16 +13:00 committed by GitHub
parent a5b4105971
commit b55e9329d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -1,10 +1,13 @@
import esphome.config_validation as cv
from esphome.components import button
from .. import template_ns
TemplateButton = template_ns.class_("TemplateButton", button.Button)
CONFIG_SCHEMA = button.BUTTON_SCHEMA.extend(
{
cv.GenerateID(): cv.declare_id(button.Button),
cv.GenerateID(): cv.declare_id(TemplateButton),
}
).extend(cv.COMPONENT_SCHEMA)

View File

@ -0,0 +1,15 @@
#pragma once
#include "esphome/components/button/button.h"
namespace esphome {
namespace template_ {
class TemplateButton : public button::Button {
public:
// Implements the abstract `press_action` but the `on_press` trigger already handles the press.
void press_action() override{};
};
} // namespace template_
} // namespace esphome