How to add custom or MQTT sensores? #2811
-
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
|
I think you have almost everything setup. You set the MQTT server values on the MQTT tab, but that is only for publishing data to MQTT. There are separate MQTT settings at the bottom of the Sensors tab for MQTT sensor subscriptions. |
Beta Was this translation helpful? Give feedback.
-
|
so I have the server configured at the bottom of the sensors panel but I too am not getting values... you mention here that the topics are fixed but I noticed you didnt correct the original poster above who was using indi-allsky as his base topic which was #!/bin/bash
# bme280_to_mqtt.sh — Fetch BME280 metrics from Prometheus exporter and publish to MQTT
METRICS_URL="http://localhost:9100/metrics"
MQTT_HOST="192.168.120.254"
MQTT_PORT="1883"
MQTT_TOPIC_PREFIX="sensors/bme280"
# MQTT_USER="user"
# MQTT_PASS="password"
# Fetch metrics
METRICS=$(curl -sf "$METRICS_URL") || { echo "ERROR: Failed to fetch metrics from $METRICS_URL"; exit 1; }
# Parse values
HUMIDITY=$(echo "$METRICS" | awk '/^bme280_humidity_percent / {print $2}')
PRESSURE=$(echo "$METRICS" | awk '/^bme280_pressure_hpa / {print $2}')
TEMPERATURE=$(echo "$METRICS" | awk '/^bme280_temperature_celsius / {print $2}')
# Bail if any value is empty
for VAR in HUMIDITY PRESSURE TEMPERATURE; do
[[ -z "${!VAR}" ]] && { echo "ERROR: Could not parse $VAR"; exit 1; }
done
# Build mosquitto_pub args (add -u/-P if auth is needed)
MQTT_ARGS=(-h "$MQTT_HOST" -p "$MQTT_PORT" -r)
# MQTT_ARGS+=(-u "$MQTT_USER" -P "$MQTT_PASS")
mosquitto_pub "${MQTT_ARGS[@]}" -t "${MQTT_TOPIC_PREFIX}/Topic 1" -m "$HUMIDITY"
mosquitto_pub "${MQTT_ARGS[@]}" -t "${MQTT_TOPIC_PREFIX}/Topic 2" -m "$PRESSURE"
mosquitto_pub "${MQTT_ARGS[@]}" -t "${MQTT_TOPIC_PREFIX}/Topic 3" -m "$TEMPERATURE"
echo "Published — humidity: $HUMIDITY% | pressure: ${PRESSURE}hPa | temp: ${TEMPERATURE}°C"I tried setting the pin to |
Beta Was this translation helpful? Give feedback.
-
|
@aaronwmorris sorry if its not ok to post a follow up question in a discussion thats been marked as "answered".... |
Beta Was this translation helpful? Give feedback.







I think you have almost everything setup. You set the MQTT server values on the MQTT tab, but that is only for publishing data to MQTT. There are separate MQTT settings at the bottom of the Sensors tab for MQTT sensor subscriptions.