Jump to content

What Am I doing Wrong?


evilpete

Recommended Posts

Posted

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:


image.png.49298c9d403ec0d81ae8428fc609fce4.pngimage.png.70d66ac02e7a52dad5b200b76c0b7a93.png

But Im seeing 

image.png.0cf4732028b4afe7a83261cad406952b.png.  image.png.dd5f6c1b3fd727d3744b2c41774e7eba.pngimage.png.dbb04f5d63c1ee2ef5b60af2836c015c.png


any suggestions?

I'm guessing I am misinterpreting fieldnames? 

 

 

Posted

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.

  • Like 1
Posted (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

 

image.png.c8a6419e516e16d35a2d362463183e5a.png

 

Edited by sjenkins
  • Thanks 1
Posted

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
 

Posted (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 by evilpete
Posted (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 by evilpete

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing

    • No registered users viewing this page.
  • Forum Statistics

    • Total Topics
      38k
    • Total Posts
      379.3k
×
×
  • Create New...