-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Add event platform to templates #145408
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
base: dev
Are you sure you want to change the base?
Add event platform to templates #145408
Conversation
Hey there @PhracturedBlue, @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
self.async_set_context(self.coordinator.data["context"]) | ||
self.async_write_ha_state() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this mean we always set the context before writing state?
I never worked with context so no clue how that works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, for trigger based template entities, we update the context from whatever triggered. Kinda like automations. There was a "bug fix" awhile ago that added this because template entities didn't properly reflect the context according to some people.
"device_id": "[%key:common::config_flow::data::device%]", | ||
"name": "[%key:common::config_flow::data::name%]", | ||
"device_class": "[%key:component::template::config::step::sensor::data::device_class%]", | ||
"event_type": "Event type template", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current event type? Last fired event type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure, it's technically the last event type. But it will be the event that's current. I'm open to suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NoRi2909, we're looking for a string that represents the current event, but this would be a template that compiles to the current event
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the Events section of the Frontend Developer tools the headline is "Fire an event on the event bus".
So "Fired event type" might fit here.
BTW: In German we currently have this translated as "Ein Ereignis im Ereignisbus auslösen" which would be "trigger an event" in English as an alternative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, for such a button that "event_type" attribute is the (last) type of event that this entity has fired, right?
Thus "Last fired event type" sounds OK to me, but you are much more familiar with the overall concept than me, so I'm probably not of much help here …
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
7648ca7
to
dfb54ae
Compare
Breaking change
Proposed change
Add Event Entities to template integration.
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.To help with the load of incoming pull requests: