added sensor name
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 26 Aug 2020 12:28:19 +0000 (14:28 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 26 Aug 2020 12:28:19 +0000 (14:28 +0200)
w1-ds18b20-influx.sh

index 9908150..a3ba047 100755 (executable)
@@ -10,8 +10,10 @@ ls /sys/bus/w1/devices/w1_bus_master*/*-*/w1_slave | while read path ; do
        if [ $temp -ne 85000 ] ; then # 85 is error
                temp=$( echo $temp | awk '{ printf "%.3f\n", $1 / 1000 }' )
                id=$( echo $path | cut -d/ -f 7 )
-               echo "ac_temp,dc=a125,sensor=$id temperature=$temp" >> $influx
+               name=$( grep "^$id" id2name.txt | cut -d' ' -f2 )
+               echo "ac_temp,dc=a125,sensor=$id,name=$name temperature=$temp" >> $influx
                echo $temp > /dev/shm/ds18b20.$id
+               echo $temp > /dev/shm/ds18b20.name.$name
        fi
 done