mirror of
https://github.com/esphome/esphome.git
synced 2025-10-30 14:43:51 +00:00
Event entity support (#6451)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
24
esphome/components/template/event/__init__.py
Normal file
24
esphome/components/template/event/__init__.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import esphome.config_validation as cv
|
||||
|
||||
from esphome.components import event
|
||||
|
||||
import esphome.codegen as cg
|
||||
|
||||
from esphome.const import CONF_EVENT_TYPES
|
||||
|
||||
from .. import template_ns
|
||||
|
||||
CODEOWNERS = ["@nohat"]
|
||||
|
||||
TemplateEvent = template_ns.class_("TemplateEvent", event.Event, cg.Component)
|
||||
|
||||
CONFIG_SCHEMA = event.event_schema(TemplateEvent).extend(
|
||||
{
|
||||
cv.Required(CONF_EVENT_TYPES): cv.ensure_list(cv.string_strict),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
async def to_code(config):
|
||||
var = await event.new_event(config, event_types=config[CONF_EVENT_TYPES])
|
||||
await cg.register_component(var, config)
|
||||
12
esphome/components/template/event/template_event.h
Normal file
12
esphome/components/template/event/template_event.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/event/event.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
|
||||
class TemplateEvent : public Component, public event::Event {};
|
||||
|
||||
} // namespace template_
|
||||
} // namespace esphome
|
||||
Reference in New Issue
Block a user