All apps · 0 apps
MQTT Pub and Sub
Plugin from giganode
Overview
Plugin that adds the ability to publish to a mqtt broker or subscribe to a topic.
Readme
View on GitHubunraid-mqtt-pub-sub
Unraid Plugin to add the ability to publish to a mqtt broker or subscribe to a topic.
Installation
Plugins > Install Plugin (or it can be installed from the Community Apps plugin)
https://raw.githubusercontent.com/giganode/unraid-mqtt-pub-sub/master/mqtt-pub-sub.plg
Usage
Preparation
Enter your mqtt credentials under Settings Page.
Settings --> MQTT
Publishing
Old template:
#!/bin/bash
source /boot/config/mqttcredentials
if [[ -z "$MQTT_HOST" || -z "$MQTT_PORT" || -z "$MQTT_USER" || -z "$MQTT_PASSWORD" || -z "$MQTT_CLIENT_ID" ]]; then
echo "Error: Information missing."
exit 1
fi
mosquitto_pub -h $MQTT_HOST -p $MQTT_PORT -i $MQTT_CLIENT_ID -u $MQTT_USER -P $MQTT_PASSWORD -t "$MQTT_CLIENT_ID/sensor/voltage" -m "{\"voltage\": $value}"
New template with shortened command line for publishing:
#!/bin/bash
source /boot/config/mqttcredentials
if [[ -z "$MQTT_HOST" || -z "$MQTT_PORT" || -z "$MQTT_USER" || -z "$MQTT_PASSWORD" || -z "$MQTT_CLIENT_ID" ]]; then
echo "Error: Information missing."
exit 1
fi
MQTT_URL=mqtt://$MQTT_USER:$MQTT_PASSWORD@$MQTT_HOST:$MQTT_PORT/$MQTT_CLIENT_ID
mosquitto_pub -L "$MQTT_URL/sensor/voltage" -m "{\"voltage\": $voltage}"
Subscribing
Start with this template:
#!/bin/bash
source /boot/config/mqttcredentials
if [[ -z "$MQTT_HOST" || -z "$MQTT_PORT" || -z "$MQTT_USER" || -z "$MQTT_PASSWORD" || -z "$MQTT_CLIENT_ID" ]]; then
echo "Fehler: MQTT-Anmeldeinformationen sind unvollständig."
exit 1
fi
mosquitto_sub -h $MQTT_HOST -p $MQTT_PORT -u $MQTT_USER -P $MQTT_PASSWORD -t "$MQTT_CLIENT_ID/sensor/voltage"
Information
In this plugin, bc is included. It's useful when you need to do float calculations in your bash script.
Install MQTT Pub and Sub on Unraid in a few clicks.
Find MQTT Pub and Sub in Community Apps on your Unraid server, review the template, and click Install. Unraid handles the Docker app or plugin setup from the published template.
Open the Apps tab on your Unraid server Search Community Apps for MQTT Pub and Sub Review the template variables and paths Click Install
Categories
Download Statistics
1,731
Total Downloads
10
This Month
24
Avg / Month
Downloads by Month
Loading chart...
Related apps
Explore more like this
Explore allDetails
Repository
https://raw.githubusercontent.com/giganode/unraid-mqtt-pub-sub/master/mqtt-pub-sub.plgLast Updated2026-07-18
First Seen2024-10-25