Skip to content

Commit

Permalink
Keep the provided name when creating a tag (home-assistant#128240)
Browse files Browse the repository at this point in the history
* Keep the name

* Add patch

* Update homeassistant/components/tag/__init__.py

Co-authored-by: G Johansson <goran.johansson@shiftit.se>

---------

Co-authored-by: G Johansson <goran.johansson@shiftit.se>
  • Loading branch information
silamon and gjohansson-ST authored Oct 14, 2024
1 parent 56e550f commit 866912d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion homeassistant/components/tag/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ def _create_entry(
original_name=f"{DEFAULT_NAME} {tag_id}",
suggested_object_id=slugify(name) if name else tag_id,
)
return entity_registry.async_update_entity(entry.entity_id, name=name)
if name:
return entity_registry.async_update_entity(entry.entity_id, name=name)
return entry


class TagStore(Store[collection.SerializedStorageCollection]):
Expand Down
4 changes: 4 additions & 0 deletions tests/components/tag/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ async def test_entity_created_and_removed(
assert item["id"] == "1234567890"
assert item["name"] == "Kitchen tag"

await hass.async_block_till_done()
er_entity = entity_registry.async_get("tag.kitchen_tag")
assert er_entity.name == "Kitchen tag"

entity = hass.states.get("tag.kitchen_tag")
assert entity
assert entity.state == STATE_UNKNOWN
Expand Down

0 comments on commit 866912d

Please sign in to comment.