I use rtl_433 to convert my Acurite sensors into MQTT that NR utilizes. The packets are transmitted one data type at a time so my Acurite 592TXR towers result in several MQTT messages each time they transmit though I really only care about 3 (temperature, humidity, battery). Currently, I have rtl_433 send the message with the topic based on the type of sensor, the unit number of that sensor, and the data being transmitted.
rtl_433/Acurite-Tower/245/time 2022-03-28 00:56:03
rtl_433/Acurite-Tower/245/id 245
rtl_433/Acurite-Tower/245/channel A
rtl_433/Acurite-Tower/245/battery_ok 0
rtl_433/Acurite-Tower/245/temperature_C 19.6
rtl_433/Acurite-Tower/245/humidity 41
rtl_433/Acurite-Tower/245/mic CHECKSUM
Right now I have a block of code for each sensor ID which seems redundant. I would prefer to consolidate the code such that one block can take care of as many sensors as there happen to be on the MQTT stream. Each sensor would output to a separate ID into grafana like I currently have but not having to hard code things.
[{"id":"2850d44b.400a84","type":"tab","label":"Acurite tower","disabled":false,"info":""},{"id":"9bbb50b9.5cbb28","type":"mqtt in","z":"2850d44b.400a84","name":"tempC_A","topic":"rtl_433/Acurite-Tower/245/temperature_C","qos":"2","datatype":"buffer","broker":"b2400571.717f88","x":80,"y":100,"wires":[["6a324fe1.1882b"]]},{"id":"32f24980.f76f46","type":"mqtt in","z":"2850d44b.400a84","name":"Humidity_A","topic":"rtl_433/Acurite-Tower/245/humidity","qos":"2","datatype":"buffer","broker":"b2400571.717f88","x":80,"y":200,"wires":[["66fa83f2.18c4bc"]]},{"id":"fa26ba27.9b17f","type":"comment","z":"2850d44b.400a84","name":"Acurite tower temperature/humidity sensor (channel A)","info":"","x":205,"y":20,"wires":[]},{"id":"15f90a5a.8ae39e","type":"mqtt in","z":"2850d44b.400a84","name":"Battery_A","topic":"rtl_433/Acurite-Tower/245/battery_ok","qos":"2","datatype":"buffer","broker":"b2400571.717f88","x":80,"y":300,"wires":[["4a23f687.ecf4b8"]]},{"id":"3e17c4e4.4063e4","type":"mqtt in","z":"2850d44b.400a84","name":"tempC_B","topic":"rtl_433/Acurite-Tower/1066/temperature_C","qos":"2","datatype":"buffer","broker":"b2400571.717f88","x":80,"y":480,"wires":[["ea5d1366.0dd49"]]},{"id":"8b0fdf40.56f4e8","type":"mqtt in","z":"2850d44b.400a84","name":"Humidity_B","topic":"rtl_433/Acurite-Tower/1066/humidity","qos":"2","datatype":"buffer","broker":"b2400571.717f88","x":80,"y":580,"wires":[["b46923e1.071f5"]]},{"id":"9f430c02.752e48","type":"comment","z":"2850d44b.400a84","name":"Acurite tower temperature/humidity sensor (channel B)","info":"","x":205,"y":400,"wires":[]},{"id":"fac0c01e.bf1578","type":"mqtt in","z":"2850d44b.400a84","name":"Battery_B","topic":"rtl_433/Acurite-Tower/1066/battery_ok","qos":"2","datatype":"buffer","broker":"b2400571.717f88","x":80,"y":680,"wires":[["3bef14f9.cf230c"]]},{"id":"eeb45354.66fb48","type":"mqtt in","z":"2850d44b.400a84","name":"tempC_C","topic":"rtl_433/Acurite-Tower/1878/temperature_C","qos":"2","datatype":"buffer","broker":"b2400571.717f88","x":80,"y":860,"wires":[["dca2b2d9.c3c2c"]]},{"id":"9edaacdc.db739","type":"mqtt in","z":"2850d44b.400a84","name":"Humidity_C","topic":"rtl_433/Acurite-Tower/1878/C/humidity","qos":"2","datatype":"buffer","broker":"b2400571.717f88","x":90,"y":962,"wires":[["2ce4d5c3.fde7a2"]]},{"id":"ffbe6bd4.8fc2a","type":"comment","z":"2850d44b.400a84","name":"Acurite tower temperature/humidity sensor (channel C)","info":"","x":205,"y":780,"wires":[]},{"id":"f0fa2830.cb629","type":"mqtt in","z":"2850d44b.400a84","name":"Battery_C","topic":"rtl_433/Acurite-Tower/1878/battery_ok","qos":"2","datatype":"buffer","broker":"b2400571.717f88","x":80,"y":1060,"wires":[["9ec96693.9e7d6"]]},{"id":"aa941b94.cad38","type":"change","z":"2850d44b.400a84","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"Temp sensor A battery low","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"Acurite tower temperature/humidity sensor A battery has dropped below 100%. Replace at soonest convenience.","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":340,"wires":[[]]},{"id":"1fc9f33e.220035","type":"change","z":"2850d44b.400a84","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"Temp sensor B battery low","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"Acurite tower temperature/humidity sensor B battery has dropped below 100%. Replace at soonest convenience.","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":720,"wires":[[]]},{"id":"d0818b6b.21cc78","type":"change","z":"2850d44b.400a84","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"Temp sensor C battery low","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"Acurite tower temperature/humidity sensor C battery has dropped below 100%. Replace at soonest convenience.","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":1100,"wires":[[]]},{"id":"898ffad.3e99f88","type":"influxdb out","z":"2850d44b.400a84","influxdb":"5b91dbad.94ba7c","name":"tempF_A","measurement":"rtl_433/Acurite-Tower/A/temperature_F","precision":"","retentionPolicy":"","database":"sensors","precisionV18FluxV20":"ms","retentionPolicyV18Flux":"","org":"organisation","bucket":"bucket","x":760,"y":100,"wires":[]},{"id":"203e957d.cde70a","type":"influxdb out","z":"2850d44b.400a84","influxdb":"5b91dbad.94ba7c","name":"Battery_A","measurement":"rtl_433/Acurite-Tower/A/battery_ok","precision":"","retentionPolicy":"","database":"sensors","precisionV18FluxV20":"ms","retentionPolicyV18Flux":"","org":"organisation","bucket":"bucket","x":520,"y":300,"wires":[]},{"id":"26521657.4a84b2","type":"influxdb out","z":"2850d44b.400a84","influxdb":"5b91dbad.94ba7c","name":"tempF_B","measurement":"rtl_433/Acurite-Tower/B/temperature_F","precision":"","retentionPolicy":"","database":"sensors","precisionV18FluxV20":"ms","retentionPolicyV18Flux":"","org":"organisation","bucket":"bucket","x":760,"y":480,"wires":[]},{"id":"b64e7b00.19fde8","type":"influxdb out","z":"2850d44b.400a84","influxdb":"5b91dbad.94ba7c","name":"Humidity_B","measurement":"rtl_433/Acurite-Tower/B/humidity","precision":"","retentionPolicy":"","database":"sensors","precisionV18FluxV20":"ms","retentionPolicyV18Flux":"","org":"organisation","bucket":"bucket","x":530,"y":580,"wires":[]},{"id":"6e539acf.d8a984","type":"influxdb out","z":"2850d44b.400a84","influxdb":"5b91dbad.94ba7c","name":"Battery_B","measurement":"rtl_433/Acurite-Tower/B/battery_ok","precision":"","retentionPolicy":"","database":"sensors","precisionV18FluxV20":"ms","retentionPolicyV18Flux":"","org":"organisation","bucket":"bucket","x":520,"y":683,"wires":[]},{"id":"eb40ab87.4c1d78","type":"influxdb out","z":"2850d44b.400a84","influxdb":"5b91dbad.94ba7c","name":"tempF_C","measurement":"rtl_433/Acurite-Tower/C/temperature_F","precision":"","retentionPolicy":"","database":"sensors","precisionV18FluxV20":"ms","retentionPolicyV18Flux":"","org":"organisation","bucket":"bucket","x":620,"y":860,"wires":[]},{"id":"517ee1.7dafd12","type":"influxdb out","z":"2850d44b.400a84","influxdb":"5b91dbad.94ba7c","name":"Humidity_C","measurement":"rtl_433/Acurite-Tower/C/humidity","precision":"","retentionPolicy":"","database":"sensors","precisionV18FluxV20":"ms","retentionPolicyV18Flux":"","org":"organisation","bucket":"bucket","x":530,"y":960,"wires":[]},{"id":"eb85d316.cf2b58","type":"influxdb out","z":"2850d44b.400a84","influxdb":"5b91dbad.94ba7c","name":"Battery_C","measurement":"rtl_433/Acurite-Tower/C/battery_ok","precision":"","retentionPolicy":"","database":"sensors","precisionV18FluxV20":"ms","retentionPolicyV18Flux":"","org":"organisation","bucket":"bucket","x":520,"y":1060,"wires":[]},{"id":"6a324fe1.1882b","type":"deduplicate","z":"2850d44b.400a84","name":"","keyproperty":"","expiry":"5","x":290,"y":100,"wires":[["32c8adec.8f308a"],[]]},{"id":"66fa83f2.18c4bc","type":"deduplicate","z":"2850d44b.400a84","name":"","keyproperty":"","expiry":"5","x":290,"y":200,"wires":[["dfeac77b.0c8e98"],[]]},{"id":"4a23f687.ecf4b8","type":"deduplicate","z":"2850d44b.400a84","name":"","keyproperty":"","expiry":"5","x":290,"y":300,"wires":[["203e957d.cde70a"],["eb51cc9b.519ea8"]]},{"id":"ea5d1366.0dd49","type":"deduplicate","z":"2850d44b.400a84","name":"","keyproperty":"","expiry":"5","x":290,"y":480,"wires":[["63bdbe3b.d8901"],[]]},{"id":"b46923e1.071f5","type":"deduplicate","z":"2850d44b.400a84","name":"","keyproperty":"","expiry":"5","x":290,"y":580,"wires":[["b64e7b00.19fde8"],[]]},{"id":"3bef14f9.cf230c","type":"deduplicate","z":"2850d44b.400a84","name":"","keyproperty":"","expiry":"5","x":290,"y":680,"wires":[["6e539acf.d8a984","4223527b.b0521c"],[]]},{"id":"dca2b2d9.c3c2c","type":"deduplicate","z":"2850d44b.400a84","name":"","keyproperty":"","expiry":"5","x":290,"y":860,"wires":[["25a23cf0.647534"],[]]},{"id":"2ce4d5c3.fde7a2","type":"deduplicate","z":"2850d44b.400a84","name":"","keyproperty":"","expiry":"5","x":290,"y":960,"wires":[["517ee1.7dafd12"],[]]},{"id":"9ec96693.9e7d6","type":"deduplicate","z":"2850d44b.400a84","name":"","keyproperty":"","expiry":"5","x":290,"y":1060,"wires":[["eb85d316.cf2b58","b0f32340.f69e1"],[]]},{"id":"eb51cc9b.519ea8","type":"falling-edge","z":"2850d44b.400a84","name":"<0.5","threshold":"0.5","x":430,"y":340,"wires":[["2aaaa03a.ba17b"]]},{"id":"4223527b.b0521c","type":"falling-edge","z":"2850d44b.400a84","name":"<0.5","threshold":"0.5","x":430,"y":720,"wires":[["8e336d6d.7e6048"]]},{"id":"b0f32340.f69e1","type":"falling-edge","z":"2850d44b.400a84","name":"<0.5","threshold":"0.5","x":430,"y":1100,"wires":[["4e32eef6.cbc418"]]},{"id":"32c8adec.8f308a","type":"unit-converter","z":"2850d44b.400a84","category":"temperature","inputUnit":"C","outputUnit":"F","inputField":"payload","outputField":"payload","inputFieldType":"msg","outputFieldType":"msg","roundOutputField":false,"outputFieldDecimals":2,"name":"TempC2F","x":460,"y":100,"wires":[["50ed743f.3d62d4"]]},{"id":"63bdbe3b.d8901","type":"unit-converter","z":"2850d44b.400a84","category":"temperature","inputUnit":"C","outputUnit":"F","inputField":"payload","outputField":"payload","inputFieldType":"msg","outputFieldType":"msg","roundOutputField":false,"outputFieldDecimals":2,"name":"TempC2F","x":460,"y":480,"wires":[["4cc92905.1d2c28"]]},{"id":"25a23cf0.647534","type":"unit-converter","z":"2850d44b.400a84","category":"temperature","inputUnit":"C","outputUnit":"F","inputField":"payload","outputField":"payload","inputFieldType":"msg","outputFieldType":"msg","roundOutputField":false,"outputFieldDecimals":2,"name":"TempC2F","x":460,"y":860,"wires":[["eb40ab87.4c1d78"]]},{"id":"dfeac77b.0c8e98","type":"influxdb out","z":"2850d44b.400a84","influxdb":"5b91dbad.94ba7c","name":"Humidity_A","measurement":"rtl_433/Acurite-Tower/A/humidity","precision":"","retentionPolicy":"","database":"sensors","precisionV18FluxV20":"ms","retentionPolicyV18Flux":"","org":"organisation","bucket":"bucket","x":530,"y":200,"wires":[]},{"id":"2aaaa03a.ba17b","type":"deduplicate","z":"2850d44b.400a84","name":"","keyproperty":"","registryclass":"","expiry":"86400","x":570,"y":340,"wires":[["aa941b94.cad38"],[]]},{"id":"8e336d6d.7e6048","type":"deduplicate","z":"2850d44b.400a84","name":"","keyproperty":"","registryclass":"","expiry":"86400","x":570,"y":720,"wires":[["1fc9f33e.220035"],[]]},{"id":"4e32eef6.cbc418","type":"deduplicate","z":"2850d44b.400a84","name":"","keyproperty":"","registryclass":"","expiry":"86400","x":570,"y":1100,"wires":[["d0818b6b.21cc78"],[]]},{"id":"50ed743f.3d62d4","type":"switch","z":"2850d44b.400a84","name":"Filter >150","property":"payload","propertyType":"msg","rules":[{"t":"lt","v":"150","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":610,"y":100,"wires":[["898ffad.3e99f88"]]},{"id":"4cc92905.1d2c28","type":"switch","z":"2850d44b.400a84","name":"Filter >150","property":"payload","propertyType":"msg","rules":[{"t":"lt","v":"150","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":610,"y":480,"wires":[["26521657.4a84b2"]]},{"id":"b2400571.717f88","type":"mqtt-broker","name":"RPi3","broker":"192.168.0.200","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"5b91dbad.94ba7c","type":"influxdb","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"sensors","name":"influxdb","usetls":false,"tls":"","influxdbVersion":"1.x","url":"http://localhost:8086","rejectUnauthorized":true}]
Right now I am transmitting the data to grafana based on the hard coded Acurite channel but I want to store the data in grafana based on the received ID.