mirror of
https://github.com/meshtastic/meshtastic.git
synced 2024-12-25 05:34:11 -08:00
commit
4daa4b421c
|
@ -44,7 +44,7 @@ sensor:
|
|||
|
||||
- name: "Node 1 Battery Voltage"
|
||||
unique_id: "node_1__battery_voltage"
|
||||
state_topic: "msh/2/json/LongFast/!67ea9400"
|
||||
state_topic: "msh/US/2/json/LongFast/!67ea9400"
|
||||
state_class: measurement
|
||||
value_template: >-
|
||||
{% if value_json.from == 4038675309 and
|
||||
|
@ -60,7 +60,7 @@ sensor:
|
|||
|
||||
- name: "Node 1 Battery Percent"
|
||||
unique_id: "node_1_battery_percent"
|
||||
state_topic: "msh/2/json/LongFast/!67ea9400"
|
||||
state_topic: "msh/US/2/json/LongFast/!67ea9400"
|
||||
state_class: measurement
|
||||
value_template: >-
|
||||
{% if value_json.from == 4038675309 and value_json.payload.battery_level is defined %}
|
||||
|
@ -73,7 +73,7 @@ sensor:
|
|||
|
||||
- name: "Node 1 ChUtil"
|
||||
unique_id: "node_1_chutil"
|
||||
state_topic: "msh/2/json/LongFast/!67ea9400"
|
||||
state_topic: "msh/US/2/json/LongFast/!67ea9400"
|
||||
state_class: measurement
|
||||
value_template: >-
|
||||
{% if value_json.from == 4038675309 and value_json.payload.channel_utilization is defined %}
|
||||
|
@ -85,7 +85,7 @@ sensor:
|
|||
|
||||
- name: "Node 1 AirUtilTX"
|
||||
unique_id: "node_1_airutiltx"
|
||||
state_topic: "msh/2/json/LongFast/!67ea9400"
|
||||
state_topic: "msh/US/2/json/LongFast/!67ea9400"
|
||||
state_class: measurement
|
||||
value_template: >-
|
||||
{% if value_json.from == 4038675309 and value_json.payload.air_util_tx is defined %}
|
||||
|
@ -104,7 +104,7 @@ sensor:
|
|||
|
||||
- name: "Node 1 Temperature"
|
||||
unique_id: "node_1_temperature"
|
||||
state_topic: "msh/2/json/LongFast/!67ea9400"
|
||||
state_topic: "msh/US/2/json/LongFast/!67ea9400"
|
||||
state_class: measurement
|
||||
value_template: >-
|
||||
{% if value_json.from == 4038675309 and value_json.payload.temperature is defined %}
|
||||
|
@ -121,7 +121,7 @@ sensor:
|
|||
|
||||
- name: "Node 1 Humidity"
|
||||
unique_id: "node_1_humidity"
|
||||
state_topic: "msh/2/json/LongFast/!67ea9400"
|
||||
state_topic: "msh/US/2/json/LongFast/!67ea9400"
|
||||
state_class: measurement
|
||||
value_template: >-
|
||||
{% if value_json.from == 4038675309 and value_json.payload.relative_humidity is defined %}
|
||||
|
@ -134,7 +134,7 @@ sensor:
|
|||
|
||||
- name: "Node 1 Pressure"
|
||||
unique_id: "node_1_pressure"
|
||||
state_topic: "msh/2/json/LongFast/!67ea9400"
|
||||
state_topic: "msh/US/2/json/LongFast/!67ea9400"
|
||||
state_class: measurement
|
||||
value_template: >-
|
||||
{% if value_json.from == 4038675309 and value_json.payload.barometric_pressure is defined %}
|
||||
|
@ -149,7 +149,7 @@ sensor:
|
|||
|
||||
- name: "Node 1 Gas Resistance"
|
||||
unique_id: "node_1_gas_resistance"
|
||||
state_topic: "msh/2/json/LongFast/!67ea9400"
|
||||
state_topic: "msh/US/2/json/LongFast/!67ea9400"
|
||||
state_class: measurement
|
||||
value_template: >-
|
||||
{% if value_json.from == 4038675309 and value_json.payload.gas_resistance is defined %}
|
||||
|
@ -167,7 +167,7 @@ sensor:
|
|||
```yaml
|
||||
- name: "Node 1 Messages"
|
||||
unique_id: "node_1_messages"
|
||||
state_topic: "msh/2/json/LongFast/!67ea9400"
|
||||
state_topic: "msh/US/2/json/LongFast/!67ea9400"
|
||||
value_template: >-
|
||||
{% if value_json.from == 4038675309 and value_json.payload.text is defined %}
|
||||
{{ value_json.payload.text }}
|
||||
|
@ -187,7 +187,7 @@ alias: Update Node 1 location
|
|||
description: Update Meshtastic node when corresponding MQTT messages are seen.
|
||||
trigger:
|
||||
- platform: mqtt
|
||||
topic: msh/2/json/LongFast/!67ea9400
|
||||
topic: msh/US/2/json/LongFast/!67ea9400
|
||||
payload: "on"
|
||||
value_template: |-
|
||||
{% if value_json.from == 4038675309 and
|
||||
|
@ -216,7 +216,7 @@ Home Assistant entities can be created for any data type that is published to MQ
|
|||
|
||||
### Configure With Your Topic & Node ID's
|
||||
|
||||
- In every entity, replace `msh/2/json/LongFast/!67ea9400` with the topic your node publishes to. In this example, `!67ea9400` refers to the node that has mqtt enabled on the mesh and is publishing to the broker.
|
||||
- In every entity, replace `msh/US/2/json/LongFast/!67ea9400` with the topic your node publishes to. In this example, `!67ea9400` refers to the node that has mqtt enabled on the mesh and is publishing to the broker.
|
||||
|
||||
- In every entity replace `4038675309` with the node number of the radio you wish to monitor. In this example `4038675309` is the node on the mesh with environment sensors and telemetry that I wish to observe. Node numbers can be found by monitoring the output in MQTT Explorer, listening with the MQTT addon or by using the Python CLI with `meshtastic --info`.
|
||||
|
||||
|
@ -227,7 +227,7 @@ Copy and paste these entities then change `name`, `unique_id`, `from`, and `stat
|
|||
```yaml
|
||||
- name: "Node 2 Messages"
|
||||
unique_id: "node_2_messages"
|
||||
state_topic: "msh/2/json/LongFast/!67ea9400"
|
||||
state_topic: "msh/US/2/json/LongFast/!67ea9400"
|
||||
value_template: >-
|
||||
{% if value_json.from == 695318008 and value_json.payload.text is defined %}
|
||||
{{ value_json.payload.text }}
|
||||
|
@ -279,7 +279,7 @@ Add the following code to your automations.yaml file. Be sure to modify the `to
|
|||
description: any message with an @Tropho will send to mobile device
|
||||
trigger:
|
||||
- platform: mqtt
|
||||
topic: msh/2/json/LongFast/!67ea9400
|
||||
topic: msh/US/2/json/LongFast/!67ea9400
|
||||
condition:
|
||||
- condition: template
|
||||
value_template: "{{ trigger.payload_json.payload.text | regex_search('@Tropho') }}"
|
||||
|
@ -336,7 +336,7 @@ This automation will check the send box for changes. After typing a message, ei
|
|||
data:
|
||||
qos: 0
|
||||
retain: false
|
||||
topic: msh/2/json/mqtt/!67ea9400
|
||||
topic: msh/US/2/json/mqtt/!67ea9400
|
||||
payload: >-
|
||||
{"from":1743426560,"type":"sendtext","payload":"{{
|
||||
states('input_text.meshtastic_send_box') }}"}
|
||||
|
|
|
@ -30,19 +30,16 @@ When MQTT is enabled, the Meshtastic device simply uplinks and/or downlinks ever
|
|||
|
||||
### MQTT [Topics](https://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices)
|
||||
|
||||
If no specific [root topic](/docs/configuration/module/mqtt#root-topic) is configured, the default root topic will be `msh/`.
|
||||
Each device that is connected to MQTT will publish its MQTT state (`online`/`offline`) to:
|
||||
If no specific [root topic](/docs/configuration/module/mqtt#root-topic) is configured, the default root topic will be `msh/REGION`.
|
||||
|
||||
`msh/2/stat/USERID`, where `USERID` is the node ID of the gateway device (the one connected to MQTT).
|
||||
|
||||
For each channel where uplink and/or downlink is enabled, two other topics might be used:
|
||||
For each channel where uplink and/or downlink is enabled, two topics might be used:
|
||||
|
||||
#### Protobufs topic
|
||||
A gateway node will uplink and/or downlink raw ([protobuf](https://developers.google.com/protocol-buffers)) MeshPackets to the topic:
|
||||
|
||||
`msh/2/e/CHANNELNAME/USERID`, where `CHANNELNAME` is the name of the channel (firmware versions prior to 2.3.0 will publish to a topic with `/c/` in the place of `/e/`).
|
||||
`msh/REGION/2/e/CHANNELNAME/USERID`, where `CHANNELNAME` is the name of the channel (firmware versions prior to 2.3.0 will publish to a topic with `/c/` in the place of `/e/`).
|
||||
|
||||
For example: `msh/2/e/LongFast/!abcd1234`
|
||||
For example: `msh/US/2/e/LongFast/!abcd1234`
|
||||
|
||||
The payload is a raw protobuf, whose definitions for Meshtastic can be found [here](https://github.com/meshtastic/protobufs/blob/master/meshtastic). Reference guides for working with protobufs in several popular programming languages can be found [here](https://protobuf.dev/reference/). Looking at the MQTT traffic with a program like `mosquitto_sub` will tell you it's working, but you won't get much useful information out of it. For example:
|
||||
|
||||
|
@ -61,7 +58,7 @@ JSON is not supported on the nRF52 platform.
|
|||
|
||||
If [JSON is enabled](/docs/configuration/module/mqtt#json-enabled), packets from the following [port numbers](/docs/development/firmware/portnum) are serialized to JSON: `TEXT_MESSAGE_APP`, `TELEMETRY_APP`, `NODEINFO_APP`, `POSITION_APP`, `WAYPOINT_APP`, `NEIGHBORINFO_APP`, `TRACEROUTE_APP`, `DETECTION_SENSOR_APP`, `PAXCOUNTER_APP` and `REMOTE_HARDWARE_APP`. These are then forwarded to the topic:
|
||||
|
||||
`msh/2/json/CHANNELNAME/USERID`.
|
||||
`msh/US/2/json/CHANNELNAME/USERID`.
|
||||
|
||||
An example of a received `NODEINFO_APP` message:
|
||||
|
||||
|
@ -103,9 +100,9 @@ If the message received contains valid JSON in the payload, the JSON is deserial
|
|||
|
||||
|
||||
#### JSON downlink to instruct a node to send a message
|
||||
You can also send a JSON message to the topic `msh/2/json/mqtt/` to instruct a gateway node to send a message to the mesh.
|
||||
You can also send a JSON message to the topic `msh/US/2/json/mqtt/` to instruct a gateway node to send a message to the mesh.
|
||||
|
||||
To make this work, ensure that your node has a Meshtastic channel configured called "mqtt". Enable Downlink. The PSK can be random and doesn't matter. This channel allows the node to listen to messages on the `msh/2/json/mqtt/` topic.
|
||||
To make this work, ensure that your node has a Meshtastic channel configured called "mqtt". Enable Downlink. The PSK can be random and doesn't matter. This channel allows the node to listen to messages on the `msh/US/2/json/mqtt/` topic.
|
||||
|
||||
Reboot your device after creating this channel.
|
||||
|
||||
|
|
Loading…
Reference in a new issue