12 Commits

Author SHA1 Message Date
claude
f9dd8bc1c9 Point documentation/issue_tracker at the actual Gitea repo
Replace the placeholder github.com/tewris URLs (guessed from the user's email
domain) with the real repository on git.stalkersvr.ru.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-22 21:48:47 +03:00
claude
027ff685b7 Multiple identities via config subentries + regenerate + editable name
Refactor from one-entry-one-identity to a hub config entry (shared RNS stack)
plus config subentries of type "identity", each an independent LXMF identity
with its own LXMRouter, address, device and entities. This is required because
LXMRouter allows only one delivery identity per instance.

- ReticulumStack: owns the single process-wide RNS instance, peer discovery and
  interface telemetry (hub device).
- IdentityManager: one per subentry, its own LXMRouter/identity/destination and
  delivery callback (identity device). Signal handlers suppressed and atexit
  handlers tamed for each router too.
- Config subentry flow (add / reconfigure identity); a first identity is seeded
  on stack creation. Editable announce display name = subentry title.
- Per-identity "Regenerate identity" button: new address + re-announce
  (clears the router's single delivery destination first).
- Services and events gain an "identity" field to target/distinguish identities.
- Per-identity assist bridge, greeting-when-assist-off, allow-list, notify,
  announce/sync buttons, message counters; hub-level connectivity/telemetry/peers.

Verified against current HA config_entries/entity_platform/selector and RNS/LXMF
sources. Docs and en/ru translations updated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-22 20:29:05 +03:00
claude
c3b98043f7 Reinstate greeting as an auto-reply used only when Assist is off
The greeting option returns, but it is now sent as an automatic reply to
incoming messages only when "Route incoming messages to Assist" is disabled,
so senders get an acknowledgement instead of silence. When Assist handles
messages the greeting is not used. Blank disables it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-22 19:43:36 +03:00
claude
47ac2ac487 Remove the greeting feature entirely
Drops the CONF_GREETING option, the first-contact greeting logic and its
RuntimeData state, and all related strings/translations/README text. Any
greeting value left in an existing entry's options is simply ignored.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-22 19:38:36 +03:00
claude
9ae6bb09c4 Count sent messages at send time; implement first-contact greeting
- messages_sent now increments when a message is queued (async_send_message),
  not only when a delivery proof returns. LXMessage's delivery callback only
  fires on a returned proof (LXMessage.py ~566), which many peers/methods never
  send, so the "Messages sent" sensor was stuck at 0 for messages that were
  actually delivered. The delivery callback now only emits the event.
- Implement the previously-inert "greeting" option: send it automatically the
  first time each sender contacts HA (tracked per sender in RuntimeData).
- Clarify the notify entity (rename to "Send message" / "Отправить сообщение")
  and document greeting + notify in strings/translations/README.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-22 19:28:26 +03:00
claude
3be19028b1 Run interface poll on the event loop (fix async_dispatcher_send off-thread)
The interface-status poll was registered as a plain lambda, so
async_track_time_interval ran it in an executor thread, where its
_push_state()->async_dispatcher_send() call tripped HA's thread-safety guard.

Make refresh_interface_status a @callback (it only reads fast in-memory
interface attributes) and pass it to async_track_time_interval directly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-22 19:19:21 +03:00
claude
66b5d4a64a Fix thread-unsafe state writes; use conversation-agent dropdown
- entity.py: decorate the dispatcher target _handle_update with @callback so it
  runs on the event loop. Without it, async_dispatcher_send offloaded the plain
  sync callback to an executor thread, and async_write_ha_state raised
  "calls async_write_ha_state from a thread other than the event loop".
- config_flow.py: replace the free-text Assist agent field with
  ConversationAgentSelector (a proper agent dropdown), and use LanguageSelector
  for the language field.
- README: clarify that the built-in Assist agent only handles device commands;
  an LLM conversation agent is required for free-form chat.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-22 19:13:08 +03:00
claude
f02d48777b Suppress signal handlers for the whole init (LXMF.LXMRouter too)
v1.0.2 only neutralised signal.signal around RNS.Reticulum(), but
LXMF.LXMRouter.__init__ also calls signal.signal(SIGINT/SIGTERM) (LXMRouter.py
308-309), so init still crashed with "signal only works in main thread of the
main interpreter" when the router was constructed in the executor thread.

Wrap the entire _start init (both constructors) with signal.signal neutralised
instead of just the RNS constructor. Confirmed via upstream source that the
only relevant signal registration sites are RNS/Reticulum.py:366-367 and
LXMF/LXMRouter.py:308-309, both module-attribute calls, so the module-level
patch intercepts both.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-22 18:53:30 +03:00
claude
a80f65c442 Embed RNS cleanly: fix signal-thread crash, tame atexit/stdout, persist on stop
Root cause of setup failure: Reticulum.__init__ calls signal.signal() with no
main-thread guard, but we (correctly) initialise off the event loop in an
executor thread, where signal.signal() raises ValueError. It failed after
setting the __instance singleton, which both broke setup and caused the
"Attempt to reinitialise Reticulum" error on every retry.

- Temporarily neutralise signal.signal during RNS init so init completes in the
  executor, and so RNS does not hijack HA's SIGINT/SIGTERM (needed for clean
  shutdown under Kubernetes).
- Unregister RNS's and LXMF's atexit exit handlers, which otherwise persist
  state with blocking file I/O on the event-loop thread and detach HA's
  stdout/stderr at interpreter exit (the loop-blocking warnings seen in logs).
- Persist RNS/LXMF state ourselves off-loop on the homeassistant_stop event.

Documents the remaining non-daemon RNS worker threads as a known shutdown note.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-22 18:46:06 +03:00
claude
f75235f9df Fix "Attempt to reinitialise Reticulum" on setup/retry
RNS.Reticulum.__init__ sets its internal singleton before it can fail partway
through init, which left our module-level _RNS_INSTANCE cache out of sync (None)
while RNS believed it was already running. Every setup retry then hit RNS's
reinit guard and raised "Attempt to reinitialise Reticulum, when it was already
running".

Use RNS.Reticulum.get_instance() as the source of truth and adopt an existing
instance instead of re-creating it (with an OSError fallback that also adopts).
Also cache and reuse the LXMF router, delivery destination, identity and
announce handler across reloads so a reload never spawns a duplicate router or
stacks announce handlers.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-22 18:30:43 +03:00
claude
b40c527515 Add Reticulum/LXMF integration for Home Assistant
Custom integration connecting Home Assistant to a Reticulum network over a
TCPClientInterface and exchanging LXMF messages, with an Assist conversation
bridge, notify entity, sensors (incl. interface telemetry), buttons, services,
bus events and device triggers.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-22 18:08:12 +03:00
22408c2bd5 Initial commit 2026-07-22 12:27:01 +00:00