core: Reboot buttons for Shelly devices is trying to use a unique_id that's already in use.

The problem

Title explains it all. The integration is attempting to reuse a unique_id that’s already taken by another entity it has created. The entity with the issue appears to be the reboot button for each device. I have 2 shelly devices, this error appears twice in my logs for each device.

2023-06-29 10:40:22.126 ERROR (MainThread) [homeassistant.components.button] Error while setting up shelly platform for button
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 353, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/src/homeassistant/homeassistant/components/shelly/button.py", line 136, in async_setup_entry
    await er.async_migrate_entries(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_registry.py", line 1328, in async_migrate_entries
    ent_reg.async_update_entity(entry.entity_id, **updates)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_registry.py", line 936, in async_update_entity
    return self._async_update_entity(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_registry.py", line 882, in _async_update_entity
    raise ValueError(
ValueError: Unique id 'F4CFA2E45D78_reboot' is already in use by 'button.washer_and_dryer_reboot'
2023-06-29 10:40:22.239 WARNING (MainThread) [homeassistant.helpers.entity] Entity None (<class 'homeassistant.components.wled.light.WLEDSegmentLight'>) is implicitly using device name by not setting its name. Instead, the name should be set to None, please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+wled%22
2023-06-29 10:40:22.251 ERROR (MainThread) [homeassistant.components.button] Error while setting up shelly platform for button
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 353, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/src/homeassistant/homeassistant/components/shelly/button.py", line 136, in async_setup_entry
    await er.async_migrate_entries(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_registry.py", line 1328, in async_migrate_entries
    ent_reg.async_update_entity(entry.entity_id, **updates)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_registry.py", line 936, in async_update_entity
    return self._async_update_entity(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_registry.py", line 882, in _async_update_entity
    raise ValueError(
ValueError: Unique id 'C45BBE603D98_reboot' is already in use by 'button.shelly_em3_reboot'

What version of Home Assistant Core has the issue?

core-2023.7.0b0

What was the last working version of Home Assistant Core?

core-2023.6.3

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

shelly

Link to integration documentation on our website

https://www.home-assistant.io/integrations/shelly/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16 (13 by maintainers)

Most upvoted comments

I will repeat my test with two devices Plus Plug S and Gas so there will be more buttons to migrate. Maybe with more entities there is some edge case. Yes, we should definitely clean up the “old” entities.

Fix is a part of the HA 2023.7.0 release. Probably you need to remove unavailable button entities in the UI. Please do not edit the registry.

You can share your registry here so that we can analyze it.

I was just about to open an issue for this after updating to core 2023.7.0

I have indeed renamed my devices.

Do I need to edit the .storage registry or will your PR fix this when it is released?

wahser_dryer entity registry:

{
        "aliases": [],
        "area_id": null,
        "capabilities": null,
        "config_entry_id": "faf5cce0f97195c483248b4a8c2a92e1",
        "device_class": null,
        "device_id": "6b4d9d9e74f3c6e38704696d104ec525",
        "disabled_by": null,
        "entity_category": "config",
        "entity_id": "button.washer_and_dryer_reboot",
        "hidden_by": null,
        "icon": null,
        "id": "606ce5974bf6fdfbb60ffb5fb5e7dca9",
        "has_entity_name": false,
        "name": null,
        "options": {
          "conversation": {
            "should_expose": false
          }
        },
        "original_device_class": "restart",
        "original_icon": null,
        "original_name": "Washer and Dryer Reboot",
        "platform": "shelly",
        "supported_features": 0,
        "translation_key": null,
        "unique_id": "F4CFA2E45D78_reboot",
        "unit_of_measurement": null
      },

paired config entry

      {
        "entry_id": "faf5cce0f97195c483248b4a8c2a92e1",
        "version": 1,
        "domain": "shelly",
        "title": "Washer and Dryer",
        "data": {
          "host": "192.168.1.9",
          "sleep_period": 0,
          "model": "SHEM",
          "gen": 1
        },
        "options": {},
        "pref_disable_new_entities": false,
        "pref_disable_polling": false,
        "source": "user",
        "unique_id": "F4CFA2E45D78",
        "disabled_by": null
      },

C45BBE603D98_reboot has 2 matches

entity_registry

      {
        "aliases": [],
        "area_id": null,
        "capabilities": null,
        "config_entry_id": "6fa03fca5aa4079c0d22bf14b76d414a",
        "device_class": null,
        "device_id": "d0779a233ede3216f455e2a770446dd1",
        "disabled_by": null,
        "entity_category": "config",
        "entity_id": "button.shelly_em3_reboot",
        "hidden_by": null,
        "icon": null,
        "id": "f5a52702562b90344bebf7865aa4a6d4",
        "has_entity_name": false,
        "name": "Shelly EM3 Reboot",
        "options": {
          "conversation": {
            "should_expose": false
          }
        },
        "original_device_class": "restart",
        "original_icon": null,
        "original_name": "shellyem3-C45BBE603D98 Reboot",
        "platform": "shelly",
        "supported_features": 0,
        "translation_key": null,
        "unique_id": "C45BBE603D98_reboot",
        "unit_of_measurement": null
      },

paired config entry

      {
        "entry_id": "6fa03fca5aa4079c0d22bf14b76d414a",
        "version": 1,
        "domain": "shelly",
        "title": "shellyem3-C45BBE603D98",
        "data": {
          "host": "192.168.1.200",
          "sleep_period": 0,
          "model": "SHEM-3",
          "gen": 1
        },
        "options": {},
        "pref_disable_new_entities": false,
        "pref_disable_polling": false,
        "source": "zeroconf",
        "unique_id": "C45BBE603D98",
        "disabled_by": null
      },

2nd

      {
        "aliases": [],
        "area_id": null,
        "capabilities": null,
        "config_entry_id": "6fa03fca5aa4079c0d22bf14b76d414a",
        "device_class": null,
        "device_id": "d0779a233ede3216f455e2a770446dd1",
        "disabled_by": null,
        "entity_category": "config",
        "entity_id": "button.shellyem3_c45bbe603d98_reboot",
        "hidden_by": null,
        "icon": null,
        "id": "927c3483bc1dc7c7fa70b54343c92587",
        "has_entity_name": false,
        "name": null,
        "options": {
          "conversation": {
            "should_expose": false
          }
        },
        "original_device_class": "restart",
        "original_icon": null,
        "original_name": "shellyem3-C45BBE603D98 Reboot",
        "platform": "shelly",
        "supported_features": 0,
        "translation_key": null,
        "unique_id": "shellyem3_c45bbe603d98_reboot",
        "unit_of_measurement": null
      }

matched entry

      {
        "entry_id": "6fa03fca5aa4079c0d22bf14b76d414a",
        "version": 1,
        "domain": "shelly",
        "title": "shellyem3-C45BBE603D98",
        "data": {
          "host": "192.168.1.200",
          "sleep_period": 0,
          "model": "SHEM-3",
          "gen": 1
        },
        "options": {},
        "pref_disable_new_entities": false,
        "pref_disable_polling": false,
        "source": "zeroconf",
        "unique_id": "C45BBE603D98",
        "disabled_by": null
      },