mirror of
https://github.com/tcivie/meshtastic-metrics-exporter.git
synced 2025-03-05 20:52:02 -08:00
Added support for multiple topics (comma seperated)
This commit is contained in:
parent
6139b7a968
commit
c9390ee417
2
.env
2
.env
|
@ -13,7 +13,7 @@ MQTT_PORT=1883
|
||||||
MQTT_USERNAME=meshdev
|
MQTT_USERNAME=meshdev
|
||||||
MQTT_PASSWORD=large4cats
|
MQTT_PASSWORD=large4cats
|
||||||
MQTT_KEEPALIVE=60
|
MQTT_KEEPALIVE=60
|
||||||
MQTT_TOPIC='msh/#'
|
MQTT_TOPIC='msh/EU_868/#,msh/US/#'
|
||||||
MQTT_IS_TLS=false
|
MQTT_IS_TLS=false
|
||||||
|
|
||||||
# MQTT protocol version (default: MQTTv5) the public MQTT server supports MQTTv311
|
# MQTT protocol version (default: MQTTv5) the public MQTT server supports MQTTv311
|
||||||
|
|
4
main.py
4
main.py
|
@ -30,7 +30,9 @@ def release_connection(conn):
|
||||||
|
|
||||||
def handle_connect(client, userdata, flags, reason_code, properties):
|
def handle_connect(client, userdata, flags, reason_code, properties):
|
||||||
print(f"Connected with result code {reason_code}")
|
print(f"Connected with result code {reason_code}")
|
||||||
client.subscribe(os.getenv('MQTT_TOPIC', 'msh/israel/#'))
|
topics = os.getenv('MQTT_TOPIC', 'msh/israel/#').split(',')
|
||||||
|
topics_tuples = [(topic, 0) for topic in topics]
|
||||||
|
client.subscribe(topics_tuples)
|
||||||
|
|
||||||
|
|
||||||
def update_node_status(node_number, status):
|
def update_node_status(node_number, status):
|
||||||
|
|
Loading…
Reference in a new issue