create influx format in mqtt which telegraf will pick up
[rtl433-sensors] / rtl433-influx.sh
1 #!/bin/sh -xe
2
3 rtl_433 -G -F json -U \
4 | tee /dev/shm/433.json \
5 | sed --unbuffered -e 's/^[^,]*,//' -e 's/ : /=/g' -e 's/, /,/g' -e 's/}$//' \
6 -e 's/ "/ /' -e 's/"=/=/g' -e 's/,"/,/g' \
7 -e 's/^ *//' \
8 -e 's/ /\\\\ /g' \
9 -e 's/,channel="*\([^,"]*\)"*,/,channel="\1",/' \
10 -e 's/,battery="*\([^,"]*\)"*,/,battery="\1",/' \
11 -e 's/,id=\([^,]*\),/,id=\1 /' \
12 -e 's/^/rtl433,/' \
13 -e 's/"//' \
14 -e 's/"//' \
15 | tee /dev/stderr \
16 | while read line ; do
17         curl -v -s -XPOST "http://10.60.0.89:8086/write?db=test" --data-binary "$line"
18 done
19