Skip to content

Commit 691f013

Browse files
committed
Fix multiple inverters creating duplicate device instead of separate devices
PROBLEM: When users added a second inverter (different IP address), it recreated the same device as the first inverter instead of creating a second device in Home Assistant. Both inverters' entities appeared under one device. ROOT CAUSE: Device identifier in coordinator.py used slave_id: "identifiers": {(DOMAIN, self._slave_id)} Both inverters typically use slave_id=1 (default), so Home Assistant considered them the same device and merged all entities into one. FIX: Changed device identifier to use config entry_id (coordinator.py:536): "identifiers": {(DOMAIN, self.entry.entry_id)} Config entry_id is unique per integration instance, guaranteed to be different for each inverter added, even if they have the same slave_id. RESULT: Users can now add multiple inverters (at different IP addresses) and each will appear as a separate device with its own sensors. MIGRATION NOTE: Existing users will see their device re-created with a new ID after updating. The old device may need to be manually removed from: Settings → Devices & Services → Devices (search for old Growatt device)
1 parent a5133dc commit 691f013

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

custom_components/growatt_modbus/coordinator.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -527,25 +527,26 @@ def _parse_model_name(self, inverter_type: str, profile: dict) -> str:
527527
def device_info(self):
528528
"""Return device information for Home Assistant."""
529529
profile = REGISTER_MAPS[self._register_map_key]
530-
530+
531531
# Use parsed model name if available, otherwise fall back to profile name
532532
model = self._model_name if self._model_name else profile.get("name", "Unknown Model")
533-
533+
534534
device_info = {
535-
"identifiers": {(DOMAIN, self._slave_id)},
535+
# Use entry_id for unique device identification (not slave_id, which may be the same for multiple inverters)
536+
"identifiers": {(DOMAIN, self.entry.entry_id)},
536537
"name": self.config[CONF_NAME],
537538
"manufacturer": "Growatt",
538539
"model": model,
539540
}
540-
541+
541542
# Add serial number if available
542543
if self._serial_number:
543544
device_info["serial_number"] = self._serial_number
544-
545+
545546
# Add firmware version if available
546547
if self._firmware_version:
547548
device_info["sw_version"] = self._firmware_version
548-
549+
549550
return device_info
550551

551552
@property

0 commit comments

Comments
 (0)