Advertisement
frithb

Untitled

Jan 15th, 2017
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. #!/bin/bash
  2. # Use this variable when creating a container to specify the MQTT broker host.
  3. MQTT_HOST="127.0.0.1"
  4. # A simple script that will receive events from a RTL433 SDR
  5.  
  6. # Author: Marco Verleun <marco@marcoach.nl>
  7. # Version 2.0: Adapted for the new output format of rtl_433
  8.  
  9. # Remove hash on next line for debugging
  10. #set -x
  11.  
  12. export LANG=C
  13. PATH="/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"
  14.  
  15. #
  16. # Start the listener and enter an endless loop
  17. #
  18.  
  19. stdbuf -i0 -o0 -e0 /usr/local/bin/rtl_433 -F json -C customary -R 39 | stdbuf -i0 -o0 -e0 uniq -s 33 \
  20. | while read line; do
  21. #echo $line
  22. if [[ $line = *12381* ]]; then
  23. LvngRm=$(echo "$line")
  24. echo $LvngRm | /usr/bin/mosquitto_pub -h "$MQTT_HOST" -u temps -P temps1 -p 1883 -i RTL_433 -l -t "livingroom/temp"
  25. #echo $LvngRm
  26. elif [[ $line = *12963* ]]; then
  27. EvnRm=$(echo "$line")
  28. echo $EvnRm | /usr/bin/mosquitto_pub -h "$MQTT_HOST" -u temps -P temps1 -p 1883 -i RTL_433 -l -t "evansroom/temp"
  29. #echo $EvnRm
  30. elif [[ $line = *3360* ]]; then
  31. BdRm=$(echo "$line")
  32. echo $BdRm | /usr/bin/mosquitto_pub -h $MQTT_HOST -u temps -P temps1 -p 1883 -i RTL_433 -l -t "bedroom/temp"
  33. #echo $BdRm
  34. elif [[ $line = *7329* ]]; then
  35. Ktchn=$(echo "$line")
  36. echo $Ktchn | /usr/bin/mosquitto_pub -h $MQTT_HOST -u temps -P temps1 -p 1883 -i RTL_433 -l -t "kitchen/temp"
  37. #echo $Ktchn
  38. fi
  39. done
  40.  
  41. # Log to file if file exists.
  42. # Create file with touch /tmp/rtl_433.log if logging is needed
  43. #touch /home/buster/rtlmqtt/rtl_433.log
  44. # [ -w /tmp/rtl_433.log ] && echo $LvngRm | >> /tmp/rtl_433.log
  45.  
  46. # Raw message to MQTT
  47. # Above in loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement