Repository navigation
Eg4-Inverters
Added ability to add on additional EG4 inverters.
Summary of changes
- Data model
- Added CONF_ENTRY_INDEX = "entry_index" in Python.const.
- Config flow: allow multiple entries and auto-assign index
- Added _next_available_index() and modified Python.async_step_user() to:
- Auto-compute next index across existing entries.
- Inject entry_index into the created config entry’s data.
- Set a unique_id that includes base_url and the index to avoid duplicate aborts.
Format: f"{DOMAIN}|{base_url}|{index}"
- Migration for existing installs
- Implemented Python.async_migrate_entry() to backfill entry_index=1 for legacy entries without changing entry.entry_id or entities.
- Device info naming only (no unique_id changes to entities)
- Updated Python.sensor device_info and Python.binary_sensor device_info:
- Keep identifiers {(DOMAIN, entry.entry_id)} to preserve device binding.
- Device name is:
- EG4 Inverter for index 1 (migrated)
- EG4 Inverter {index} for index > 1
Preserved stability
- Entities’ unique_ids continue to be based on entry.entry_id and are unchanged, so history and associations remain intact for existing setups.
How this addresses the original issue
- Previously, config flow unique_id was based on title and caused Home Assistant to abort when a second inverter with the same base URL was added. Now, unique_id includes the auto-assigned index, so multiple config entries can co-exist.
- Devices are displayed distinctly: EG4 Inverter (first) and EG4 Inverter 2 (second), etc.
- All sensors are grouped under the correct device and remain uniquely identified.
What to test
- Restart Home Assistant to apply migration; verify existing device remains EG4 Inverter with entities intact.
- Add a second entry with same/different credentials as needed; confirm device shows as EG4 Inverter 2 and entities appear correctly.
- Optionally add a third to confirm EG4 Inverter 3.
- Remove and re-add entries; index will keep incrementing by max+1 (current strategy).
Files modified
Documentation note
- Add a README section: Multiple Inverters
- Existing installs become index 1 automatically.
- Adding another inverter will create EG4 Inverter 2, 3, …
- Entity names remain the same; use device name to distinguish in UI.
Full Changelog: https://github.com/Trixanna/EG4-Inverter/commits/v1.1.0