From b55e9329d98a2b63a12134108c2236db68129d62 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Tue, 22 Feb 2022 13:47:16 +1300 Subject: [PATCH] Fix template button after abstract press_action (#3250) --- esphome/components/template/button/__init__.py | 5 ++++- .../components/template/button/template_button.h | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 esphome/components/template/button/template_button.h diff --git a/esphome/components/template/button/__init__.py b/esphome/components/template/button/__init__.py index aa192d118e..a8bf595942 100644 --- a/esphome/components/template/button/__init__.py +++ b/esphome/components/template/button/__init__.py @@ -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) diff --git a/esphome/components/template/button/template_button.h b/esphome/components/template/button/template_button.h new file mode 100644 index 0000000000..68e976f64b --- /dev/null +++ b/esphome/components/template/button/template_button.h @@ -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