home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.62k stars 30.78k forks source link

Autogenerated entity names are impossible to differentiate with integrations that create multiple devices with the same base name #23995

Closed ACiDGRiM closed 5 years ago

ACiDGRiM commented 5 years ago

Home Assistant release with the issue: 0.93.1

Last working Home Assistant release (if known): Has been this way since I started using Home Assistant

Operating environment (Hass.io/Docker/Windows/etc.): Hass.io Docker on rasbian

Component/platform: Z-Wave and other integrations

Description of problem: When adding integrations that create multiple entities and related sub-entities, the names are auto generated on the Device Name string. This is a usability issue when there are multiple entities named:

switch.elexa_consumer_products_inc_dome_on_off_plug_in_switch_switch switch.elexa_consumer_products_inc_dome_on_off_plug_in_switch_switch_2 switch.elexa_consumer_products_inc_dome_on_off_plug_in_switch_switch_3 switch.elexa_consumer_products_inc_dome_on_off_plug_in_switch_switch_4

as well as several related entities with the same name. Homeseer does not use the "name" property in core.device_registry or the parent entity in core_entity_registry when generating these child entities.

This leaves management in an inconsistent state and requires manual editing of configuration files. Allowing a rename of these devices and regeneration of entity names would rexolve entity management.

Additional information: Regenerating missing entity names on cached Name attributes from core.device_registry would reduce actions required to manually update entity names.

Swamp-Ig commented 5 years ago

I'm actually already working on this, at least for z wave.

Swamp-Ig commented 5 years ago

OK, so here's what I do, although it's a bit hacky:

  1. Shut down hass
  2. Edit the zwcfg_***.xml file

You can change the device names with the name attribute, which starts blank:

    <Node id="48" name="Node Name" location="" basic="4" generic="17" specific="1" roletype="5" devicetype="1536" nodetype="0" type="Multilevel Power Switch" listening="true" frequentListening="false" beaming="true" routing="true" max_baud_rate="40000" version="4" secured="true" query_stage="Complete">

If you want to edit the names of entities rather than devices, then edit the label attribute:

            <CommandClass id="50" name="COMMAND_CLASS_METER" version="3" request_flags="2" innif="true">
                <Instance index="1" />
                <Value type="decimal" genre="user" instance="1" index="0" label="Energy" units="kWh" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" value="7.400" />
                <Value type="decimal" genre="user" instance="1" index="1" label="Previous Reading" units="kWh" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" value="7.400" />
            </CommandClass>
  1. Restart hass

You might have to remove any entities and then restart again to repopulate their names. The device names get updated though.

Swamp-Ig commented 5 years ago

There's actually a zwave service that will rename nodes and values too. Here's a cut and paste from the source. Not sure why the documentation doesn't show up in the services dev tools, but anyhow:


rename_node:
  description: Set the name of a node. This will also affect the IDs of all entities in the node.
  fields:
    node_id:
      description: ID of the node to rename.
      example: 10
    name:
      description: New Name
      example: 'kitchen'

rename_value:
  description: Set the name of a node value. This will affect the ID of the value entity. Value IDs can be queried from /api/zwave/values/{node_id}
  fields:
    node_id:
      description: ID of the node to rename.
      example: 10
    value_id:
      description: ID of the value to rename.
      example: 72037594255792737
    name:
      description: New Name
      example: 'Luminosity'
Swamp-Ig commented 5 years ago

Ok just submitted a PR that partially fixes this issue for zwave at least. #24032

Joshfindit commented 5 years ago

Any chance this could loop in MQTT devices as well?

Joshfindit commented 5 years ago

Personally, I'd even be comfortable with this workflow:

  1. Disable discovery
  2. Reboot
  3. Run a service called homeassistant.delete_entity and choose the offending entity from the dropdown (just like homeassistant.update_entity)
  4. Repeat for each entity

Alternately:

  1. Run a service called homeassistant.delete_entity and choose group.all_unavailable
  2. Already done

Or:

  1. Somehow call switch.elexa_consumer_products_inc_dome_on_off_plug_in_switch_switch_4.delete_entity
Swamp-Ig commented 5 years ago

Front end PR done that lets you edit device names, that should help :)