-
Notifications
You must be signed in to change notification settings - Fork 529
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
[EN] Explicit and friendly domain name for HassTurnOn/HassTurnOff #2418
[EN] Explicit and friendly domain name for HassTurnOn/HassTurnOff #2418
Conversation
📝 WalkthroughWalkthroughThe pull request introduces dynamic responses for the Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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: 1
🧹 Outside diff range and nitpick comments (8)
tests/en/media_player_HassTurnOn.yaml (1)
3-9
: Consider adding a generic media player test case.The current test cases cover various ways to turn on a TV, which is great. To improve test coverage, consider adding a test case for a generic media player. This would ensure the intent works correctly for other types of media players as well.
Here's a suggested addition:
- sentences: - "turn on the media player" - "activate the media player" intent: name: HassTurnOn slots: domain: media_player name: media player response: "Turned on"tests/en/media_player_HassTurnOff.yaml (3)
4-9
: LGTM: Comprehensive set of test sentences.The test sentences cover a wide range of variations for the "turn off TV" command, including different word orders and phrasings. This comprehensive set will help ensure robust intent recognition.
Consider adding a sentence with a more specific TV name, e.g., "turn off the living room TV", to test handling of multi-word device names.
10-14
: LGTM: Intent and slots are correctly defined.The intent name and slots are properly set up for the "turn off TV" use case.
Consider parameterizing the "name" slot in the test case to allow for testing with different device names. This could help ensure the intent works correctly for various media player names beyond just "TV".
1-15
: Great job! This test file effectively addresses the PR objectives.The
media_player_HassTurnOff.yaml
test file is well-structured and comprehensive. It successfully implements the proposed solution of removing the domain from the response for themedia_player
domain. The test cases cover various phrasings for turning off a TV, and the expected response is clear and concise.This implementation effectively resolves the issue of incorrect pronunciation in voice responses without compromising the functionality of the intent recognition system.
As the project evolves, consider creating a centralized configuration for common device types and their aliases. This could make it easier to maintain consistency across different intents and languages.
sentences/en/media_player_HassTurnOn.yaml (1)
5-8
: LGTM: Sentence patterns are comprehensive and flexible.The defined sentence patterns cover various ways a user might phrase the command to turn on a media player, which aligns well with the PR objectives.
Consider adding a pattern for "power on" as an alternative to "turn on", e.g., " on ( | [in ])". This might capture additional user phrasings.
sentences/en/media_player_HassTurnOff.yaml (1)
5-8
: LGTM: Sentence structures are comprehensive.The defined sentence structures provide good flexibility for users to turn off media players. They cover various phrasings and include options for specifying areas.
Consider adding a structure for plural forms, such as:
- "<turn> off (<area> <name>|<name> [in <area>]){s}"
This would allow for commands like "Turn off the TVs in the living room".
responses/en/HassTurnOn.yaml (1)
16-16
: LGTM! The change addresses the issue effectively.The new entry for
media_player
successfully removes the domain from the response, addressing the mispronunciation issue described in the PR objectives. This change will improve the clarity of voice responses for media player commands.Consider enhancing this further by utilizing the
name
slot if available, which could provide more specific feedback when multiple media players are present. For example:media_player: > {% if slots.name %}Turned on {{ slots.name }}{% else %}Turned on{% endif %}This would allow responses like "Turned on Living Room TV" when a name is available, while falling back to the generic "Turned on" when it's not.
responses/en/HassTurnOff.yaml (1)
Line range hint
1-15
: Consider consistency and future improvements across domainsWhile the current change effectively solves the immediate issue, consider the following points for future improvements:
The
media_player
response is notably shorter than others. For consistency, you might want to consider a slightly more verbose response, such as "Turned off the player" or "Turned off the device".This change might set a precedent for handling other domains with underscores or spaces. It might be worth considering a more general solution that could be applied consistently across all domains.
As mentioned in the PR objectives, adding the domain without underscores could be a potential middle ground. For example: "Turned off the media player".
These suggestions aim to balance solving the current issue while maintaining consistency and planning for potential future challenges.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (8)
- responses/en/HassTurnOff.yaml (1 hunks)
- responses/en/HassTurnOn.yaml (1 hunks)
- sentences/en/homeassistant_HassTurnOff.yaml (1 hunks)
- sentences/en/homeassistant_HassTurnOn.yaml (1 hunks)
- sentences/en/media_player_HassTurnOff.yaml (1 hunks)
- sentences/en/media_player_HassTurnOn.yaml (1 hunks)
- tests/en/media_player_HassTurnOff.yaml (1 hunks)
- tests/en/media_player_HassTurnOn.yaml (1 hunks)
🧰 Additional context used
🔇 Additional comments (18)
tests/en/media_player_HassTurnOn.yaml (2)
1-2
: LGTM: File structure is correct.The YAML file structure is appropriate for a test configuration, with the language specified and a tests array defined.
3-15
: LGTM: Content aligns well with PR objectives.The test case content effectively addresses the PR's main objective:
- Various sentence variations for turning on a TV are included (lines 3-9).
- The intent structure correctly defines 'HassTurnOn' with appropriate slots (lines 10-14).
- The response "Turned on" (line 15) resolves the issue by removing the domain from the response, avoiding the "media underscore player" pronunciation problem.
This implementation successfully achieves the goal of improving voice responses for media player commands.
tests/en/media_player_HassTurnOff.yaml (3)
1-1
: LGTM: Language specification is correct.The language specification aligns with the file location and the PR objectives.
2-3
: LGTM: Test case structure is well-defined.The YAML structure for the test case is correct and follows the expected format.
15-15
: LGTM: Response aligns with PR objectives.The expected response "Turned off" is concise and clear. It successfully addresses the PR's main objective by removing the domain from the response, which solves the issue of incorrect pronunciation of "media_player".
This implementation effectively resolves the problem described in the PR summary.
sentences/en/media_player_HassTurnOn.yaml (4)
1-3
: LGTM: Language and intent declaration are correct.The language is correctly set to English, and the intent name "HassTurnOn" is clear and follows the naming convention.
9-10
: LGTM: Domain specification is correct.The slot definition correctly specifies the domain as "media_player", which aligns with the PR objectives of addressing the issue specifically for the media_player domain.
11-12
: LGTM: Context requirement is appropriate.The context requirement ensures that this intent is only triggered in the context of a media player, which is appropriate for the intended functionality.
13-13
: Verify if this response resolves the pronunciation issue.The response is set to "media_player", which might not directly address the pronunciation issue mentioned in the PR objectives. The goal was to avoid the "media underscore player" pronunciation.
Consider modifying the response to remove the domain entirely, as suggested in the PR objectives. For example:
response: turn_onThis would allow for a generic "Turned on" response without mentioning the media player, potentially resolving the pronunciation issue.
To verify the current implementation, please run the following script:
This will help us ensure that the response is consistent and doesn't include the problematic "media_player" phrase in other files.
sentences/en/media_player_HassTurnOff.yaml (6)
1-1
: LGTM: Language declaration is correct.The language is correctly set to "en" for English, which aligns with the PR objectives.
2-3
: LGTM: Intent declaration is correct.The intent
HassTurnOff
is correctly declared and matches the file name and PR objectives.
9-10
: LGTM: Slot definition is correct.The slot
domain
is correctly set to "media_player", which aligns with the PR objectives to handle media player responses specifically.
11-12
: LGTM: Context requirement is appropriate.The context requirement ensures that this intent is only triggered for media players, which is in line with the PR objectives.
13-13
: LGTM: Response category is set correctly.The response category is set to "media_player", which aligns with the PR objectives to address the issue with media player responses.
To ensure this change resolves the pronunciation issue mentioned in the PR objectives, please verify that the response generated does not include "media_player" in the output. You can do this by testing the intent with various inputs and checking the responses.
#!/bin/bash # Description: Search for response templates that might still include "media_player" # Test: Search for response templates containing "media_player" rg --type yaml 'response:.*media_player' sentences/en/
1-13
: Overall, the changes in this file effectively address the PR objectives.The new
HassTurnOff
intent for media players is well-structured and should resolve the issue with incorrect pronunciation of "media_player" in responses. The sentence structures, slots, context requirements, and response category are all aligned with the goal of improving voice responses for media player commands.To ensure full compatibility with the existing system:
- Verify that this new intent doesn't conflict with any existing intents for turning off devices.
- Test the intent with various phrasings to ensure it covers all expected use cases.
- Confirm that the response generated doesn't include "media_player" in the output.
sentences/en/homeassistant_HassTurnOff.yaml (1)
17-17
: Approved: Addition ofmedia_player
to excluded contexts.The change correctly addresses the PR objective by excluding the
media_player
domain from theHassTurnOff
intent. This should prevent the incorrect "Turned off the media_player" response.However, could you please clarify how media players will be turned off after this modification? Will there be a separate intent or handling mechanism for media players?
To ensure this change doesn't break existing functionality, please run the following verification:
responses/en/HassTurnOff.yaml (2)
15-15
: LGTM! This change effectively addresses the PR objective.The addition of
media_player: "Turned off"
successfully resolves the issue of mispronouncing "media_player" in voice responses. This concise response aligns perfectly with the PR's goal of improving clarity for media player commands.
Line range hint
1-15
: Verify consistency across languages and usageTo ensure this change doesn't introduce inconsistencies or break existing functionality, please run the following verification steps:
Please review the results of these checks to ensure that:
- The
media_player
entry is consistently handled across all language files.- There are no hardcoded expectations of the response format that might break due to this change.
- All relevant tests are updated to reflect this change.
@@ -15,3 +15,4 @@ intents: | |||
- script | |||
- sensor | |||
- valve | |||
- media_player |
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.
💡 Codebase verification
Inconsistent Exclusion of 'media_player' Across Intent Files
The addition of 'media_player' to the excluded domains in sentences/en/homeassistant_HassTurnOn.yaml
is approved. However, media_player
is still included in multiple other intent files across various languages. To maintain consistency and prevent unintended behavior, please verify and apply similar exclusions where necessary.
🔗 Analysis chain
Approved: Addition of 'media_player' to excluded domains.
This change aligns with the PR objective to address the issue with media player responses. It's a minimal and focused modification that should resolve the problem of incorrect pronunciation in voice responses.
To ensure this change doesn't have unintended consequences, please verify:
- That turning on media players still works correctly through other means.
- That this change is consistent with any related files or intents.
Run the following script to check for any other occurrences of 'media_player' in intent files that might need similar modifications:
This will help ensure consistency across the intent system.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Search for 'media_player' occurrences in other intent files
# Test: Look for 'media_player' in other YAML files
rg --type yaml 'media_player' sentences/
Length of output: 9382
Script:
#!/bin/bash
# Description: Verify if 'media_player' exclusions are present in other HassTurnOn intent files
# Search for 'HassTurnOn' intent files across all languages
fd --type f 'HassTurnOn.yaml' sentences/ --exec grep -H 'media_player' {}
Length of output: 364
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.
Looks good to me
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: 0
🧹 Outside diff range and nitpick comments (3)
responses/en/HassTurnOn.yaml (2)
5-25
: Approve with suggestions: Dynamic response improves clarity, but consider refinements.The introduction of a dynamic response using a Jinja2 template is a significant improvement. It addresses the PR objective of providing more accurate and user-friendly responses for different device types. However, I have a few suggestions to enhance this implementation:
Add a fallback for unknown device types to ensure clear responses in all scenarios. For example:
Turned on {{ translations.get(state.domain, "the " + state.domain.replace('_', ' ')) }}
Consider moving the
translations
dictionary to a separate file (e.g.,device_translations.yaml
) and importing it. This would improve maintainability and allow reuse across multiple intents.Be cautious with the current indentation of the Jinja2 template. YAML is sensitive to indentation, and the current structure might lead to parsing issues. Ensure that the YAML structure is preserved when the template is processed.
Would you like assistance in implementing these suggestions?
Line range hint
26-38
: Consider reviewing specific responses for consistency.While the new default response provides improved clarity for various device types, there are some potential inconsistencies with the specific responses that remain unchanged. For example:
- Default: "Turned on the media player"
- Lights: "Turned on the lights"
- Cover: "Opened"
To maintain a consistent user experience across all device types, consider reviewing and potentially updating these specific responses to align with the new default response style.
Would you like assistance in drafting consistent responses for these specific device types?
responses/en/HassTurnOff.yaml (1)
5-25
: Improved response specificity, but consider further enhancementsThe changes effectively address the PR objective by providing more specific and user-friendly responses for different device types. This solution resolves the issue with incorrect pronunciation of "media_player" and offers flexibility for future extensions.
However, there are a few considerations and potential improvements:
The translations dictionary is quite long. Consider moving it to a separate file for better maintainability and potential reuse across other intent files (e.g., HassTurnOn.yaml).
Ensure consistency with other response files, particularly HassTurnOn.yaml, to maintain a uniform user experience.
Add a fallback for unknown domains to prevent potential errors. For example:
Turned off {{ translations.get(state.domain, "the " + state.domain.replace("_", " ")) }}
This fallback would replace underscores with spaces for unknown domains, providing a reasonable default response.
Would you like assistance in implementing these suggestions?
The point of these files are to be easily interpreted and translated by the language leaders, so adding extra code complexity will harm legibility. A response such as "Turned on" is perfectly fine (i.e. without domain name) in case an unknown domain happens to be assigned to an entity. |
Tip For best results, initiate chat on the files or code changes. @tetele: Understood, thank you for explaining your reasoning. Keeping the responses simple for better legibility by the language leaders makes sense. (_/) |
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.
Thx very much! This will greatly help other language leaders
"Turn on the TV" would hare produced the response "Turned on the media_player", read as "Turned on media underscore player"
We've patched this by adding a map of how each domain should be handled in the response text.
Other approaches would have been to:
name
slot instead of domain (such as in RO)media_player
domain, which is what I wanted to do withmetadata
Summary by CodeRabbit
HassTurnOn
andHassTurnOff
intents with dynamic feedback based on device types.These updates improve user interaction by providing contextually relevant responses when controlling devices.