Companion name not updated after public key change; Reconfigure fails while port is in use

Open
#411 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 11 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
46/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start in __init__.py around lines 511–530, where the public key mismatch migration updates the config entry, then trace how companion names and entity IDs are stored and migrated. Also inspect _reconfigure_save() and USB validation in config_flow.py around line 293 to understand why a running entry cannot reconnect. Done means the refreshed name and all companion entities are migrated, and Reconfigure works for a running USB entry or a disabled entry.

Written by the indexing model from the issue text.

Description

Summary

After replacing the companion node (same USB path, new device with a new public key and a new name),
the integration's public key migration updates pubkey and renames most entities to the new key
prefix, but the stored companion name (entry.data["name"], shown as "Primary Node" in the options
dialog) keeps the old node's name. There is no working way to update it from the UI.

Environment

  • meshcore-ha 3.0.5 (HACS)
  • Home Assistant 2026.10.4 (Docker, network_mode: host)
  • Old companion: RAK4631, Companion USB, name old@exemple
  • New companion: Heltec V4, Companion USB 1.18, name new@exemple
  • Connection: USB, /dev/ttyMESHCORE, 115200

Steps to reproduce

  1. Run the integration with companion A (USB).
  2. Replace it with companion B (different key and name) on the same /dev/ttyMESHCORE.
  3. Reload the integration → "MeshCore public key changed" repair appears, entities are migrated to the new prefix.
  4. Open the integration options → "Primary Node" still shows companion A's name.

Impact

coordinator.name comes from entry.data[CONF_NAME] (coordinator.py:196), so after the swap:

  • Outgoing messages are reported with the old name (logbook.py:476 uses coordinator.name as
    sender_name). Automations that filter out own echoes by sender_name (new name) stop working —
    every bot reply triggered an "incoming message" notification.
  • Device / entity names keep the old name suffix (..._4631_essh_fr).
  • Some entities were not migrated to the new key prefix at all: sensor.<old>_cli_console,
    button.<old>_cli_run, button.<old>_cli_clear, sensor.<old>_discovered_summary_*,
    update.<old>_firmware.

In __init__.py (around lines 511–530) the mismatch branch only sets new_data[CONF_PUBKEY] = live_pubkey;
the name is not refreshed from the device.

Reconfigure doesn't help

_reconfigure_save() (config_flow.py:293) would update the name, but:

  • With the entry enabled, Reconfigure → USB → same path fails with "Failed to connect",
    presumably because validate_usb_input() opens the serial port that the running integration already holds.
  • With the entry disabled, Reconfigure is not offered.

The only workaround was to delete the config entry and add it again, which resets all options and repeater
subscriptions and changes the companion entity IDs.

Expected

  • The public key migration also refreshes the stored companion name from the device (as Reconfigure does), and
    migrates all companion entities to the new prefix.
  • Reconfigure works for a running USB entry (e.g., release the connection before validating), or is available
    while the entry is disabled.

Happy to provide diagnostics or debug logs if useful.

Dominant language
Python
Stars
269
Forks
58
Avg merge
10d 17h
Merged PRs (30d)
12

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from meshcore-dev/meshcore-ha

All issues in meshcore-dev/meshcore-ha

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.