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>
This commit is contained in:
claude
2026-07-22 19:28:26 +03:00
parent 3be19028b1
commit 9ae6bb09c4
7 changed files with 32 additions and 12 deletions

View File

@@ -362,9 +362,15 @@ class ReticulumManager:
) -> str:
"""Send an LXMF message. Returns the message hash (hex)."""
dest_hash = self._normalise_hash(destination)
return await self.hass.async_add_executor_job(
message_hash = await self.hass.async_add_executor_job(
self._send, dest_hash, content, title, method, fields
)
# Count at send time. The delivery callback only fires on a returned
# proof, which many peers/methods never send, so counting there would
# leave this stuck at 0 even for messages that were delivered fine.
self.state.messages_sent += 1
self._push_state()
return message_hash
def _send(
self,
@@ -535,10 +541,10 @@ class ReticulumManager:
@callback
def _on_outbound_delivered(self, message: Any) -> None:
# messages_sent is counted at send time (see async_send_message); this
# callback only confirms delivery, so it just emits the event.
import RNS # noqa: PLC0415
self.state.messages_sent += 1
self._push_state()
_fire_event(
self.hass,
"delivered",