aten_pdu: Add noop mode to mqtt publish script

This commit is contained in:
Timo Makinen 2025-04-19 20:02:30 +00:00
parent d4d68dc962
commit 20c91fad84

View file

@ -5,6 +5,12 @@ umask 077
community="public"
if [ "${1:-}" = "-n" ]; then
_noop=true
else
_noop=false
fi
mqtt_send() {
topic="$1"
value="$2"
@ -48,7 +54,11 @@ do
for key in Current Power Voltage ; do
topic="home/${location}/${device}/$(echo "$key" | tr '[:upper:]' '[:lower:]')"
value="$(snmp_get "$name" "ATEN-PE-CFG::outlet${key}.${port}")"
mqtt_send "$topic" "$value"
if $_noop ; then
echo "${topic} -> ${value}"
else
mqtt_send "$topic" "$value"
fi
done
done
done