Need help with MQTT - spent hours with AI

Hi there

I recently played around with some LoRa-sensors for my garden. I bought a Dragino LSPH01 to measure the temp and pH-value of my lawn.

I connected the sensor to my local Chirpstack and I can also see the values via MQTT.

The payload I see in MQTT-Explorer is:

{
    "deduplicationId": "XX",
    "time": "2026-03-28T09:50:42.701+00:00",
    "deviceInfo": {
        "tenantId": "XX",
        "tenantName": "XX",
        "applicationId": "XX",
        "applicationName": "Dragino LSPH01",
        "deviceProfileId": "XX",
        "deviceProfileName": "Dragino LSPH01",
        "deviceName": "Dragino LSPH01",
        "devEui": "XX",
        "deviceClassEnabled": "CLASS_A",
        "tags": {}
    },
    "devAddr": "XX",
    "adr": true,
    "dr": 0,
    "fCnt": 0,
    "fPort": 2,
    "confirmed": false,
    "data": "XX",
    "object": {
        "Interrupt_flag": 0,
        "TempC_DS18B20": "0.00 °C",
        "Message_type": 1,
        "PH1_SOIL": "7.01",
        "Bat": "3.399 V",
        "TEMP_SOIL": "24.60",
        "Node_type": "LSPH01"
    },
    "rxInfo": [
        {
            "gatewayId": "XX",
            "uplinkId": 36283,
            "gwTime": "2026-03-28T09:50:42.701409+00:00",
            "nsTime": "2026-03-28T09:50:42.726080832+00:00",
            "timeSinceGpsEpoch": "1458726660.701s",
            "rssi": -25,
            "snr": 7.2,
            "channel": 6,
            "rfChain": 1,
            "location": {
                "latitude": XX,
                "longitude": XX,
                "altitude":XX
            },
            "context": "XX",
            "crcStatus": "CRC_OK"
        }
    ],
    "txInfo": {
        "frequency": 868300000,
        "modulation": {
            "lora": {
                "bandwidth": 125000,
                "spreadingFactor": 12,
                "codeRate": "CR_4_5"
            }
        }
    },
    "regionConfigId": "eu868"
}

I would like to read out the temp for a test:

"TEMP_SOIL": "24.60",

This is my latest YAML, I tried dozens of variations though.

mqtt:
  sensor:
    - name: "LSPH01 Temp"
      unique_id: lsph01_boden_temp
      state_topic: "application/XX/device/XX/event/up"
      value_template: "{{ (value | from_json).object.TEMP_SOIL | float(0) }}"
      unit_of_measurement: "°C"
      state_class: measurement

I spent hours with Chat GPT, Gemini however they could not help and I cannot identify why it doesn’t work. Would appreciate any help from you guys, probably its just a small thing that I am missing.

Best,
Andrew

Try this:

{{ value_json.object.TEMP_SOIL | float(0) }}

And AI…well, sometimes A is not that I

MQTT Sensor - Home Assistant

thanks a lot, well actually I found the error. I use two MQTT-instances, one running on the HA-machine and one my NAS. The values never came in as HA would only receive data from the MQTT-instance running on HA.

I now used the following method in Node-RED:

MQTT-in node to get the value from MQTT on the NAS
function-node

if (
    msg.payload &&
    msg.payload.object &&
    msg.payload.object.TEMP_SOIL !== undefined
) {
    msg.payload = parseFloat(msg.payload.object.TEMP_SOIL);
    msg.topic = "home/soil_temp";
    msg.retain = true;
    return msg;
}
return null;

MQTT-out node to the MQTT-instance on HA

YAML-code:

    - name: "Bodentemperatur Schachenmatt"
      state_topic: "home/soil_temp"
      unit_of_measurement: "°C"
      device_class: temperature
      state_class: measurement

now it works :slight_smile:

Was that suggested by AI hallucinations as well?

Now you have two different places for your data to get lost or corrupted, and double the disk space to store two backups!

Break down the process:

  1. Get the data from the sensors.
  2. Package into a format that can be transmitted.
  3. Transmit it.
  4. Store it (preferably once).
  5. Extract the values.
  6. Display them.

@lighthouse for me, mqtt does not work.
try other way - it’s wasting time.

good point. No actually AI didnt suggest that and I may rethink my setup. I ran only one MQTT-instance for many years, however since I played around with Chirpstack I installed MQTT directly with it and never really thought about the impact it has on the whole setup.

1 Like