mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	Fix template button after abstract press_action (#3250)
This commit is contained in:
		| @@ -1,10 +1,13 @@ | |||||||
| import esphome.config_validation as cv | import esphome.config_validation as cv | ||||||
| from esphome.components import button | from esphome.components import button | ||||||
|  |  | ||||||
|  | from .. import template_ns | ||||||
|  |  | ||||||
|  | TemplateButton = template_ns.class_("TemplateButton", button.Button) | ||||||
|  |  | ||||||
| CONFIG_SCHEMA = button.BUTTON_SCHEMA.extend( | CONFIG_SCHEMA = button.BUTTON_SCHEMA.extend( | ||||||
|     { |     { | ||||||
|         cv.GenerateID(): cv.declare_id(button.Button), |         cv.GenerateID(): cv.declare_id(TemplateButton), | ||||||
|     } |     } | ||||||
| ).extend(cv.COMPONENT_SCHEMA) | ).extend(cv.COMPONENT_SCHEMA) | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										15
									
								
								esphome/components/template/button/template_button.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								esphome/components/template/button/template_button.h
									
									
									
									
									
										Normal 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 | ||||||
		Reference in New Issue
	
	Block a user