Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
cc1e02c
Update config_flow.py
partach Jan 19, 2026
1e0176d
Update const.py
partach Jan 19, 2026
0826f6e
Update __init__.py
partach Jan 20, 2026
1875f1c
Update config_flow.py
partach Jan 20, 2026
db55001
Update __init__.py
partach Jan 20, 2026
d90dcb0
Update config_flow.py
partach Jan 20, 2026
4b79eaf
Update const.py
partach Jan 20, 2026
a55f314
Update __init__.py
partach Jan 20, 2026
ed538c4
Update options_flow.py
partach Jan 20, 2026
1a776ce
Update __init__.py
partach Jan 20, 2026
07850f0
Update coordinator.py
partach Jan 20, 2026
5101cce
Update options_flow.py
partach Jan 20, 2026
f7b464f
Update __init__.py
partach Jan 20, 2026
4304656
Update __init__.py
partach Jan 20, 2026
89eb872
Update coordinator.py
partach Jan 20, 2026
a22f34b
Update coordinator.py
partach Jan 20, 2026
86dc433
Update coordinator.py
partach Jan 20, 2026
9c31754
Update __init__.py
partach Jan 20, 2026
0bac6ed
Update coordinator.py
partach Jan 20, 2026
1e5a8ad
Update config_flow.py
partach Jan 20, 2026
17c1cc3
Update __init__.py
partach Jan 20, 2026
c370c5a
Update __init__.py
partach Jan 20, 2026
8b25253
Update options_flow.py
partach Jan 20, 2026
f8104f3
Update coordinator.py
partach Jan 20, 2026
cc1e6a6
Update coordinator.py
partach Jan 20, 2026
de84a6a
Update options_flow.py
partach Jan 20, 2026
d842734
Fix template loading for new Modbus devices in multi-slave architecture
claude Jan 20, 2026
c3aa91c
Merge pull request #19 from partach/claude/fix-multi-slave-templates-…
partach Jan 20, 2026
a1ac3df
Fix entity platform discovery for multi-slave Modbus architecture
claude Jan 20, 2026
2b39be6
Merge pull request #20 from partach/claude/fix-multi-slave-templates-…
partach Jan 20, 2026
82cdcf6
Fix multi-slave menu not appearing for single slave devices
claude Jan 20, 2026
8b555df
Merge pull request #21 from partach/claude/fix-multi-slave-templates-…
partach Jan 20, 2026
f72470f
Fix duplicate device creation when adding multiple slaves
claude Jan 20, 2026
31e4164
Merge pull request #22 from partach/claude/fix-multi-slave-templates-…
partach Jan 20, 2026
ce00cc0
Fix device registry cleanup when deleting Modbus slaves
claude Jan 21, 2026
31d3286
Merge pull request #23 from partach/claude/fix-multi-slave-templates-…
partach Jan 21, 2026
ede94a5
Merge branch 'main' into Multiple-slaves-in-one-device
partach Jan 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
283 changes: 227 additions & 56 deletions custom_components/protocol_wizard/__init__.py

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions custom_components/protocol_wizard/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ async def async_step_user(self, user_input: dict[str, Any] | None = None) -> Flo

if user_input is not None:
self._protocol = user_input.get(CONF_PROTOCOL, CONF_PROTOCOL_MODBUS)
unique_id = f"{DOMAIN}_{user_input.get('device_id', 'default')}_{self._protocol}"
await self.async_set_unique_id(unique_id)
self._abort_if_unique_id_configured()

if self._protocol == CONF_PROTOCOL_MODBUS:
return await self.async_step_modbus_common()
Expand Down
1 change: 1 addition & 0 deletions custom_components/protocol_wizard/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
CONF_PROTOCOL_KNX = "knx"
CONF_PROTOCOL = "protocol"
CONF_IP = "IP"
CONF_SLAVES = "slaves"

# Defaults
DEFAULT_SLAVE_ID = 1
Expand Down
35 changes: 33 additions & 2 deletions custom_components/protocol_wizard/entity_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
CONF_PROTOCOL_MQTT,
CONF_PROTOCOL_BACNET,
CONF_PROTOCOL,
CONF_SLAVES,
)
from .protocols.base import BaseProtocolCoordinator

Expand Down Expand Up @@ -187,10 +188,40 @@ def _unique_id(self, entity_config: dict) -> str:
async def sync_entities(self) -> None:
"""Create, update, and remove entities based on current config."""
config_key = self._get_entities_config_key()
current_configs = self.entry.options.get(config_key, [])

# For Modbus, check if we have the new CONF_SLAVES structure
protocol = self.entry.data.get(CONF_PROTOCOL, CONF_PROTOCOL_MODBUS)
if protocol == CONF_PROTOCOL_MODBUS:
slaves = self.entry.options.get(CONF_SLAVES, [])
if slaves:
# Multi-slave mode: get entities from coordinator's slave
# The coordinator has slave_id and slave_index attributes set
if hasattr(self.coordinator, 'slave_index'):
slave_index = self.coordinator.slave_index
if slave_index < len(slaves):
current_configs = slaves[slave_index].get('registers', [])
_LOGGER.debug("Reading entities from slave %d (index %d): %d entities",
self.coordinator.slave_id, slave_index, len(current_configs))
else:
_LOGGER.warning("Slave index %d out of range (total slaves: %d)",
slave_index, len(slaves))
current_configs = []
else:
# Single slave mode (backward compatibility)
current_configs = slaves[0].get('registers', [])
_LOGGER.debug("Reading entities from single slave: %d entities", len(current_configs))
else:
# Old structure fallback
current_configs = self.entry.options.get(config_key, [])
_LOGGER.debug("Reading entities from old structure (%s): %d entities",
config_key, len(current_configs))
else:
# Non-Modbus protocols use the config key directly
current_configs = self.entry.options.get(config_key, [])

desired_ids = set()
new_entities: list[Entity] = []

for config in current_configs:
if not self._should_create_entity(config):
continue
Expand Down
7 changes: 5 additions & 2 deletions custom_components/protocol_wizard/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ async def async_setup_entry(
):
"""Set up number entities for any protocol."""
coordinator = hass.data[DOMAIN]["coordinators"][entry.entry_id]


# Use coordinator_key if available (multi-slave), otherwise use entry.entry_id
device_identifier = getattr(coordinator, 'coordinator_key', entry.entry_id)

device_info = DeviceInfo(
identifiers={(DOMAIN, entry.entry_id)},
identifiers={(DOMAIN, device_identifier)},
name=entry.title or f"{coordinator.protocol_name.title()} Device",
manufacturer=coordinator.protocol_name.title(),
model="Protocol Wizard",
Expand Down
Loading
Loading