New rtlamr addon
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "RTLAMR to MQTT Bridge",
|
"name": "RTLAMR to MQTT Bridge",
|
||||||
"version": "0.0.2",
|
"version": "0.0.3",
|
||||||
"slug": "rtlamr",
|
"slug": "rtlamr",
|
||||||
"description": "RF to MQTT Bridge based on RTL_SDR/RTL_433 for RTL2832U based DVB-T USB tuners",
|
"description": "RF to MQTT Bridge based on RTL_SDR/RTL_433 for RTL2832U based DVB-T USB tuners",
|
||||||
"url": "https://github.com/bvlaicu/home-assistant-addons/tree/master/rtlamr",
|
"url": "https://github.com/bvlaicu/home-assistant-addons/tree/master/rtlamr",
|
||||||
|
|||||||
+22
-16
@@ -39,24 +39,30 @@ LASTVAL="0"
|
|||||||
# Do this loop, so will restart if buffer runs out
|
# Do this loop, so will restart if buffer runs out
|
||||||
while true; do
|
while true; do
|
||||||
|
|
||||||
/go/bin/rtlamr -format json -msgtype=$MQTT_MSGTYPE -filterid=$MQTT_IDS | while read line
|
ID_FILTER_OPTION=""
|
||||||
#/go/bin/rtlamr -format json -msgtype=$MQTT_MSGTYPE | while read line
|
if [ -z ${MQTT_IDS+x} ]; then
|
||||||
|
ID_FILTER_OPTION=""
|
||||||
do
|
else
|
||||||
VAL="$(echo $line | jq --raw-output '.Message.Consumption' | tr -s ' ' '_')" # replace ' ' with '_'
|
ID_FILTER_OPTION=$MQTT_IDS
|
||||||
DEVICEID="$(echo $line | jq --raw-output '.Message.ID' | tr -s ' ' '_')"
|
|
||||||
MSGTYPE="$(echo $line | jq --raw-output '.Type' | tr -s ' ' '_')"
|
|
||||||
MQTT_PATH="readings/$DEVICEID/meter_reading"a
|
|
||||||
|
|
||||||
# Create file with touch /var/log/rtl_433.log if logging is needed
|
|
||||||
[ -w /var/log/rtl_433.log ] && echo $line >> /var/log/rtl_433.log
|
|
||||||
if [ "$VAL" != "$LASTVAL" ]; then
|
|
||||||
echo $VAL | /usr/bin/mosquitto_pub -h $MQTT_HOST -u $MQTT_USER -P $MQTT_PASS -i RTL_433 -r -l -t $MQTT_PATH
|
|
||||||
LASTVAL=$VAL
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
/go/bin/rtlamr -format json -msgtype=$MQTT_MSGTYPE $ID_FILTER_OPTION | while read line
|
||||||
|
|
||||||
sleep 60
|
do
|
||||||
|
VAL="$(echo $line | jq --raw-output '.Message.Consumption' | tr -s ' ' '_')" # replace ' ' with '_'
|
||||||
|
DEVICEID="$(echo $line | jq --raw-output '.Message.ID' | tr -s ' ' '_')"
|
||||||
|
MSGTYPE="$(echo $line | jq --raw-output '.Type' | tr -s ' ' '_')"
|
||||||
|
MQTT_PATH="rtlamr/$DEVICEID/meter_reading"
|
||||||
|
|
||||||
|
# Create file with touch /var/log/rtl_433.log if logging is needed
|
||||||
|
[ -w /var/log/rtl_433.log ] && echo $line >> /var/log/rtl_433.log
|
||||||
|
if [ "$VAL" != "$LASTVAL" ]; then
|
||||||
|
echo $VAL | /usr/bin/mosquitto_pub -h $MQTT_HOST -u $MQTT_USER -P $MQTT_PASS -i RTL_433 -r -l -t $MQTT_PATH
|
||||||
|
LASTVAL=$VAL
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
sleep 60
|
||||||
|
|
||||||
done
|
done
|
||||||
Reference in New Issue
Block a user