-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Add event entity to template integration #39144
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: next
Are you sure you want to change the base?
Conversation
It seems that this PR is targeted against an incorrect branch. Documentation updates which apply to our current stable release should target the |
❌ Deploy Preview for home-assistant-docs failed.
|
📝 WalkthroughWalkthroughThe documentation for the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant HomeAssistantConfig
participant TemplateIntegration
User ->> HomeAssistantConfig: Define template entity (sensor, binary_sensor, event, etc.)
HomeAssistantConfig ->> TemplateIntegration: Parse configuration
TemplateIntegration -->> HomeAssistantConfig: Validate entity type (sensor, binary_sensor, event, etc.)
TemplateIntegration ->> HomeAssistantConfig: Register entity with appropriate schema
HomeAssistantConfig -->> User: Entity available for use
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. Note ⚡️ Faster reviews with cachingCodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 30th. To opt out, configure Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 6
🔭 Outside diff range comments (1)
source/_integrations/template.markdown (1)
170-179
: 🛠️ Refactor suggestionInclude
event
in shared-fields description
The[all binary_sensor, event, sensor entities]
block now covers events, but the description only mentions sensors and binary sensors. Update it to reference events.- "[all binary_sensor, event, sensor entities]": - description: Fields that can be used above for both sensors and binary sensors. + "[all binary_sensor, event, sensor entities]": + description: Fields that can be used above for sensors, binary sensors, and events.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
📒 Files selected for processing (1)
source/_integrations/template.markdown
(11 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
source/_integrations/template.markdown
56-56: Link fragments should be valid
null
(MD051, link-fragments)
273-273: Emphasis style
Expected: underscore; Actual: asterisk
(MD049, emphasis-style)
273-273: Emphasis style
Expected: underscore; Actual: asterisk
(MD049, emphasis-style)
277-277: Emphasis style
Expected: underscore; Actual: asterisk
(MD049, emphasis-style)
277-277: Emphasis style
Expected: underscore; Actual: asterisk
(MD049, emphasis-style)
🪛 LanguageTool
source/_integrations/template.markdown
[misspelling] ~212-~212: This word is normally spelled with a hyphen.
Context: ... Note that the string comparison is not case sensitive; "TrUe"
and "yEs"
are allowed. ...
(EN_COMPOUNDS_CASE_SENSITIVE)
[style] ~269-~269: In American English, abbreviations like “etc.” require a period.
Context: ...nd (Open
/Closed
, Detected
/Clear
etc) depends on the sensor's device_class v...
(ETC_PERIOD)
[grammar] ~644-~644: Is an article like ‘a’ or ‘an’ missing?
Context: ... describes when the state of the sensor was last reset. Must render to a valid `dat...
(BE_NN)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Redirect rules - home-assistant-docs
- GitHub Check: Header rules - home-assistant-docs
- GitHub Check: Pages changed - home-assistant-docs
🔇 Additional comments (2)
source/_integrations/template.markdown (2)
9-9
: Addevent
to supported categories
The insertion ofEvent
into theha_category
list is correct and follows alphabetical order, matching the new entity support.
34-34
: Addevent
to supported platforms
Includingevent
in theha_platforms
list is accurate and maintains alphabetical ordering with the other platforms.
@@ -104,7 +106,7 @@ template: | |||
|
|||
{% endraw %} | |||
|
|||
### Trigger-based template binary sensors, images, lights, numbers, selects, sensors, switches, and weathers | |||
### Trigger-based template binary sensors, events, images, lights, numbers, selects, sensors, switches, and weathers |
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.
🛠️ Refactor suggestion
Fix pluralization of “weather”
In the trigger-based heading, change “weathers” to “weather entities”.
- ### Trigger-based template binary sensors, events, images, lights, numbers, selects, sensors, switches, and weathers
+ ### Trigger-based template binary sensors, events, images, lights, numbers, selects, sensors, switches, and weather entities
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
### Trigger-based template binary sensors, events, images, lights, numbers, selects, sensors, switches, and weathers | |
### Trigger-based template binary sensors, events, images, lights, numbers, selects, sensors, switches, and weather entities |
🤖 Prompt for AI Agents
In source/_integrations/template.markdown at line 109, update the heading by
replacing the plural word "weathers" with the correct phrase "weather entities"
to fix the pluralization issue.
|
||
_For old sensor/binary sensor configuration format, [see below](#legacy-binary-sensor-configuration-format)._ | ||
|
||
### State-based template alarm control panels, binary sensors, buttons, covers, fans, images, lights, numbers, selects, sensors, switches, vacuums, and weathers | ||
### State-based template alarm control panels, binary sensors, buttons, covers, events, fans, images, lights, numbers, selects, sensors, switches, vacuums, and weathers |
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.
🛠️ Refactor suggestion
Fix pluralization of “weather”
The heading’s list should end with “weather entities” instead of “weathers”.
- ### State-based template alarm control panels, binary sensors, buttons, covers, events, fans, images, lights, numbers, selects, sensors, switches, vacuums, and weathers
+ ### State-based template alarm control panels, binary sensors, buttons, covers, events, fans, images, lights, numbers, selects, sensors, switches, vacuums, and weather entities
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
### State-based template alarm control panels, binary sensors, buttons, covers, events, fans, images, lights, numbers, selects, sensors, switches, vacuums, and weathers | |
### State-based template alarm control panels, binary sensors, buttons, covers, events, fans, images, lights, numbers, selects, sensors, switches, vacuums, and weather entities |
🤖 Prompt for AI Agents
In source/_integrations/template.markdown at line 87, the heading ends with the
incorrect plural form "weathers". Change "weathers" to "weather entities" to fix
the pluralization and improve clarity.
@@ -78,11 +80,11 @@ If you need more specific features for your use case, the manual [YAML-configura | |||
|
|||
## YAML configuration | |||
|
|||
Entities (alarm control panels, binary sensors, buttons, covers, fans, images, lights, locks, numbers, selects, sensors, switches, vacuums, and weathers) are defined in your YAML configuration files under the `template:` key. You can define multiple configuration blocks as a list. Each block defines sensor/binary sensor/number/select entities and can contain optional update triggers. | |||
Entities (alarm control panels, binary sensors, buttons, covers, events, fans, images, lights, locks, numbers, selects, sensors, switches, vacuums, and weathers) are defined in your YAML configuration files under the `template:` key. You can define multiple configuration blocks as a list. Each block defines sensor/binary sensor/number/select entities and can contain optional update triggers. |
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.
🛠️ Refactor suggestion
Fix pluralization of “weather”
In the parenthetical list, replace “weathers” with “weather entities” for consistency and correctness.
- Entities (alarm control panels, binary sensors, buttons, covers, events, fans, images, lights, locks, numbers, selects, sensors, switches, vacuums, and weathers) are defined in your YAML configuration files under the `template:` key.
+ Entities (alarm control panels, binary sensors, buttons, covers, events, fans, images, lights, locks, numbers, selects, sensors, switches, vacuums, and weather entities) are defined in your YAML configuration files under the `template:` key.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
Entities (alarm control panels, binary sensors, buttons, covers, events, fans, images, lights, locks, numbers, selects, sensors, switches, vacuums, and weathers) are defined in your YAML configuration files under the `template:` key. You can define multiple configuration blocks as a list. Each block defines sensor/binary sensor/number/select entities and can contain optional update triggers. | |
Entities (alarm control panels, binary sensors, buttons, covers, events, fans, images, lights, locks, numbers, selects, sensors, switches, vacuums, and weather entities) are defined in your YAML configuration files under the `template:` key. You can define multiple configuration blocks as a list. Each block defines sensor/binary sensor/number/select entities and can contain optional update triggers. |
🤖 Prompt for AI Agents
In source/_integrations/template.markdown at line 83, the word "weathers" in the
parenthetical list is incorrectly pluralized. Replace "weathers" with "weather
entities" to maintain consistency and correctness in the list of entity types.
@@ -51,7 +53,7 @@ related: | |||
|
|||
The `template` integration allows creating entities which derive their values from other data. This is done by specifying [templates](/docs/configuration/templating/) for properties of an entity, like the name or the state. | |||
|
|||
Alarm control panels, binary sensors, buttons, covers, fans, images, lights, locks, numbers, selects, sensors, switches, vacuums, and weathers are covered on this page. They can be configured using [UI](#configuration) or [YAML](#yaml-configuration) file. | |||
Alarm control panels, binary sensors, buttons, covers, events, fans, images, lights, locks, numbers, selects, sensors, switches, vacuums, and weathers are covered on this page. They can be configured using [UI](#configuration) or [YAML](#yaml-configuration) file. |
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.
🛠️ Refactor suggestion
Fix pluralization of “weather”
“Weathers” is incorrect here—use “weather entities” (or simply “weather”) to match the integration name and other occurrences.
- Alarm control panels, binary sensors, buttons, covers, events, fans, images, lights, locks, numbers, selects, sensors, switches, vacuums, and weathers are covered on this page.
+ Alarm control panels, binary sensors, buttons, covers, events, fans, images, lights, locks, numbers, selects, sensors, switches, vacuums, and weather entities are covered on this page.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
Alarm control panels, binary sensors, buttons, covers, events, fans, images, lights, locks, numbers, selects, sensors, switches, vacuums, and weathers are covered on this page. They can be configured using [UI](#configuration) or [YAML](#yaml-configuration) file. | |
Alarm control panels, binary sensors, buttons, covers, events, fans, images, lights, locks, numbers, selects, sensors, switches, vacuums, and weather entities are covered on this page. They can be configured using [UI](#configuration) or [YAML](#yaml-configuration) file. |
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
56-56: Link fragments should be valid
null
(MD051, link-fragments)
🤖 Prompt for AI Agents
In source/_integrations/template.markdown at line 56, replace the incorrect
plural "weathers" with "weather entities" or just "weather" to correctly match
the integration name and maintain consistency with other mentions.
event: | ||
description: List of events | ||
required: true | ||
type: map | ||
keys: | ||
device_class: | ||
description: Sets the [class of the device](/integrations/event/), changing the device state and icon that is displayed on the frontend. | ||
required: false | ||
type: string | ||
event_type: | ||
description: Template for the event's last fired event type. | ||
required: true | ||
type: template | ||
event_types: | ||
description: Template for the event's available event types. | ||
required: true | ||
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.
Configuration schema: event
should be a list, not a map
The example usage defines event
as a list of mappings (- event:
followed by - name: …
), but the reference schema declares type: map
. This mismatch will confuse users.
Proposed fix:
-event:
- description: List of events
- required: true
- type: map
+event:
+ description: List of events
+ required: true
+ type: list
Ensure the keys:
under this section remain the same, as they apply to each list item.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
event: | |
description: List of events | |
required: true | |
type: map | |
keys: | |
device_class: | |
description: Sets the [class of the device](/integrations/event/), changing the device state and icon that is displayed on the frontend. | |
required: false | |
type: string | |
event_type: | |
description: Template for the event's last fired event type. | |
required: true | |
type: template | |
event_types: | |
description: Template for the event's available event types. | |
required: true | |
type: template | |
event: | |
description: List of events | |
required: true | |
type: list | |
keys: | |
device_class: | |
description: Sets the [class of the device](/integrations/event/), changing the device state and icon that is displayed on the frontend. | |
required: false | |
type: string | |
event_type: | |
description: Template for the event's last fired event type. | |
required: true | |
type: template | |
event_types: | |
description: Template for the event's available event types. | |
required: true | |
type: template |
🤖 Prompt for AI Agents
In source/_integrations/template.markdown around lines 343 to 359, the
configuration schema incorrectly defines `event` as a map, but it should be a
list to match the example usage. Change the `type` of `event` from `map` to
`list` while keeping the `keys:` section unchanged, so each item in the list has
the same structure as currently defined.
"[all alarm control panel, binary sensor, button, cover, event, fan, image, light, number, select, sensor, switch, vacuum, weather entities]": | ||
description: Fields that can be used above for sensors, binary sensors, buttons, numbers, and selects. | ||
required: false | ||
type: map | ||
keys: | ||
name: | ||
description: Defines a template to get the name of the entity. | ||
required: false | ||
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.
🛠️ Refactor suggestion
Align shared-fields description with entity list
The block [all alarm control panel, binary sensor, button, cover, event, fan, image, light, number, select, sensor, switch, vacuum, weather entities]
now includes many entity types, but the description only lists a subset. Update it to reflect all supported types.
- "[all alarm control panel, binary sensor, button, cover, event, fan, image, light, number, select, sensor, switch, vacuum, weather entities]":
- description: Fields that can be used above for sensors, binary sensors, buttons, numbers, and selects.
+ "[all alarm control panel, binary sensor, button, cover, event, fan, image, light, number, select, sensor, switch, vacuum, weather entities]":
+ description: Fields that can be used above for alarm control panels, binary sensors, buttons, covers, events, fans, images, lights, locks, numbers, selects, sensors, switches, vacuums, and weather entities.
Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In source/_integrations/template.markdown around lines 194 to 202, the
description for the shared fields under the key listing multiple entity types
does not include all the entity types mentioned. Update the description text to
list all the entity types exactly as they appear in the key, ensuring the
description fully reflects all supported entity types for clarity and accuracy.
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.
Actionable comments posted: 2
♻️ Duplicate comments (5)
source/_integrations/template.markdown (5)
56-56
: Fix pluralization of “weather”
The text uses “weathers,” which is incorrect. Change to “weather entities” for consistency.🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
56-56: Link fragments should be valid
null(MD051, link-fragments)
83-83
: Fix pluralization of “weather”
The list ends with “weathers”—update to “weather entities” to match docs style.
87-87
: Fix pluralization of “weather”
In this heading, replace “weathers” with “weather entities” for correctness.
194-202
: Align shared-fields description with entity list
The schema key lists many types (alarm control panel, binary sensor, button, cover, event, …), but the description only lists sensors, binary sensors, buttons, numbers, and selects.
343-359
: Defineevent
as a list, not a map
To match example usage and other entity types (e.g.,sensor
,binary_sensor
are lists),event
should betype: list
with per-item keys—currently it’stype: map
.
🧹 Nitpick comments (1)
source/_integrations/template.markdown (1)
1241-1243
: Hyphenate “Trigger-based event”
Headings should use “Trigger-based” (with a hyphen) for consistency and proper compound adjective styling.🧰 Tools
🪛 LanguageTool
[uncategorized] ~1241-~1241: This expression is usually spelled with a hyphen.
Context: ... seconds: 5 ``` {% endraw %} ### Trigger based event - Turn any custom event into an e...(BASED_HYPHEN)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
📒 Files selected for processing (1)
source/_integrations/template.markdown
(12 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
source/_integrations/template.markdown
56-56: Link fragments should be valid
null
(MD051, link-fragments)
273-273: Emphasis style
Expected: underscore; Actual: asterisk
(MD049, emphasis-style)
273-273: Emphasis style
Expected: underscore; Actual: asterisk
(MD049, emphasis-style)
277-277: Emphasis style
Expected: underscore; Actual: asterisk
(MD049, emphasis-style)
277-277: Emphasis style
Expected: underscore; Actual: asterisk
(MD049, emphasis-style)
🪛 LanguageTool
source/_integrations/template.markdown
[uncategorized] ~204-~204: Possible missing comma found.
Context: ...with the unique ID of the configuration block if available. This allows changing the ...
(AI_HYDRA_LEO_MISSING_COMMA)
[misspelling] ~212-~212: This word is normally spelled with a hyphen.
Context: ... Note that the string comparison is not case sensitive; "TrUe"
and "yEs"
are allowed. ...
(EN_COMPOUNDS_CASE_SENSITIVE)
[style] ~269-~269: In American English, abbreviations like “etc.” require a period.
Context: ...nd (Open
/Closed
, Detected
/Clear
etc) depends on the sensor's device_class v...
(ETC_PERIOD)
[grammar] ~644-~644: Is an article like ‘a’ or ‘an’ missing?
Context: ... describes when the state of the sensor was last reset. Must render to a valid `dat...
(BE_NN)
[uncategorized] ~1241-~1241: This expression is usually spelled with a hyphen.
Context: ... seconds: 5 ``` {% endraw %} ### Trigger based event - Turn any custom event into an e...
(BASED_HYPHEN)
🔇 Additional comments (2)
source/_integrations/template.markdown (2)
9-9
: AddEvent
to Home Assistant categories
IncludingEvent
in theha_category
list properly surfaces the new entity type in the integration overview.
34-34
: Addevent
to supported platforms
Addingevent
underha_platforms
ensures the documentation matches the integration’s implementation.
"[all binary_sensor, event, sensor entities]": | ||
description: Fields that can be used above for both sensors and binary sensors. | ||
required: false |
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.
Update shared-fields description to include events
The key applies to [all binary_sensor, event, sensor entities]
, but the description only mentions sensors and binary sensors. This will confuse users about event support.
Suggested diff:
- description: Fields that can be used above for both sensors and binary sensors.
+ description: Fields that can be used above for sensors, binary sensors, and events.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
"[all binary_sensor, event, sensor entities]": | |
description: Fields that can be used above for both sensors and binary sensors. | |
required: false | |
"[all binary_sensor, event, sensor entities]": | |
description: Fields that can be used above for sensors, binary sensors, and events. | |
required: false |
🤖 Prompt for AI Agents
In source/_integrations/template.markdown around lines 171 to 173, the
description for the key "[all binary_sensor, event, sensor entities]" only
mentions sensors and binary sensors, omitting events. Update the description to
explicitly include events so users understand that event entities are also
supported by this key.
template: | ||
- triggers: | ||
- trigger: event | ||
event_type: room_state | ||
event: | ||
name: Room State | ||
event_type: "{{ trigger.event.data.status }}" | ||
event_types: "{{ ['room_occupied', 'room_empty'] }}" | ||
``` |
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.
Fix YAML list syntax for event
definitions
The example under event:
omits the leading dash before each item, unlike other entity examples. This will prevent users from defining multiple events.
Proposed diff:
- event:
- name: Room State
- event_type: "{{ trigger.event.data.status }}"
- event_types: "{{ ['room_occupied', 'room_empty'] }}"
+ event:
+ - name: Room State
+ event_type: "{{ trigger.event.data.status }}"
+ event_types: "{{ ['room_occupied', 'room_empty'] }}"
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
template: | |
- triggers: | |
- trigger: event | |
event_type: room_state | |
event: | |
name: Room State | |
event_type: "{{ trigger.event.data.status }}" | |
event_types: "{{ ['room_occupied', 'room_empty'] }}" | |
``` | |
template: | |
- triggers: | |
- trigger: event | |
event_type: room_state | |
event: | |
- name: Room State | |
event_type: "{{ trigger.event.data.status }}" | |
event_types: "{{ ['room_occupied', 'room_empty'] }}" |
🤖 Prompt for AI Agents
In source/_integrations/template.markdown around lines 1246 to 1254, the YAML
list under the event key is missing leading dashes before each item, which
breaks the list syntax and prevents defining multiple events. Fix this by adding
a dash before each event item to properly format them as a YAML list, consistent
with other entity examples.
Proposed change
Add event entities to template integration.
e.g.
Type of change
current
branch).current
branch).next
branch).next
branch).Additional information
Checklist
current
branch.next
branch.Summary by CodeRabbit