adds first shot add providing 1 wire temps to homeassistant
This commit is contained in:
38
mqtt/send
Executable file
38
mqtt/send
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/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)
|
||||
|
||||
SENSORS+=("${s} ${v}")
|
||||
done
|
||||
|
||||
for ROW in "${SENSORS[@]}"; do
|
||||
ENTRY=( $ROW )
|
||||
SENSOR=${ENTRY[0]}
|
||||
VALUE=${ENTRY[1]/#[0-9][0-9]/&.}
|
||||
|
||||
# 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
|
||||
echo "${ENV_SENSOR_NAME}.value ${VALUE}"
|
||||
else
|
||||
echo "${SENSOR}.value ${VALUE}"
|
||||
fi
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user