Breina / PowerTagGateway

HomeAssistant integration for EcoStruxure gateways; SmartLink, PowerTag Link and Panel Servers.
MIT License
14 stars 7 forks source link

Duplicate device ID because of truncated Panel Server component serial number #27

Open Wopples opened 4 days ago

Wopples commented 4 days ago

Describe the bug Our PAS800L panel server has serial numbers with a length of 21 characters. When a device is created the integration turuncates the serial number to 20 characters. Devices that have a serial number with only the last character difference have a conflict. I've been looking for a way to shorten the serial number in the panel server, but have not found. Is it possible to increase the length of the device ID or to truncate the serial number at the front if it's to long? Schneider HA Schneider Panel

Versions

Logs extract: 2024-10-28 09:09:03.701 ERROR (MainThread) [homeassistant.components.binary_sensor] Platform powertag_gateway does not generate unique IDs. ID PowerTagRN-2023-W33-4-GH-010wireless communication valid already exists - ignoring binary_sensor.hal_1_1_wireless_communication_valid 2024-10-28 09:09:03.701 ERROR (MainThread) [homeassistant.components.binary_sensor] Platform powertag_gateway does not generate unique IDs. ID PowerTagRN-2023-W33-4-GH-010radio communication valid already exists - ignoring binary_sensor.hal_1_1_radio_communication_valid 2024-10-28 09:09:03.701 ERROR (MainThread) [homeassistant.components.binary_sensor] Platform powertag_gateway does not generate unique IDs. ID PowerTagRN-2023-W33-4-GH-010alarm info already exists - ignoring binary_sensor.hal_1_1_alarm_info 2024-10-28 09:09:03.706 ERROR (MainThread) [homeassistant.components.binary_sensor] Platform powertag_gateway does not generate unique IDs. ID PowerTagRN-2023-W33-4-GH-010wireless communication valid already exists - ignoring binary_sensor.hal_1_1_wireless_communication_valid 2024-10-28 09:09:03.706 ERROR (MainThread) [homeassistant.components.binary_sensor] Platform powertag_gateway does not generate unique IDs. ID PowerTagRN-2023-W33-4-GH-010radio communication valid already exists - ignoring binary_sensor.hal_1_1_radio_communication_valid 2024-10-28 09:09:03.706 ERROR (MainThread) [homeassistant.components.binary_sensor] Platform powertag_gateway does not generate unique IDs. ID PowerTagRN-2023-W33-4-GH-010alarm info already exists - ignoring binary_sensor.hal_1_1_alarm_info 2024-10-28 09:09:03.707 ERROR (MainThread) [homeassistant.components.binary_sensor] Platform powertag_gateway does not generate unique IDs. ID PowerTagRN-2023-W10-7-GH-004wireless communication valid already exists - ignoring binary_sensor.ontkoppelbord_zp_wireless_communication_valid 2024-10-28 09:09:03.708 ERROR (MainThread) [homeassistant.components.binary_sensor] Platform powertag_gateway does not generate unique IDs. ID PowerTagRN-2023-W10-7-GH-004radio communication valid already exists - ignoring binary_sensor.ontkoppelbord_zp_radio_communication_valid 2024-10-28 09:09:03.708 ERROR (MainThread) [homeassistant.components.binary_sensor] Platform powertag_gateway does not generate unique IDs. ID PowerTagRN-2023-W10-7-GH-004alarm info already exists - ignoring binary_sensor.ontkoppelbord_zp_alarm_info 2024-10-28 09:09:03.725 WARNING (MainThread) [homeassistant.helpers.frame] Detected code that calls async_forward_entry_setup for integration powertag_gateway with title: EcoStruxure Panel Server and entry_id: 01JAYV9GJ313NNXT9KT79W8SYF, during setup without awaiting async_forward_entry_setup, which can cause the setup lock to be released before the setup is done. This will stop working in Home Assistant 2025.1. Please report this issue.

Breina commented 4 days ago

Seems to be an oversight on Schneider's end, so I put a message on their forum.

https://community.se.com/t5/Gateways-and-Energy-Servers/PowerTag-serial-numbers-can-be-longer-than-the-modbus-registers/m-p/489073#M4378

I can work around this though, but if I would do it in the codebase, everyone's entities would get duplicated, so I will propose a manual fix that's just for you:

  1. Navigate to custom_components/powertag_gateway/entity_base.py
  2. On line 126, find self._attr_unique_id = f"{TAG_DOMAIN}{serial}{entity_name}
  3. Add {modbus_index} so that this line becomes self._attr_unique_id = f"{TAG_DOMAIN}{serial}{entity_name}{modbus_index}"
  4. Save and restart

Please let me know if that helps!

Wopples commented 3 days ago

I modified the entity_base.py, restarted HA, deleted the entry, restarted HA, reintegrated the entry. The result is the same with the exception that before I had 633 entities and now I have 810. Some are still mapped to the wrong device and not all devices are shown. I checked if the change to entity_base.py was still there after the reintegration and that was the case. I don't have the impression that new devices were created as my frontend views continue to show their data. So the existing entities are unchanged (except for the units that are set back from kW to W). frontend

Enclosed the core log file: home-assistant_2024-10-29T06-51-15.814Z blinded.txt