meshcore-ha icon indicating copy to clipboard operation
meshcore-ha copied to clipboard

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

Open xyrkep opened this issue 3 weeks ago • 0 comments

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.

xyrkep avatar Nov 07 '26 14:11 xyrkep