-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
Add support for renaming entities dynamically #877
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughA new service for renaming entities has been introduced in the Spook integration for Home Assistant. This feature allows users to dynamically change the names of entities through a new service called Changes
Sequence DiagramsequenceDiagram
participant User
participant HomeAssistant
participant EntityRegistry
User->>HomeAssistant: Call rename_entity service
HomeAssistant->>EntityRegistry: Update entity name
EntityRegistry-->>HomeAssistant: Confirm name change
HomeAssistant-->>User: Service completed
Poem
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: 0
🧹 Nitpick comments (5)
custom_components/spook/ectoplasms/homeassistant/services/rename_entity.py (2)
1-2
: Consider expanding docstring for clarity.
The current docstring,"Spook - Your homie."
, is not very descriptive of the file’s purpose. A short summary of the service’s functionality (e.g., “Service for renaming entities in Home Assistant”) might be more helpful.
23-26
: Consider validating non-emptyname
field.
Whilecv.string
enforces a string type, consider prohibiting empty strings to ensure the entity’s display name is always meaningful. You might want to add a custom validator or incorporate a minimal length check.documentation/entities.md (1)
439-442
: Clarify “friendly_name” vs. “entity_id.”
These lines describe updating the “friendly_name” (throughname
) rather than the entity ID. It might help users if you explicitly note that changing thefriendly_name
doesn’t alter the entity’s underlying ID.documentation/actions.md (1)
127-131
: Minor punctuation/language refinement.
Around line 131, consider rephrasing to avoid the extra underscore near “#LookMaNewName_”. For instance, “#LookMaNewName” might be changed to “#LookMaNewName!” or simply “#LookMaNewName.”-This action can be used to rename an entity on the fly. _#LookMaNewName_ +This action can be used to rename an entity on the fly. #LookMaNewName🧰 Tools
🪛 LanguageTool
[uncategorized] ~131-~131: Loose punctuation mark.
Context: ...aNewName_homeassistant.rename_entity
, [Try this action](https://my.home-assis...(UNLIKELY_OPENING_PUNCTUATION)
custom_components/spook/services.yaml (1)
293-311
: LGTM! Consider enhancing the documentation.The service definition follows the established patterns and integrates well with existing entity management services. However, the description could be more detailed about:
- Whether the rename persists across restarts
- Impact on entity history/statistics
- Behavior when renaming multiple entities with a single name
Apply this diff to enhance the documentation:
description: >- - Renames an entity (or entities) on the fly. + Renames an entity (or entities) on the fly. The new name persists across + Home Assistant restarts and is reflected in the UI, history, and statistics. + When renaming multiple entities, the same name will be applied to all + selected entities.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
documentation/images/entities/rename_entity.png
is excluded by!**/*.png
📒 Files selected for processing (5)
custom_components/spook/ectoplasms/homeassistant/services/rename_entity.py
(1 hunks)custom_components/spook/services.yaml
(1 hunks)documentation/actions.md
(1 hunks)documentation/core_extensions.md
(1 hunks)documentation/entities.md
(2 hunks)
🧰 Additional context used
🪛 LanguageTool
documentation/actions.md
[uncategorized] ~131-~131: Loose punctuation mark.
Context: ...aNewName_ homeassistant.rename_entity
, [Try this action](https://my.home-assis...
(UNLIKELY_OPENING_PUNCTUATION)
🔇 Additional comments (4)
custom_components/spook/ectoplasms/homeassistant/services/rename_entity.py (1)
28-35
: Handle potential non-existent entities gracefully.
Currently, the loop updates any entity in call.data["entity_id"]
without verifying existence. Consider logging a warning or skipping if an entity ID is not found in the registry.
documentation/core_extensions.md (1)
29-29
: Documentation updated successfully.
The addition of “rename” to the set of entity management actions aligns perfectly with the new functionality.
documentation/entities.md (2)
449-481
: Schema layout looks consistent.
The action parameters (entity_id
and name
) are clear, and the documentation follows the same style as existing actions. Excellent coherence!
483-494
: Great example usage.
Providing a YAML snippet makes it straightforward for users to integrate the rename action into their automations. This lowers the barrier to adoption.
Hello! 🙂 Is there a chance someone could help with the PR labels and review? 🙏🏼 |
|
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.
Pull Request Overview
This PR adds a new action to dynamically rename entities in the Spook integration, updating both documentation and service definitions.
- Introduces the homeassistant.rename_entity service in YAML and Python.
- Updates documentation files (entities.md, core_extensions.md, and actions.md) to include details and examples for the new action.
- Enhances developer tool links and example code snippets to support the renaming functionality.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
documentation/entities.md | Updates entity action table and adds a detailed rename action guide |
documentation/core_extensions.md | Adds 'rename' to the list of entity management actions |
documentation/actions.md | Documents the new rename action with examples |
custom_components/spook/services.yaml | Adds the service definition for homeassistant.rename_entity |
custom_components/spook/ectoplasms/homeassistant/services/rename_entity.py | Implements the rename_entity service handling logic |
Comments suppressed due to low confidence (3)
documentation/entities.md:441
- Consider clarifying the description to specify that the friendly name is being updated, for example: 'This action allows you to rename an entity's friendly name on the fly.'
This action allows you to update an entity friendly_name on the fly.
documentation/actions.md:129
- [nitpick] Consider removing or updating the informal tag to maintain a professional tone in the documentation.
This action can be used to rename an entity on the fly. _#LookMaNewName_
custom_components/spook/ectoplasms/homeassistant/services/rename_entity.py:1
- [nitpick] Consider using a more formal module docstring to reflect the professional tone of production code, for example: 'Spook integration service for renaming entities.'
"""Spook - Your homie."""
Description
This PR introduces a new action to the Spook integration, allowing users to rename entities dynamically. It updates the
services.yaml
file and associated documentation to include the newhomeassistant.rename_entity
action.Motivation and Context
This new action allows users to rename an entity without needing to go through the UI process, enabling more efficient workflows. It also provides the ability to dynamically rename entities within automations and scripts, or perform bulk renaming of multiple entities at once, helping users maintain better naming conventions in their smart homes. Additionally, this action aligns with other entity management functionalities already provided, such as changing entity IDs, ensuring consistency and enhancing the flexibility of entity customization.
How has this been tested?
homeassistant.rename_entity
action was manually tested to ensure it successfully renames single and multiple entities.Screenshots (if appropriate):
Types of changes
Checklist