evilpete Posted Thursday at 08:42 PM Posted Thursday at 08:42 PM I am trying to feed data from my outdoor temperature sensor (LaCrosse-TX141Bv3). I'm receiving the data using an SDR dongle and passing it via mqtt. The data I'm sending to MQTT: {"time" : "2025-08-07 13:39:10", "protocol" : 73, "model" : "LaCrosse-TX141Bv3", "id" : 237, "channel" : 1, "battery_ok" : 1, "temperature_C" : 20.800, "test" : "No"} This is the json output from rtl_433 My devfile: devices: - id: "TX141Bv1" sensor_id: "temperature_C" type: "Temp" name: "Temperature" status_topic: "rtl_433/LaCrosse-TX141Bv3/temperature_C" cmd_topic: "rtl_433/LaCrosse-TX141Bv3/power" - id: "TX141Bv2" sensor_id: "battery_ok" type: "raw" name: "Battery" status_topic: "rtl_433/LaCrosse-TX141Bv3/battery_ok" cmd_topic: "rtl_433/LaCrosse-TX141Bv3/power" - id: "TX141Bv4" sensor_id: "test" type: "flag" name: "testFlag" status_topic: "rtl_433/LaCrosse-TX141Bv3/test" cmd_topic: "rtl_433/LaCrosse-TX141Bv3/power" MQTT Explorer reports: . But Im seeing . any suggestions? I'm guessing I am misinterpreting fieldnames? Quote
TriLife Posted Thursday at 11:17 PM Posted Thursday at 11:17 PM Hi @evilpete, The MQTT plug-in was designed for Tasmota integrations. Tasmota doesn't send JSON packets, only individual data points. I think @sjenkins added one or two devices, which send JSON packets. He might be able to shed more light to see, if using his device-type will better match your needs. 1 Quote
evilpete Posted Friday at 12:24 AM Author Posted Friday at 12:24 AM Thanks I'll do more studying.. I found a few filters that grok the json and publish the filtered results. Quote
sjenkins Posted Saturday at 01:18 PM Posted Saturday at 01:18 PM (edited) @evilpete , your issue is these devices do not read a JSON string from MQTT but rather individual variables. so your MQTT should look more like this..... (sorry this isn't a raw example but the form factory holds). You will need to write your JSON string using each variable. Does not matter if your device is Tasmota or not ; in fact when I started using, then modifying this plugin I didn't know what Tasmota was & still have never used one. What matters is the form it hits the MQTT ; that's the beauty of MQTT ! Not sure if you are sending with Python or with C, C# but works similar in both, the topic in the below case is /sej/awning/status/hb while the message is ON. You are sending the whole JSON as one message in a topic. hope that helps Edited Saturday at 01:29 PM by sjenkins 1 Quote
sjenkins Posted Saturday at 02:09 PM Posted Saturday at 02:09 PM A quick Python example from my Copilot friend: Here's a Python function that takes a JSON array and sends each item to a separate MQTT topic using the paho-mqtt library: import json import paho.mqtt.client as mqtt def send_json_array_to_mqtt_topics(json_array, topic_prefix, mqtt_host='localhost', mqtt_port=1883): """ Sends each item in a JSON array to a separate MQTT topic. Parameters: - json_array (list): A list of JSON-serializable items. - topic_prefix (str): Prefix for MQTT topics (e.g., 'sensor/data'). - mqtt_host (str): MQTT broker host. - mqtt_port (int): MQTT broker port. """ client = mqtt.Client() client.connect(mqtt_host, mqtt_port, 60) for i, item in enumerate(json_array): topic = f"{topic_prefix}/{i}" payload = json.dumps(item) client.publish(topic, payload) print(f"Published to {topic}: {payload}") client.disconnect() Example usage: data = [{"temp": 22.5}, {"temp": 23.0}, {"temp": 21.8}] send_json_array_to_mqtt_topics(data, "sensors/temperature") This will publish each dictionary in the array to a topic like: - sensors/temperature/0 - sensors/temperature/1 - sensors/temperature/2 Quote
evilpete Posted Saturday at 02:29 PM Author Posted Saturday at 02:29 PM (edited) @sjenkins thanks I'll probably have to write a plug-in that interprets the output of rtl-433. it's written in C and the code focuses on SDR protocol decoding thus the input format is not gonna change (I contributed to code base a few years ago) after looking around they have some example code that does something similar for another product. Side Note: once done it will be trivial to incorporate pre-existing devices as input sensors Tire pressure: {"time" : "2025-08-04 18:22:45", "protocol" : 186, "model" : "Hyundai-VDO", "type" : "TPMS", "id" : "5173f60b", "state" : 48, "flags" : 8, "repeat" : 1, "pressure_kPa" : 248.875, "temperature_C" : 25.000, "maybe_battery" : 1, "mic" : "CRC"} Home security sensors (admittedly the neighbors') {"time" : "2025-06-30 22:14:47", "model" : "Interlogix-Security", "subtype" : "unknown", "id" : "51a4c2", "battery_ok" : 0, "switch1" : "CLOSED", "switch2" : "CLOSED", "switch3" : "OPEN", "switch4" : "CLOSED", "switch5" : "CLOSED", "raw_message" : "d24000"} Efergy home energy meter (also the neighbors', but hey, it's good for development input data) {"time" : "2025-07-31 19:01:36", "protocol" : 100, "model" : "Efergy-e2CT", "id" : 16386, "battery_ok" : 0, "current" : 18.781, "interval" : 6} Rolling code Keyfobs {"time" : "@0.843604s", "protocol" : 164, "model" : "Secplus-v2", "id" : 1959100928, "button_id" : 16, "remote_id" : 1959100928, "fixed" : "70678577664", "rolling" : "240124739"} Motion sensors {time" : "2024-09-27 19:28:26", "model" : "Skylink motion sensor", "motion" : "true", "id" : "1e3e8", "raw" : "be3e8"} Edited Saturday at 08:46 PM by evilpete Quote
sjenkins Posted Saturday at 08:21 PM Posted Saturday at 08:21 PM @evilpete your other option is to add a device to the mqtt plugin & do a pull request. Take a look at the github, the code is pretty simple. Less work than a whole plugin. https://github.com/Trilife/udi-mqtt-pg3x 1 Quote
evilpete Posted Saturday at 08:40 PM Author Posted Saturday at 08:40 PM (edited) 5 hours ago, sjenkins said: @evilpete your other option is to add a device to the mqtt plugin & do a pull request. Take a look at the github, the code is pretty simple. Less work than a whole plugin. https://github.com/Trilife/udi-mqtt-pg3x Yeah, now that i understand what is going on more that's what I've thinking about with a few translation table based on protocol number... I was trying to use it as it at first not realizing it was special case mostly for Tasmota integrations Edited yesterday at 01:41 AM by evilpete Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.