1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 02:33:18 +00:00

tasmota: add temperature and allow multiple DS18B20 sensors

This commit is contained in:
Tim Connors 2024-09-28 21:01:35 +10:00
parent dde29e9982
commit f1e354ebd3

View file

@ -84,6 +84,11 @@ if [ "$1" = "suggest" ]; then
echo "${device}_${i}"
done
done
nodeattr -n '(tasmota || beken) && temperature' | while read -r device ; do
for i in temperature ; do
echo "${device}_${i}"
done
done
nodeattr -n '(tasmota || beken) && DS18B20' | while read -r device ; do
for i in DS18B20 ; do
echo "${device}_${i}"
@ -126,7 +131,7 @@ voltage() {
echo "$axis.label Voltage"
else
get_status 8 ".StatusSNS.ENERGY.Voltage"
get_status 8 '.StatusSNS["ENERGY"].Voltage'
echo "$axis.value $res"
fi
}
@ -140,7 +145,7 @@ current() {
echo "$axis.label Current"
else
get_status 8 ".StatusSNS.ENERGY.Current"
get_status 8 '.StatusSNS["ENERGY"].Current'
echo "$axis.value $res"
fi
}
@ -160,7 +165,7 @@ power() {
done
else
for axis in ApparentPower ReactivePower Power ; do
get_status 8 ".StatusSNS.ENERGY.$axis"
get_status 8 '.StatusSNS["ENERGY"].$axis'
echo "$axis.value $res"
done
fi
@ -177,7 +182,7 @@ powerfactor() {
echo "$axis.max 1"
echo "$axis.label Power Factor"
else
get_status 8 ".StatusSNS.ENERGY.Factor"
get_status 8 '.StatusSNS["ENERGY"].Factor'
echo "$axis.value $res"
fi
}
@ -192,12 +197,12 @@ energy() {
echo "$axis.label Energy"
echo "$axis.draw AREA"
else
get_status 8 ".StatusSNS.ENERGY.Total"
get_status 8 '.StatusSNS["ENERGY"].Total'
echo "$axis.value $res"
fi
}
DS18B20() {
temperature() {
axis=Temperature
if [ "$1" = "config" ]; then
echo "graph_title Tasmota Temperature: $DEVICE"
@ -208,11 +213,41 @@ DS18B20() {
echo "$axis.type GAUGE"
#echo "$axis.min 0"
else
get_status 10 ".StatusSNS.DS18B20.Temperature"
get_status 10 '.StatusSNS["ANALOG"].Temperature1'
echo "$axis.value $res"
fi
}
DS18B20() {
if [ "$1" = "config" ]; then
echo "graph_title Tasmota Temperature: $DEVICE"
echo "graph_args --base 1000"
echo "graph_vlabel °C"
fi
for i in '' `seq 1 9` ; do
axis=Temperature$i
if [ "$1" = "config" ]; then
get_status 10 ".StatusSNS[\"DS18B20${i:+-$i}\"].Temperature"
if [ "$res" != U ] ; then
echo "$axis.label Temperature${i:+ $i}"
echo "$axis.type GAUGE"
#echo "$axis.min 0"
fi
else
get_status 10 ".StatusSNS[\"DS18B20${i:+-$i}\"].Temperature"
if [ "$res" != U ] ; then # should only echo U if there's
# not a valid temperature where
# there once was, but we don't
# immediately know which ones
# are intended to be valid
echo "$axis.value $res"
fi
fi
done
}
SCD40() {
axis=CO2
if [ "$1" = "config" ]; then
@ -223,7 +258,7 @@ SCD40() {
echo "$axis.label Carbon Dioxide"
echo "$axis.type GAUGE"
else
get_status 8 ".StatusSNS.SCD40.CarbonDioxide"
get_status 8 '.StatusSNS["SCD40"].CarbonDioxide'
echo "$axis.value $res"
fi
}
@ -245,7 +280,7 @@ PMS5003() {
for v in 'PB1="PB1"' 'PB2_5="PB2.5"' 'PB10="PB10"' ; do
axis=$( echo "$v" | cut -d= -f 1 )
field=$( echo "$v" | cut -d= -f 2 )
get_status 8 ".StatusSNS.PMS5003.$field"
get_status 8 '.StatusSNS["PMS5003"].$field'
echo "$axis.value $res"
done
fi
@ -271,7 +306,7 @@ millivolts() {
echo "$axis.label V"
echo "$axis.type GAUGE"
else
get_status 8 ".StatusSNS.ANALOG.Range"
get_status 8 '.StatusSNS["ANALOG"].Range'
if [ "$res" != U ] ; then
res=$( echo "$res" | awk '{printf "%0.3f", $1/1000}' )
fi
@ -288,7 +323,7 @@ switch() {
for v in POWER POWER{1,2,3,4,5,6,7,8,9} ; do
axis=$( echo "$v" | cut -d= -f 1 )
lab=$( echo "$v" | cut -d= -f 2 )
get_status 11 ".StatusSTS.$v"
get_status 11 ".StatusSTS[\"$v\"]"
if [ "$res" != U ] || [ -e $MUNIN_PLUGSTATE/tasmota/$DEVICE.$FUNCTION.$v.seen ] ; then
# if we've ever seen an axis, then we want to keep
@ -329,7 +364,7 @@ dimmer() {
for v in Channel{1,2,3,4} ; do
axis=$( echo "$v" | cut -d= -f 1 )
lab=$( echo "$v" | cut -d= -f 2 )
get_status 11 ".StatusSTS.$v"
get_status 11 ".StatusSTS[\"$v\"]"
if [ "$res" != U ] || [ -e $MUNIN_PLUGSTATE/tasmota/$DEVICE.$FUNCTION.$v.seen ] ; then
# if we've ever seen an axis, then we want to keep
@ -354,7 +389,7 @@ dimmer() {
}
case "$FUNCTION" in
voltage|power|powerfactor|current|energy|DS18B20|SCD40|PMS5003|millivolts|switch|dimmer)
voltage|power|powerfactor|current|energy|temperature|DS18B20|SCD40|PMS5003|millivolts|switch|dimmer)
$FUNCTION "$1"
;;
*)