add rid and channel to tags to uniqly identify sensors
[rtl433-sensors] / mqtt-rtl_433-influx.sh
1 #!/bin/sh -xe
2
3 mosquitto_sub -t rpi2/rtl433/json \
4 | sed --unbuffered -e 's/^[^,]*,//' -e 's/ : /=/g' -e 's/, /,/g' -e 's/}$//' \
5 -e 's/ "/ /' -e 's/"=/=/g' -e 's/,"/,/g' \
6 -e 's/^ *//' \
7 -e 's/ /\\ /g' \
8 -e 's/,channel="*\([^,"]*\)"*,/,channel="\1",/' \
9 -e 's/,battery="*\([^,"]*\)"*,/,battery="\1",/' \
10 -e 's/,id=\([^,]*\),/,id=\1 /' \
11 -e 's/ rid=\([^,]*\),/,rid=\1 /' \
12 -e 's/ channel=\([^,]*\),/,channel=\1 /' \
13 -e 's/^/rtl_433,/' \
14 -e 's/"//' \
15 -e 's/"//' \
16 | tee /dev/stderr \
17 | tee /dev/shm/433.influx \
18 | mosquitto_pub -t rpi2/rtl_433/influx -l