-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Event entity support #6451
Event entity support #6451
Conversation
Hey there @OttoWinter, mind taking a look at this pull request as it has been labeled with an integration ( |
Hey there @nohat, CODEOWNERS = ["@nohat"] And run (message by NeedsCodeownersLabel) |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #6451 +/- ##
==========================================
- Coverage 53.70% 53.45% -0.26%
==========================================
Files 50 50
Lines 9408 9543 +135
Branches 1654 1685 +31
==========================================
+ Hits 5053 5101 +48
- Misses 4056 4131 +75
- Partials 299 311 +12 ☔ View full report in Codecov by Sentry. |
Hey there @jesserockz, mind taking a look at this pull request as it has been labeled with an integration ( |
Hey there @esphome/core, mind taking a look at this pull request as it has been labeled with an integration ( |
Hey there @Azimath, mind taking a look at this pull request as it has been labeled with an integration ( |
This has to be the most detailed PR description I have ever seen. Very nice. I have rebased your changes on top of the latest |
Move event_types list to template event
For future reference, if you want to alphabetise a file, please do it in its own PR. =) |
@jesserockz, |
What does this implement/fix?
Event entities were introduced in Home Assistant 2023.8:
This PR introduces support in ESPHome for Home Assistant "Event Entities" as a new component. In addition to an implementation of event entities in the template platform for integration into config YAMLs, it adds support for exposing event entities and events in the API, via MQTT, and in the web server.
Besides this PR, there are also necessary changes to aioesphomeapi as well as the esphome home-assistant/core:
Types of changes
Related issue or feature (if applicable):
Pull request in esphome-docs with documentation:
Test Environment
Example entry for
config.yaml
:Checklist:
tests/
folder).If user exposed functionality or configuration variables are added/changed:
Config YAML
platform
: Specifies the platform type, in this PR, only template events are supported. Future improvements may provide direct support of e.g. GPIO or Tuya MCU events without an underlying binary_sensor component to trigger the events.name
: A friendly name for the event entity, appearing in Home Assistant.id
: A unique identifier for this event entity within ESPHome.event_types
(Mandatory): A list of the event types this entity can emit. Each type is a distinct string identifier, facilitating specific event differentiation in Home Assistant.on_event
: Defines automation actions to execute when the event is fired. Conditions can be used to perform actions based on theevent_type
.event.fire
ActionThis action is used in automations to fire an event.
Example use in a button:
Limitations
Although the Home Assistant documentations allows it, this implementation does not support sending any attributes with events, only the mandatory "event_type" string.
Summary of changes by file
esphome/components/event/__init__.py
:esphome/components/event/event.{h,cpp}
:fire_event()
,has_event_type()
,set_event_types()
,get_event_types()
, andadd_on_event_fired_callback()
methods.esphome/components/event/automation.h
:event.fire
actionon_event
triggeresphome/components/template/event/__init__.py
,esphome/components/template/event/template_event.h
:esphome/components/api/api.proto
:esphome/components/api/api_connection.{h,cpp}
,esphome/components/api/api_pb2_service.{h,cpp}
,esphome/components/api/subscribe_state.h
,esphome/components/api/api_server.cpp
,esphome/components/api/list_entities.{h,cpp}
:esphome/components/mqtt/__init__.py
,esphome/components/mqtt/mqtt_event.h
,esphome/components/mqtt/mqtt_event.{h,cpp}
:esphome/components/mqtt/mqtt_const.h
"event_type"
and"event_types"
.esphome/components/web_server/web_server.cpp
,esphome/components/web_server/list_entities.{h,cpp}
:"state"
events when events fire.esphome/core/application.h
:esphome/const.py
:event_type
,event_types
,on_event
button
anddoorbell
esphome/core/controller.{h,cpp}
:esphome/core/component_iterator.{h,cpp}