Feature request / possible bug: DM fallback to flood for stale paths

Open
#302 3 comments 1 reaction 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
22/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
backend

Research direction

The issue names no source files, so start from the Home Assistant service that sends direct messages and the existing change_contact_path(...) and path discovery commands it mentions. Confirm how the companion reports ACK status for a sent DM, then check whether a retry and flood-resend path can be triggered from there. Done means a DM that fails on a stale saved path is retried, its path is cleared, and it is resent with flood routing, with the learned path stored on success. Expect protocol-level design questions before writing code.

Written by the indexing model from the issue text.

Description

bug enhancement help wanted

When sending a direct/private message through the Home Assistant integration using a USB Serial Companion,
the message appears to keep using the previously saved DM path / contact out_path.

If that path is no longer valid because one of the companions has moved to another repeater area, the
message may fail instead of automatically falling back to flood routing.

From the MeshCore FAQ, the official app behavior appears to be:

  1. Try the known saved path.
  2. Retry when the message is not ACKed.
  3. After multiple failed retries, reset/clear the saved path.
  4. Send again using flood as a fallback.

It would be very useful if meshcore-ha could implement the same behavior for direct/private messages sent
through Home Assistant.

Why this matters

A companion is often mobile by design. When a companion moves to another location or another repeater area,
the previously learned route may become stale.

In the official MeshCore app, this appears to be handled by retrying and eventually falling back to flood.
However, messages sent from Home Assistant via USB Serial Companion do not appear to do this automatically.

This makes direct/private messages from Home Assistant less reliable for mobile companions, especially for
bots and automations.

Observed behavior

In my setup, public/channel messages can be received through the mesh, but direct/private messages sent from
Home Assistant to the same mobile companion may remain Unconfirmed.

The contact is known by the USB Serial Companion, but the saved path appears to stay stale or unusable.
Manual path changes or path discovery commands may be required, which is not practical for automations.

Example observations:

  • Public message from mobile companion to the Home Assistant USB companion: received.
  • Direct/private message from Home Assistant USB companion to the same mobile companion: Unconfirmed.
  • Trace/path discovery to that companion: timeout / path_discovery_timeout.
  • Manually testing different repeater paths did not reliably recover the DM delivery.

Expected behavior

When sending a DM/private message through Home Assistant:

  • Try the saved contact path first.
  • Wait for ACK / delivery confirmation.
  • Retry if no ACK is received.
  • After failed retries, clear/reset the stale path.
  • Re-send using flood routing, similar to the official app behavior.
  • If delivery succeeds, store the newly learned path for future messages.

Suggested implementation

Add support for automatic DM fallback behavior in meshcore-ha, for example:

  • Track ACK/delivery updates for direct/private messages sent through Home Assistant.
  • Use timeout/retry information from the companion protocol if available.
  • Add optional fallback behavior for direct/private messages, enabled by default or configurable.
  • Optionally expose a service parameter to force flood routing for a DM when needed.
  • Optionally expose a service to clear/reset a saved DM path from Home Assistant.

Current workaround

Manually clearing or changing the contact path from Home Assistant can sometimes help, for example by using
path discovery or change_contact_path(...) commands.

However, this is not reliable or practical for automations, bots, or mobile users because the correct path
can change frequently.

Environment

  • Integration: meshcore-ha
  • Radio type: USB Serial Companion
  • Sender: Home Assistant service / automation
  • Message type: direct/private message
  • Path hash mode: 2 / 3-byte
  • Radio: 910.525 MHz, bandwidth 62.5, SF 7, CR 5
  • Repeater firmware observed in network: v1.16.0
  • Exact USB Serial Companion firmware version: to be confirmed
  • Exact meshcore-ha version: to be confirmed

I can provide logs or run specific tests if needed.

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.