37 lines
882 B
Bash
Executable File
37 lines
882 B
Bash
Executable File
#!/bin/bash
|
|
|
|
source ./1wire
|
|
|
|
FILES=$(find -L /sys/bus/w1/devices/ -maxdepth 2 -name temperature)
|
|
|
|
SENSORS=()
|
|
for f in $FILES
|
|
do
|
|
s=${f%/*}
|
|
s=${s##*-}
|
|
v=$(cat $f)
|
|
|
|
SENSOR=${s}
|
|
VALUE=${v/#[0-9][0-9]/&.}
|
|
VALUE=$(echo "scale=1; (10*($VALUE+0.5))/10" | /usr/bin/bc)
|
|
|
|
# Overrides SENSOR - Example: env.sensor_0_0 Batterie
|
|
ENV_SENSOR_VAR_NAME="alias_${SENSOR}"
|
|
ENV_SENSOR_NAME=${!ENV_SENSOR_VAR_NAME}
|
|
|
|
if [ -n "${ENV_SENSOR_NAME}" ]; then
|
|
SENSOR="${ENV_SENSOR_NAME}"
|
|
fi
|
|
|
|
echo "${SENSOR}.value ${VALUE}"
|
|
SENSOR_NAME="${SENSOR}" SENSOR_UNIT="°C" ./mqtt ${VALUE}
|
|
done
|
|
|
|
|
|
|
|
|
|
#SENSOR_NAME="voltage" SENSOR_UNIT="mV" DEVICE_NAME="heat-pi ina219" ./mqtt $VOLTAGE
|
|
#SENSOR_NAME="current" SENSOR_UNIT="mA" DEVICE_NAME="heat-pi ina219" ./mqtt $CURRENT
|
|
#SENSOR_NAME="power" SENSOR_UNIT="mW" DEVICE_NAME="heat-pi ina219" ./mqtt $POWER
|
|
|