Skip to content
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

[QOL] Format Home Assistant entity names without _ #4048

Closed
blakadder opened this issue Aug 5, 2020 · 7 comments
Closed

[QOL] Format Home Assistant entity names without _ #4048

blakadder opened this issue Aug 5, 2020 · 7 comments

Comments

@blakadder
Copy link
Contributor

Currently Home Assistant entity names are generated with _ which is perfectly functional but doesn't look that great in the UI and more importantly when using device triggers in automations.

image
image

While it is possible to change the names manually in Lovelace it would become quite a chore proportional to number of entities a device creates.

I'm proposing a simple change of _ into a space when generating name: value autodiscovery payload so the end result would be:
image
image

@Koenkk
Copy link
Owner

Koenkk commented Aug 5, 2020

I think this highly depends on how people name their entities. Personally I prefer to use snake_case for the friendly_name as I dislike the spaces, e.g. kitchen_climate_sensor, having this to appear as kitchen_climate_sensor temperature feels strange to me.

Something we can do is to use a space instead of _ when the friendly_name contains a space. Does that sound like a good approach?

@blakadder
Copy link
Contributor Author

Excellent solution!

@Koenkk
Copy link
Owner

Koenkk commented Aug 6, 2020

Maybe even more fancy (not sure if this is desired):

  • Sonoff Motion -> Sonoff Motion Battery (capital B)
  • sonoff motion -> sonoff motion battery
  • Default _battery

@blakadder
Copy link
Contributor Author

Perhaps, personally I'm not bothered by case...

Also what if it's "Sonoff motion" ?

@Koenkk
Copy link
Owner

Koenkk commented Aug 8, 2020

I've took that from your example in the OP.

I've implemented this now, assuming this can be closed.

Changes will be available in the latest dev branch in a few hours (https://www.zigbee2mqtt.io/how_tos/how-to-switch-to-dev-branch.html)

@Koenkk Koenkk closed this as completed Aug 8, 2020
@crowbarz
Copy link
Contributor

I had been manually converting that _ to a space in the friendly_name for every generated entity via devices.yaml overrides. This feature will eliminate the need to continue to do that - thanks!

However, a small pre-upgrade question, what happens with entities whose name is just a single word? Will these continue to need manual modification either in devices.yaml, HA entity settings, or Lovelace?

@Koenkk
Copy link
Owner

Koenkk commented Aug 12, 2020

However, a small pre-upgrade question, what happens with entities whose name is just a single word? Will these continue to need manual modification either in devices.yaml, HA entity settings, or Lovelace?

It will only be done when the friendly name contains a space (so not in this case)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants