should be working now

This commit is contained in:
2024-10-20 09:01:31 +02:00
parent 1ae30d5d91
commit 0eefa1772a
4 changed files with 32 additions and 31 deletions

View File

@@ -1,11 +1,11 @@
#!/bin/bash
# -*- sh -*-
# -*- bash -*-
: << =cut
=head1 NAME
433mhz - Plugin to capture readings from wireless sensors via serial
1wire - Plugin to capture readings from 1wire sensors on raspberry pi
=head1 NOTES
@@ -32,8 +32,7 @@ if [ "$1" = "autoconf" ]; then
fi
if [ "$1" = "config" ]; then
echo 'graph_title Wireless temperature sensor readings'
echo 'graph_title 1wire sensor readings'
echo 'graph_args --base 1 -l 0 '
echo 'graph_scale no'
echo 'graph_vlabel °C'
@@ -45,19 +44,22 @@ if [ "$1" = "config" ]; then
exit 0
fi
SENSORS=()
CMD="for f in $(find -L /sys/bus/w1/devices/ -maxdepth 2 -name temperature); do s=${f%/*}; s=${s##*-}; v=$(cat $f); echo "${s} ${v}"; done"
FILES=$(find -L /sys/bus/w1/devices/ -maxdepth 2 -name temperature)
for f in $FILES
do
s=${f%/*}
s=${s##*-}
v=$(cat $f)
SENSORS+=("${s} ${v}")
done
IFS=$'\n'
SENSORS=( $(eval $CMD) )
echo $SENSORS
IFS=' '
for ROW in "${SENSORS[@]}"; do
ENTRY=( $ROW )
SENSOR=${ENTRY[0]}
VALUE=${ENTRY[1]}
VALUE=${ENTRY[1]/#[0-9][0-9]/&.}
# Overrides SENSOR - Example: env.sensor_0_0 Batterie
ENV_SENSOR_VAR_NAME="alias_${SENSOR}"
@@ -69,7 +71,3 @@ for ROW in "${SENSORS[@]}"; do
echo "${SENSOR}.value ${VALUE}"
fi
done
#echo "Vorratskammer.value $TEMP"