Skip to content

Extend meshtastic_api_text_message for additional data#126

Open
heggi wants to merge 1 commit intomeshtastic:mainfrom
heggi:extend_notify
Open

Extend meshtastic_api_text_message for additional data#126
heggi wants to merge 1 commit intomeshtastic:mainfrom
heggi:extend_notify

Conversation

@heggi
Copy link

@heggi heggi commented Dec 3, 2025

Added to meshtastic_api_text_message fields hops_count, rx_rssi and rx_snr.
Using me in automatization auto replay for direct message

Example:

alias: Echo on Direct Message
description: Only from gateway with node id __masked__
triggers:
  - trigger: event
    event_type: meshtastic_api_text_message
    event_data:
      data:
        to:
          node: __masked__
          channel: null
        gateway: __masked__
conditions: []
actions:
  - delay:
      seconds: 1
  - action: meshtastic.send_text
    data:
      ack: true
      text: >-
        Hops: {{ trigger.event.data.data.hops_count }},  
        rssi: {{ trigger.event.data.data.rx_rssi }}dBm,  
        snr: {{ trigger.event.data.data.rx_snr }}dB. 

        ECHO: {{ trigger.event.data.data.message }}
      from: "{{ trigger.event.data.data.gateway }}"
      to: "{{ trigger.event.data.data.from }}"
mode: single

@CLAassistant
Copy link

CLAassistant commented Dec 3, 2025

CLA assistant check
All committers have signed the CLA.

@megadimich
Copy link

When will this be implemented? Where can I download this version?

@GoaMind
Copy link

GoaMind commented Dec 8, 2025

@heggi mb you would like to have more data: #120 =)

@megadimich you already can use it by pulling the branch directly.

I was able to implement this automation with my branch from #120. Automation replies automatically went got message contains !test message

Example:

alias: "Meshtastic: !test reply"
description: Test reply
triggers:
  - domain: meshtastic
    device_id: XXX
    type: channel_message.received
    entity_id: meshtastic.gateway_XXX_channel_secondary
    trigger: device
    id: message_recieved_from_XXX
conditions:
  - condition: template
    value_template: |-
      {{ trigger.event.data.message | lower
               is search('(^|\\s)!test(\\s|$)') }}
actions:
  - action: notify.send_message
    data:
      message: >-
        {%- set msg = trigger.event.data.message | default('') -%}


        @{{ trigger.event.data.sender_short_name }} got your test message: "{{
        msg[:40] }}{{ '…' if msg|length > 40 else '' }}" near Stroomi rand at 

        {%- set tf = trigger.event.time_fired -%}

        {%- set tf_str = tf if tf is string else tf.isoformat() -%}

        {%- set fixed = tf_str[:-3] ~ tf_str[-2:] -%}

        {%- set dt = strptime(fixed, '%Y-%m-%dT%H:%M:%S.%f%z')
                    if 'T' in fixed
                    else strptime(fixed, '%Y-%m-%d %H:%M:%S.%f%z') -%}
         {{ as_local(dt).strftime(' %H:%M:%S %Z (UTC%z)') }}

        {%- if trigger.event.data.rx_snr is defined %}

        SNR: {{ trigger.event.data.rx_snr }}dB

        {%- endif %}

        {%- if trigger.event.data.rx_rssi is defined %} 

        RSSI: {{ trigger.event.data.rx_rssi }}dBm

        {%- endif %}

        {%- if trigger.event.data.hop_count is defined %}

        Hops: {{ trigger.event.data.hop_count }}

        {%- endif %}
    target:
      entity_id:
        - notify.mesh_channel_longfast
mode: single

Resulting message looks like this:

@mcM2 got your test message: "!test" near Stroomi rand at 18:39:27 EET (UTC+0200) 
SNR: 4.5dB 
RSSI: -61dBm 
Hops: 2

@megadimich
Copy link

megadimich commented Dec 9, 2025

Super!!!

@megadimich
Copy link

I couldn't find it: sender_short_name
Please provide a link where I can download this compilation. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments