Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Use this variable when creating a container to specify the MQTT broker host.
- MQTT_HOST="127.0.0.1"
- # A simple script that will receive events from a RTL433 SDR
- # Author: Marco Verleun <marco@marcoach.nl>
- # Version 2.0: Adapted for the new output format of rtl_433
- # Remove hash on next line for debugging
- #set -x
- export LANG=C
- PATH="/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"
- #
- # Start the listener and enter an endless loop
- #
- stdbuf -i0 -o0 -e0 /usr/local/bin/rtl_433 -F json -C customary -R 39 | stdbuf -i0 -o0 -e0 uniq -s 33 \
- | while read line; do
- #echo $line
- if [[ $line = *12381* ]]; then
- LvngRm=$(echo "$line")
- echo $LvngRm | /usr/bin/mosquitto_pub -h "$MQTT_HOST" -u temps -P temps1 -p 1883 -i RTL_433 -l -t "livingroom/temp"
- #echo $LvngRm
- elif [[ $line = *12963* ]]; then
- EvnRm=$(echo "$line")
- echo $EvnRm | /usr/bin/mosquitto_pub -h "$MQTT_HOST" -u temps -P temps1 -p 1883 -i RTL_433 -l -t "evansroom/temp"
- #echo $EvnRm
- elif [[ $line = *3360* ]]; then
- BdRm=$(echo "$line")
- echo $BdRm | /usr/bin/mosquitto_pub -h $MQTT_HOST -u temps -P temps1 -p 1883 -i RTL_433 -l -t "bedroom/temp"
- #echo $BdRm
- elif [[ $line = *7329* ]]; then
- Ktchn=$(echo "$line")
- echo $Ktchn | /usr/bin/mosquitto_pub -h $MQTT_HOST -u temps -P temps1 -p 1883 -i RTL_433 -l -t "kitchen/temp"
- #echo $Ktchn
- fi
- done
- # Log to file if file exists.
- # Create file with touch /tmp/rtl_433.log if logging is needed
- #touch /home/buster/rtlmqtt/rtl_433.log
- # [ -w /tmp/rtl_433.log ] && echo $LvngRm | >> /tmp/rtl_433.log
- # Raw message to MQTT
- # Above in loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement