Friendly_name with Chinese characters got error,is this a bug?

hi,

I have a Broadlink Switch and I put it in configuration like:

switch 4:
platform: broadlink
host: 10.0.0.90
mac: ‘xx:xx:xx:xx’
type: spmini2
friendly_name: ‘XXX’

I found that if I use all Chinese characters (eg:客厅) in friendly_name, then it shows error and the switch disappear in frontend:

17-01-18 13:37:34 homeassistant.core: Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
    result = next(coro)
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 336, in _async_process_entity
    new_entity, self, update_before_add=update_before_add
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 202, in async_add_entity
    'Invalid entity id: {}'.format(entity.entity_id))
homeassistant.exceptions.HomeAssistantError: Invalid entity id: switch.

If I use Chinese characters + English words (eg:客厅wifi) OR all English words in friendly_name, it shows no error.

Is this a bug? please help!

Yes it seems to be using the friendly name as entity_id instead of using an entity_id and a friendly name

Thanks touliloup, it extract the English part in friendly_name as entity_id indeed. If there is no English part just like all Chinese characters, it shows Invalid entity id.

So I wonder if it will be fix in the future version or is there some alternative way to use Chinese as friendly_name.

I guess a fix is possible, some device allow for both name and friendly_name, not sure if it already available/possible for this component.

Maybe you should open an issue on GitHub:

Could this be due UTF-8 encoding used in HA vs. UTF-16 which provides better support for Chinese characters?

It is not a bug.

You should use English characters in the all config files(etc: configuration.yaml) first,

And then, use customize.yaml file(only) to change the ‘Friendly name’ in Chinese character !

I am also from China, if you want have a discuss with me,

pls contact my WeiXin(Wechat): gao13903408669

There were some scenarios that friendly name were not set by the configuration.yaml , but by the ‘homeassistant.components’ during the hass initialization.

e.g. homeassistant.components.tado will do so ,it fetches the home name from tado.com (maker’s site)

It is UGLY to extend this INTERNAL obligation of ‘NO chinese /asia name in configuration’ to innocent third party.

thus why I consider it as A BUG.

1 Like

在customize中定义entity id,赋予friendly name 中文名即可

2017-08-31_124450

Same problem here with 0.60.
I’m newbie to python but for unicode system, there should not be CJK issues any more.
As to the current implementation, how about using python-pinyin to extract pinyin chars from Chinese string as entity id ?

Personally thinking, of course it is a bug. Some platform offers the possibility to setup friendly_name inside component’s column, others are not. It all depends on component’s creators. Like broadlink, it actually open this possibility. If it doesn’t or decide to remove this approach, they should correct relevant docs to avoid other language speaker misunderstanding about this issue and let users only go to customize part.

For now, try to use customize for Chinese friendly_name and input English name in name part of component.

Furthermore, actually it raises a issue that if we can figure out a way to transform none-English name into and entity_ID.

Chinese translation:
我认为这是一个 bug,理由是博联组件本身的描述不清。正常情况下昵称应该在 customize 模块设置,但是博联的 Doc 又给出了组件内设置的路径,导致大家误解。应该是组件本身没有对字符编码解析导致的,错误将昵称作为名称(只能英文)。目前建议还是在 customize 里设中文昵称,在博联组件内的设置使用英文。

hell of configuration…

ye.

but friendly_name field not for swtiches (MQTT switch register) component。

the Chinese characters auto converted Chinese Pinyin。

hoply fix this bug。