mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Pr/11430 (#11587)
* Fix error when name is non-latin script When the name is non-latin script (e.g. Japanese), slugify returns empty string and causes failure in a later stage. This commit fixes the issue by using default name. * Add test
This commit is contained in:
parent
6af42b4372
commit
9384e2c963
@ -35,10 +35,10 @@ def generate_entity_id(entity_id_format: str, name: Optional[str],
|
||||
current_ids, hass
|
||||
).result()
|
||||
|
||||
name = (name or DEVICE_DEFAULT_NAME).lower()
|
||||
name = (slugify(name) or slugify(DEVICE_DEFAULT_NAME)).lower()
|
||||
|
||||
return ensure_unique_string(
|
||||
entity_id_format.format(slugify(name)), current_ids)
|
||||
entity_id_format.format(name), current_ids)
|
||||
|
||||
|
||||
@callback
|
||||
|
@ -31,6 +31,14 @@ def test_generate_entity_id_given_keys():
|
||||
'test.another_entity']) == 'test.overwrite_hidden_true'
|
||||
|
||||
|
||||
def test_generate_entity_id_with_nonlatin_name():
|
||||
"""Test generate_entity_id given a name containing non-latin characters."""
|
||||
fmt = 'test.{}'
|
||||
assert entity.generate_entity_id(
|
||||
fmt, 'ホームアシスタント', current_ids=[]
|
||||
) == 'test.unnamed_device'
|
||||
|
||||
|
||||
def test_async_update_support(hass):
|
||||
"""Test async update getting called."""
|
||||
sync_update = []
|
||||
|
Loading…
x
Reference in New Issue
Block a user