MQTT Topic TTN

[
    {
        "id": "153ff67d1f2c61b8",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "8e52c3ed8907ee0c",
        "type": "mqtt in",
        "z": "153ff67d1f2c61b8",
        "name": "Füllstand Quelle",
        "topic": "v3/DEVICEID@ttn/devices/+/up",
        "qos": "2",
        "datatype": "json",
        "broker": "0a4f4fef6fee57c6",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 260,
        "y": 260,
        "wires": [
            [
                "059296a9a604036f",
                "1ae3c6d92610a908"
            ]
        ]
    },
    {
        "id": "059296a9a604036f",
        "type": "change",
        "z": "153ff67d1f2c61b8",
        "name": "change node",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.uplink_message.decoded_payload.Distance",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "dev_eui",
                "pt": "msg",
                "to": "payload.end_device_ids.dev_eui",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 470,
        "y": 260,
        "wires": [
            [
                "08529e03113c98e2",
                "c4aa3711222d1081"
            ]
        ]
    },
    {
        "id": "08529e03113c98e2",
        "type": "debug",
        "z": "153ff67d1f2c61b8",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 990,
        "y": 280,
        "wires": []
    },
    {
        "id": "1ae3c6d92610a908",
        "type": "debug",
        "z": "153ff67d1f2c61b8",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 430,
        "y": 180,
        "wires": []
    },
    {
        "id": "c4aa3711222d1081",
        "type": "debug",
        "z": "153ff67d1f2c61b8",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "dev_eui",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 990,
        "y": 240,
        "wires": []
    },
    {
        "id": "0a4f4fef6fee57c6",
        "type": "mqtt-broker",
        "name": "Füllstand Quelle",
        "broker": "eu1.cloud.thethings.network",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "sessionExpiry": ""
    }
]

Thats the flow

You have added a few thing that aided in the confusion.

You should rather keep your debug node set to as below.

image

This way you only get part of the JSON

image

I have corrected your flow, you will see there is a “Test Json”, if I hade you JSON I could have solved the problem faster.

You should be good now to inject the JSON into the Influx DB node and have the correct data in the DB.

[
    {
        "id": "153ff67d1f2c61b8",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "8e52c3ed8907ee0c",
        "type": "mqtt in",
        "z": "153ff67d1f2c61b8",
        "name": "Füllstand Quelle",
        "topic": "v3/DEVICEID@ttn/devices/+/up",
        "qos": "2",
        "datatype": "json",
        "broker": "0a4f4fef6fee57c6",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 220,
        "y": 260,
        "wires": [
            [
                "059296a9a604036f"
            ]
        ]
    },
    {
        "id": "059296a9a604036f",
        "type": "change",
        "z": "153ff67d1f2c61b8",
        "name": "change node",
        "rules": [
            {
                "t": "set",
                "p": "Distance",
                "pt": "msg",
                "to": "payload.uplink_message.decoded_payload.Distance",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "dev_eui",
                "pt": "msg",
                "to": "payload.end_device_ids.device_id",
                "tot": "msg"
            },
            {
                "t": "delete",
                "p": "payload.uplink_message",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "payload.correlation_ids",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "payload",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "topic",
                "pt": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 510,
        "y": 260,
        "wires": [
            [
                "c4aa3711222d1081"
            ]
        ]
    },
    {
        "id": "1ae3c6d92610a908",
        "type": "debug",
        "z": "153ff67d1f2c61b8",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 530,
        "y": 360,
        "wires": []
    },
    {
        "id": "c4aa3711222d1081",
        "type": "debug",
        "z": "153ff67d1f2c61b8",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "dev_eui",
        "statusType": "auto",
        "x": 670,
        "y": 260,
        "wires": []
    },
    {
        "id": "60f39d916a35dd8b",
        "type": "inject",
        "z": "153ff67d1f2c61b8",
        "name": "Test Json",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"topic\":\"v3/compact-tracker-abeeway@ttn/devices/eui-20635f0161000093/up\",\"payload\":{\"end_device_ids\":{\"device_id\":\"eui-dhdfth\",\"application_ids\":{\"application_id\":\"fjdjdy\"},\"dev_eui\":\"hth3\",\"join_eui\":\"hrhxf\",\"dev_addr\":\"hhF\"},\"correlation_ids\":[\"as:up:01FPZ2ZC6PJQE0XQ68ECN239B7\",\"gs:conn:01FNXTS68EYM139F0J53QR5ZK0\",\"gs:up:host:01FNXTS699E4A2H7VSP45SZG62\",\"gs:uplink:01FPZ2ZC04E8WTWP10DHJX97S6\",\"ns:uplink:01FPZ2ZC0568ACBK2MBZQK4148\",\"rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01FPZ2ZC052XX7N17EDTRCYW6D\",\"rpc:/ttn.lorawan.v3.NsAs/HandleUplink:01FPZ2ZC6MRZ4WAM86KEJC7J6B\"],\"received_at\":\"2021-12-15T13:02:16.279389076Z\",\"uplink_message\":{\"session_key_id\":\"AX23nQJEOCVpz1fId9ugRw==\",\"f_port\":18,\"f_cnt\":182,\"frm_payload\":\"BSBhigAQAgAAAwIA\",\"decoded_payload\":{\"ack\":0,\"batteryPersentage\":97,\"bleFirmware\":\"bleFwVersion3.2.0\",\"data\":0,\"Distance\":512,\"debug\":{\"length\":12,\"payload\":\"0520618a0010gfhfg030200\",\"port\":18,\"server_time\":\"2021-12-15T13:02:16.283Z\"},\"lastResetCause\":\"lastResetCause: 16\",\"mcuFirmware\":\"fwVersion: 2.0.0\",\"status\":{\"mode\":{\"code\":1,\"description\":\"Motion tracking\"},\"moving\":false,\"on_demand\":false,\"periodic\":false,\"sos\":false,\"tracking\":false},\"temperature\":25.81,\"type\":\"HEARTBEAT\"},\"rx_metadata\":[{\"gateway_ids\":{\"gateway_id\":\"dhdth-mdhdfhfn-01-dbn\",\"eui\":\"3dhdfhdfgh0\"},\"time\":\"2021-12-15T13:02:15.958012Z\",\"timestamp\":534735231,\"rssi\":-109,\"channel_rssi\":-109,\"snr\":1.75,\"location\":{\"latitude\":-505059.885050571,\"longitude\":5050.905081617,\"altitude\":225,\"source\":\"SOURCE_REGISTRY\"},\"uplink_token\":\"CiIKIAoUdGVjaDUtbWFsdmVybi0wMS1kYm4SCDQ2MjgkAFAAEP/S/f4BGgsI2M7njQYQ1+/aICCYsNCFyP3/ASoMCNfO540GEOC06MgD\",\"channel_index\":4}],\"settings\":{\"data_rate\":{\"lora\":{\"bandwidth\":125000,\"spreading_factor\":7}},\"coding_rate\":\"4/5\",\"frequency\":\"867300000\",\"timestamp\":534735231,\"time\":\"2021-12-15T13:02:15.958012Z\"},\"received_at\":\"2021-12-15T13:02:16.069864716Z\",\"consumed_airtime\":\"0.061696s\",\"locations\":{\"frm-payload\":{\"latitude\":-29.8889728,\"longitude\":30.916608,\"source\":\"SOURCE_GPS\"}},\"network_ids\":{\"net_id\":\"000013\",\"tenant_id\":\"ttn\",\"cluster_id\":\"ttn-eu1\"}}},\"qos\":0,\"retain\":false,\"_msgid\":\"d38de075552048d0\"}",
        "payloadType": "json",
        "x": 230,
        "y": 360,
        "wires": [
            [
                "99997bbb40d80fb0"
            ]
        ]
    },
    {
        "id": "99997bbb40d80fb0",
        "type": "change",
        "z": "153ff67d1f2c61b8",
        "name": "Test Json",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 360,
        "y": 360,
        "wires": [
            [
                "059296a9a604036f",
                "1ae3c6d92610a908"
            ]
        ]
    },
    {
        "id": "3f4efbddb8220f44",
        "type": "comment",
        "z": "153ff67d1f2c61b8",
        "name": "For Testing",
        "info": "",
        "x": 210,
        "y": 320,
        "wires": []
    },
    {
        "id": "0a4f4fef6fee57c6",
        "type": "mqtt-broker",
        "name": "Füllstand Quelle",
        "broker": "eu1.cloud.thethings.network",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "sessionExpiry": ""
    }
]

image

Thank you very much!
I like the solution and I’m very thankful for your very useful tips!
I also like the testing via the inject node. I did not know this trick… I just waited for the next payload from the LoraNode.

Okay first of all you are writing the distance and the deveui into msg.Distance and msg.deveui and then you are deleting everything from the stream we don’t want to save into the DB. Do I understand that correctly?

!The question is obsolete! I’ve found a solution!

Now I have an additional question. Now the “Distance” stands for the distance between an ultrasonic sensor and a water level.
Now I want to have the height of the water. The mathematical solution for this is to subtract"2300" from the measurement and multiply it by “-1”.
I’m pretty sure you would do this with a function node but I’m having trouble taking the msg.Distance and calculate with the number.

There is a “Copy Value” Button.

dwJ9uLCIM0

and past in inject node, press the … and delete what ever is in the window and past your JSON, hit “Done”, Done" and “Deploy”

Now you can inject your JSON into the flow.

image

Some math in the function node, or you can save DB space and do it when you display the data, if you use Grafana or the likes easy to do there.

I don’t like extra long JSON, only the necessities.

Save the electrons from flowing :smiling_imp:

[
    {
        "id": "153ff67d1f2c61b8",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "8e52c3ed8907ee0c",
        "type": "mqtt in",
        "z": "153ff67d1f2c61b8",
        "name": "Füllstand Quelle",
        "topic": "v3/DEVICEID@ttn/devices/+/up",
        "qos": "2",
        "datatype": "json",
        "broker": "0a4f4fef6fee57c6",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 220,
        "y": 260,
        "wires": [
            [
                "059296a9a604036f"
            ]
        ]
    },
    {
        "id": "059296a9a604036f",
        "type": "change",
        "z": "153ff67d1f2c61b8",
        "name": "change node",
        "rules": [
            {
                "t": "set",
                "p": "Distance",
                "pt": "msg",
                "to": "payload.uplink_message.decoded_payload.Distance",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "dev_eui",
                "pt": "msg",
                "to": "payload.end_device_ids.device_id",
                "tot": "msg"
            },
            {
                "t": "delete",
                "p": "payload.uplink_message",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "payload.correlation_ids",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "payload",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "topic",
                "pt": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 510,
        "y": 260,
        "wires": [
            [
                "a99ae555ccc4abb5"
            ]
        ]
    },
    {
        "id": "1ae3c6d92610a908",
        "type": "debug",
        "z": "153ff67d1f2c61b8",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 530,
        "y": 360,
        "wires": []
    },
    {
        "id": "c4aa3711222d1081",
        "type": "debug",
        "z": "153ff67d1f2c61b8",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "dev_eui",
        "statusType": "auto",
        "x": 870,
        "y": 260,
        "wires": []
    },
    {
        "id": "60f39d916a35dd8b",
        "type": "inject",
        "z": "153ff67d1f2c61b8",
        "name": "Test Json",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"topic\":\"v3/compact-tracker-abeeway@ttn/devices/eui-20635f0161000093/up\",\"payload\":{\"end_device_ids\":{\"device_id\":\"eui-dhdfth\",\"application_ids\":{\"application_id\":\"fjdjdy\"},\"dev_eui\":\"hth3\",\"join_eui\":\"hrhxf\",\"dev_addr\":\"hhF\"},\"correlation_ids\":[\"as:up:01FPZ2ZC6PJQE0XQ68ECN239B7\",\"gs:conn:01FNXTS68EYM139F0J53QR5ZK0\",\"gs:up:host:01FNXTS699E4A2H7VSP45SZG62\",\"gs:uplink:01FPZ2ZC04E8WTWP10DHJX97S6\",\"ns:uplink:01FPZ2ZC0568ACBK2MBZQK4148\",\"rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01FPZ2ZC052XX7N17EDTRCYW6D\",\"rpc:/ttn.lorawan.v3.NsAs/HandleUplink:01FPZ2ZC6MRZ4WAM86KEJC7J6B\"],\"received_at\":\"2021-12-15T13:02:16.279389076Z\",\"uplink_message\":{\"session_key_id\":\"AX23nQJEOCVpz1fId9ugRw==\",\"f_port\":18,\"f_cnt\":182,\"frm_payload\":\"BSBhigAQAgAAAwIA\",\"decoded_payload\":{\"ack\":0,\"batteryPersentage\":97,\"bleFirmware\":\"bleFwVersion3.2.0\",\"data\":0,\"Distance\":512,\"debug\":{\"length\":12,\"payload\":\"0520618a0010gfhfg030200\",\"port\":18,\"server_time\":\"2021-12-15T13:02:16.283Z\"},\"lastResetCause\":\"lastResetCause: 16\",\"mcuFirmware\":\"fwVersion: 2.0.0\",\"status\":{\"mode\":{\"code\":1,\"description\":\"Motion tracking\"},\"moving\":false,\"on_demand\":false,\"periodic\":false,\"sos\":false,\"tracking\":false},\"temperature\":25.81,\"type\":\"HEARTBEAT\"},\"rx_metadata\":[{\"gateway_ids\":{\"gateway_id\":\"dhdth-mdhdfhfn-01-dbn\",\"eui\":\"3dhdfhdfgh0\"},\"time\":\"2021-12-15T13:02:15.958012Z\",\"timestamp\":534735231,\"rssi\":-109,\"channel_rssi\":-109,\"snr\":1.75,\"location\":{\"latitude\":-505059.885050571,\"longitude\":5050.905081617,\"altitude\":225,\"source\":\"SOURCE_REGISTRY\"},\"uplink_token\":\"CiIKIAoUdGVjaDUtbWFsdmVybi0wMS1kYm4SCDQ2MjgkAFAAEP/S/f4BGgsI2M7njQYQ1+/aICCYsNCFyP3/ASoMCNfO540GEOC06MgD\",\"channel_index\":4}],\"settings\":{\"data_rate\":{\"lora\":{\"bandwidth\":125000,\"spreading_factor\":7}},\"coding_rate\":\"4/5\",\"frequency\":\"867300000\",\"timestamp\":534735231,\"time\":\"2021-12-15T13:02:15.958012Z\"},\"received_at\":\"2021-12-15T13:02:16.069864716Z\",\"consumed_airtime\":\"0.061696s\",\"locations\":{\"frm-payload\":{\"latitude\":-29.8889728,\"longitude\":30.916608,\"source\":\"SOURCE_GPS\"}},\"network_ids\":{\"net_id\":\"000013\",\"tenant_id\":\"ttn\",\"cluster_id\":\"ttn-eu1\"}}},\"qos\":0,\"retain\":false,\"_msgid\":\"d38de075552048d0\"}",
        "payloadType": "json",
        "x": 230,
        "y": 360,
        "wires": [
            [
                "99997bbb40d80fb0"
            ]
        ]
    },
    {
        "id": "99997bbb40d80fb0",
        "type": "change",
        "z": "153ff67d1f2c61b8",
        "name": "Test Json",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 360,
        "y": 360,
        "wires": [
            [
                "059296a9a604036f",
                "1ae3c6d92610a908"
            ]
        ]
    },
    {
        "id": "3f4efbddb8220f44",
        "type": "comment",
        "z": "153ff67d1f2c61b8",
        "name": "For Testing",
        "info": "",
        "x": 210,
        "y": 320,
        "wires": []
    },
    {
        "id": "a99ae555ccc4abb5",
        "type": "function",
        "z": "153ff67d1f2c61b8",
        "name": "level",
        "func": "msg.level =  msg.Distance - 2300\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 700,
        "y": 260,
        "wires": [
            [
                "c4aa3711222d1081"
            ]
        ]
    },
    {
        "id": "0a4f4fef6fee57c6",
        "type": "mqtt-broker",
        "name": "Füllstand Quelle",
        "broker": "eu1.cloud.thethings.network",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "sessionExpiry": ""
    }
]

Very cool!

Okay that’s as i expected another approach to this “problem”.
I installed a calculator Plugin and did it with this.

[
    {
        "id": "dec69ff8f39faf70",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "9c6d69e06c2386f7",
        "type": "change",
        "z": "dec69ff8f39faf70",
        "name": "change node",
        "rules": [
            {
                "t": "set",
                "p": "Distance",
                "pt": "msg",
                "to": "payload.uplink_message.decoded_payload.Distance",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "dev_eui",
                "pt": "msg",
                "to": "payload.end_device_ids.device_id",
                "tot": "msg"
            },
            {
                "t": "delete",
                "p": "payload.uplink_message",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "payload.correlation_ids",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "payload",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "topic",
                "pt": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 430,
        "y": 240,
        "wires": [
            [
                "c7fe070daa6649a2"
            ]
        ]
    },
    {
        "id": "9a2ef07e29a54a89",
        "type": "debug",
        "z": "dec69ff8f39faf70",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "dev_eui",
        "statusType": "auto",
        "x": 950,
        "y": 60,
        "wires": []
    },
    {
        "id": "c7fe070daa6649a2",
        "type": "calculator",
        "z": "dec69ff8f39faf70",
        "name": "-2300",
        "inputMsgField": "Distance",
        "outputMsgField": "Distance",
        "operation": "sub",
        "constant": "2300",
        "round": true,
        "decimals": "2",
        "x": 550,
        "y": 180,
        "wires": [
            [
                "dc8fb232d449aaa2"
            ]
        ]
    },
    {
        "id": "dc8fb232d449aaa2",
        "type": "calculator",
        "z": "dec69ff8f39faf70",
        "name": "x-1",
        "inputMsgField": "Distance",
        "outputMsgField": "Distance",
        "operation": "mult",
        "constant": "-1",
        "round": true,
        "decimals": "2",
        "x": 670,
        "y": 140,
        "wires": [
            [
                "11f0bf4bb0abba44"
            ]
        ]
    },
    {
        "id": "11f0bf4bb0abba44",
        "type": "calculator",
        "z": "dec69ff8f39faf70",
        "name": "x1,64x1,417",
        "inputMsgField": "Distance",
        "outputMsgField": "Füllmenge",
        "operation": "mult",
        "constant": "2.32388",
        "round": true,
        "decimals": "0",
        "x": 810,
        "y": 100,
        "wires": [
            [
                "9a2ef07e29a54a89",
                "ba2599eea969d74a"
            ]
        ]
    },
    {
        "id": "ba2599eea969d74a",
        "type": "influxdb out",
        "z": "dec69ff8f39faf70",
        "influxdb": "9f2a7e530ba069af",
        "name": "Influxdb fuellstandquelle",
        "measurement": "distanz",
        "precision": "",
        "retentionPolicy": "",
        "database": "database",
        "precisionV18FluxV20": "ms",
        "retentionPolicyV18Flux": "",
        "org": "organisation",
        "bucket": "bucket",
        "x": 1010,
        "y": 140,
        "wires": []
    },
    {
        "id": "06f471c9d70fc21f",
        "type": "mqtt in",
        "z": "dec69ff8f39faf70",
        "name": "Füllstand Quelle",
        "topic": "v3/fuellstandquelle@ttn/devices/+/up",
        "qos": "2",
        "datatype": "json",
        "broker": "0a4f4fef6fee57c6",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 140,
        "y": 240,
        "wires": [
            [
                "9c6d69e06c2386f7",
                "4962ee966ff9499e"
            ]
        ]
    },
    {
        "id": "4962ee966ff9499e",
        "type": "debug",
        "z": "dec69ff8f39faf70",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 310,
        "y": 160,
        "wires": []
    },
    {
        "id": "9f2a7e530ba069af",
        "type": "influxdb",
        "hostname": "localhost",
        "port": "8086",
        "protocol": "http",
        "database": "fuellstandquelle",
        "name": "Influx DB fuellstandquelle",
        "usetls": false,
        "tls": "",
        "influxdbVersion": "1.x",
        "url": "http://localhost:8086",
        "rejectUnauthorized": true
    },
    {
        "id": "0a4f4fef6fee57c6",
        "type": "mqtt-broker",
        "name": "Füllstand Quelle",
        "broker": "eu1.cloud.thethings.network",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "sessionExpiry": ""
    }
]

That is my approach and it’s working and I’m fine with that…
Thats the calculator if you need it.

But I can’t save the result into my db.

Screenshot (42)
Screenshot (44)
Screenshot (43)

I have another question.
Is there a reason you are not deleting the “_msgid”?

The “_msgid” does not matter, used in node-red to ID the JSON packet.

This is a setting in your Influx DB, read there documentation on retention policies.
image

Far to many nodes needed.

Look at this flow.

[
    {
        "id": "153ff67d1f2c61b8",
        "type": "tab",
        "label": "Flow 2sddsdvv",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "8e52c3ed8907ee0c",
        "type": "mqtt in",
        "z": "153ff67d1f2c61b8",
        "name": "Füllstand Quelle",
        "topic": "v3/DEVICEID@ttn/devices/+/up",
        "qos": "2",
        "datatype": "json",
        "broker": "0a4f4fef6fee57c6",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 220,
        "y": 260,
        "wires": [
            [
                "059296a9a604036f"
            ]
        ]
    },
    {
        "id": "059296a9a604036f",
        "type": "change",
        "z": "153ff67d1f2c61b8",
        "name": "change node",
        "rules": [
            {
                "t": "set",
                "p": "payload.Distance",
                "pt": "msg",
                "to": "payload.uplink_message.decoded_payload.Distance",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "payload.dev_eui",
                "pt": "msg",
                "to": "payload.end_device_ids.dev_eui",
                "tot": "msg"
            },
            {
                "t": "delete",
                "p": "payload.uplink_message",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "payload.correlation_ids",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "topic",
                "pt": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 510,
        "y": 260,
        "wires": [
            [
                "a99ae555ccc4abb5",
                "c4aa3711222d1081"
            ]
        ]
    },
    {
        "id": "1ae3c6d92610a908",
        "type": "debug",
        "z": "153ff67d1f2c61b8",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 530,
        "y": 360,
        "wires": []
    },
    {
        "id": "c4aa3711222d1081",
        "type": "debug",
        "z": "153ff67d1f2c61b8",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "dev_eui",
        "statusType": "auto",
        "x": 850,
        "y": 360,
        "wires": []
    },
    {
        "id": "60f39d916a35dd8b",
        "type": "inject",
        "z": "153ff67d1f2c61b8",
        "name": "Test Json",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"topic\":\"v3/compact-tracker-abeeway@ttn/devices/eui-20635f0161000093/up\",\"payload\":{\"end_device_ids\":{\"device_id\":\"eui-dhdfth\",\"application_ids\":{\"application_id\":\"fjdjdy\"},\"dev_eui\":\"hth3\",\"join_eui\":\"hrhxf\",\"dev_addr\":\"hhF\"},\"correlation_ids\":[\"as:up:01FPZ2ZC6PJQE0XQ68ECN239B7\",\"gs:conn:01FNXTS68EYM139F0J53QR5ZK0\",\"gs:up:host:01FNXTS699E4A2H7VSP45SZG62\",\"gs:uplink:01FPZ2ZC04E8WTWP10DHJX97S6\",\"ns:uplink:01FPZ2ZC0568ACBK2MBZQK4148\",\"rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01FPZ2ZC052XX7N17EDTRCYW6D\",\"rpc:/ttn.lorawan.v3.NsAs/HandleUplink:01FPZ2ZC6MRZ4WAM86KEJC7J6B\"],\"received_at\":\"2021-12-15T13:02:16.279389076Z\",\"uplink_message\":{\"session_key_id\":\"AX23nQJEOCVpz1fId9ugRw==\",\"f_port\":18,\"f_cnt\":182,\"frm_payload\":\"BSBhigAQAgAAAwIA\",\"decoded_payload\":{\"ack\":0,\"batteryPersentage\":97,\"bleFirmware\":\"bleFwVersion3.2.0\",\"data\":0,\"Distance\":512,\"debug\":{\"length\":12,\"payload\":\"0520618a0010gfhfg030200\",\"port\":18,\"server_time\":\"2021-12-15T13:02:16.283Z\"},\"lastResetCause\":\"lastResetCause: 16\",\"mcuFirmware\":\"fwVersion: 2.0.0\",\"status\":{\"mode\":{\"code\":1,\"description\":\"Motion tracking\"},\"moving\":false,\"on_demand\":false,\"periodic\":false,\"sos\":false,\"tracking\":false},\"temperature\":25.81,\"type\":\"HEARTBEAT\"},\"rx_metadata\":[{\"gateway_ids\":{\"gateway_id\":\"dhdth-mdhdfhfn-01-dbn\",\"eui\":\"3dhdfhdfgh0\"},\"time\":\"2021-12-15T13:02:15.958012Z\",\"timestamp\":534735231,\"rssi\":-109,\"channel_rssi\":-109,\"snr\":1.75,\"location\":{\"latitude\":-505059.885050571,\"longitude\":5050.905081617,\"altitude\":225,\"source\":\"SOURCE_REGISTRY\"},\"uplink_token\":\"CiIKIAoUdGVjaDUtbWFsdmVybi0wMS1kYm4SCDQ2MjgkAFAAEP/S/f4BGgsI2M7njQYQ1+/aICCYsNCFyP3/ASoMCNfO540GEOC06MgD\",\"channel_index\":4}],\"settings\":{\"data_rate\":{\"lora\":{\"bandwidth\":125000,\"spreading_factor\":7}},\"coding_rate\":\"4/5\",\"frequency\":\"867300000\",\"timestamp\":534735231,\"time\":\"2021-12-15T13:02:15.958012Z\"},\"received_at\":\"2021-12-15T13:02:16.069864716Z\",\"consumed_airtime\":\"0.061696s\",\"locations\":{\"frm-payload\":{\"latitude\":-29.8889728,\"longitude\":30.916608,\"source\":\"SOURCE_GPS\"}},\"network_ids\":{\"net_id\":\"000013\",\"tenant_id\":\"ttn\",\"cluster_id\":\"ttn-eu1\"}}},\"qos\":0,\"retain\":false,\"_msgid\":\"d38de075552048d0\"}",
        "payloadType": "json",
        "x": 230,
        "y": 360,
        "wires": [
            [
                "99997bbb40d80fb0"
            ]
        ]
    },
    {
        "id": "99997bbb40d80fb0",
        "type": "change",
        "z": "153ff67d1f2c61b8",
        "name": "Test Json",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 360,
        "y": 360,
        "wires": [
            [
                "059296a9a604036f",
                "1ae3c6d92610a908"
            ]
        ]
    },
    {
        "id": "3f4efbddb8220f44",
        "type": "comment",
        "z": "153ff67d1f2c61b8",
        "name": "For Testing",
        "info": "",
        "x": 210,
        "y": 320,
        "wires": []
    },
    {
        "id": "a99ae555ccc4abb5",
        "type": "function",
        "z": "153ff67d1f2c61b8",
        "name": "level",
        "func": "msg.payload.Füllmenge =  (2300 - msg.payload.Distance)*2.32388\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 700,
        "y": 260,
        "wires": [
            [
                "c4aa3711222d1081"
            ]
        ]
    },
    {
        "id": "0a4f4fef6fee57c6",
        "type": "mqtt-broker",
        "name": "Füllstand Quelle",
        "broker": "eu1.cloud.thethings.network",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "sessionExpiry": ""
    }
]

Well, when I’m looking at the two rows of code I’m feeling stupid… :smiley:
Thank you for showing me this solution.

Then there is only the problem with the DB left…
I’m very confused about the error.

I don’t mean the problem with the retention of the data…

I am here to learn, there are no stupid questions.

Try that flow, I had to brush up on Influxdb, not my 1st choice for a DB.

Yes, that’s true but sometimes I’m feeling stupid. even if I’m learning a lot of things by trying things iv never done before…

Error: A 400 Bad Request error occurred: {"error":"unable to parse 'distanz Distance=510,Füllmenge=4159.7452,dev_eui=\"\",end_device_ids=[object Object],received_at=\"2021-12-15T20:10:26.405479754Z\"': invalid boolean"}

There’s still the same error with the DB…
I would say that’s a problem with the “Measurement” in the DB Node

Because we did not delete ‘msg.payload.end_device_ids’ from the JSON

[
    {
        "id": "059296a9a604036f",
        "type": "change",
        "z": "454b7c0d2cc14647",
        "name": "change node",
        "rules": [
            {
                "t": "set",
                "p": "payload.Distance",
                "pt": "msg",
                "to": "payload.uplink_message.decoded_payload.Distance",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "payload.dev_eui",
                "pt": "msg",
                "to": "payload.end_device_ids.dev_eui",
                "tot": "msg"
            },
            {
                "t": "delete",
                "p": "payload.uplink_message",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "payload.correlation_ids",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "topic",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "payload.end_device_ids",
                "pt": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 450,
        "y": 1020,
        "wires": [
            [
                "a99ae555ccc4abb5",
                "c4aa3711222d1081"
            ]
        ]
    },
    {
        "id": "1ae3c6d92610a908",
        "type": "debug",
        "z": "454b7c0d2cc14647",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 470,
        "y": 1120,
        "wires": []
    },
    {
        "id": "c4aa3711222d1081",
        "type": "debug",
        "z": "454b7c0d2cc14647",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "dev_eui",
        "statusType": "auto",
        "x": 790,
        "y": 1120,
        "wires": []
    },
    {
        "id": "60f39d916a35dd8b",
        "type": "inject",
        "z": "454b7c0d2cc14647",
        "name": "Test Json",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"topic\":\"v3/compact-tracker-abeeway@ttn/devices/eui-20635f0161000093/up\",\"payload\":{\"end_device_ids\":{\"device_id\":\"eui-dhdfth\",\"application_ids\":{\"application_id\":\"fjdjdy\"},\"dev_eui\":\"hth3\",\"join_eui\":\"hrhxf\",\"dev_addr\":\"hhF\"},\"correlation_ids\":[\"as:up:01FPZ2ZC6PJQE0XQ68ECN239B7\",\"gs:conn:01FNXTS68EYM139F0J53QR5ZK0\",\"gs:up:host:01FNXTS699E4A2H7VSP45SZG62\",\"gs:uplink:01FPZ2ZC04E8WTWP10DHJX97S6\",\"ns:uplink:01FPZ2ZC0568ACBK2MBZQK4148\",\"rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01FPZ2ZC052XX7N17EDTRCYW6D\",\"rpc:/ttn.lorawan.v3.NsAs/HandleUplink:01FPZ2ZC6MRZ4WAM86KEJC7J6B\"],\"received_at\":\"2021-12-15T13:02:16.279389076Z\",\"uplink_message\":{\"session_key_id\":\"AX23nQJEOCVpz1fId9ugRw==\",\"f_port\":18,\"f_cnt\":182,\"frm_payload\":\"BSBhigAQAgAAAwIA\",\"decoded_payload\":{\"ack\":0,\"batteryPersentage\":97,\"bleFirmware\":\"bleFwVersion3.2.0\",\"data\":0,\"Distance\":512,\"debug\":{\"length\":12,\"payload\":\"0520618a0010gfhfg030200\",\"port\":18,\"server_time\":\"2021-12-15T13:02:16.283Z\"},\"lastResetCause\":\"lastResetCause: 16\",\"mcuFirmware\":\"fwVersion: 2.0.0\",\"status\":{\"mode\":{\"code\":1,\"description\":\"Motion tracking\"},\"moving\":false,\"on_demand\":false,\"periodic\":false,\"sos\":false,\"tracking\":false},\"temperature\":25.81,\"type\":\"HEARTBEAT\"},\"rx_metadata\":[{\"gateway_ids\":{\"gateway_id\":\"dhdth-mdhdfhfn-01-dbn\",\"eui\":\"3dhdfhdfgh0\"},\"time\":\"2021-12-15T13:02:15.958012Z\",\"timestamp\":534735231,\"rssi\":-109,\"channel_rssi\":-109,\"snr\":1.75,\"location\":{\"latitude\":-505059.885050571,\"longitude\":5050.905081617,\"altitude\":225,\"source\":\"SOURCE_REGISTRY\"},\"uplink_token\":\"CiIKIAoUdGVjaDUtbWFsdmVybi0wMS1kYm4SCDQ2MjgkAFAAEP/S/f4BGgsI2M7njQYQ1+/aICCYsNCFyP3/ASoMCNfO540GEOC06MgD\",\"channel_index\":4}],\"settings\":{\"data_rate\":{\"lora\":{\"bandwidth\":125000,\"spreading_factor\":7}},\"coding_rate\":\"4/5\",\"frequency\":\"867300000\",\"timestamp\":534735231,\"time\":\"2021-12-15T13:02:15.958012Z\"},\"received_at\":\"2021-12-15T13:02:16.069864716Z\",\"consumed_airtime\":\"0.061696s\",\"locations\":{\"frm-payload\":{\"latitude\":-29.8889728,\"longitude\":30.916608,\"source\":\"SOURCE_GPS\"}},\"network_ids\":{\"net_id\":\"000013\",\"tenant_id\":\"ttn\",\"cluster_id\":\"ttn-eu1\"}}},\"qos\":0,\"retain\":false,\"_msgid\":\"d38de075552048d0\"}",
        "payloadType": "json",
        "x": 170,
        "y": 1120,
        "wires": [
            [
                "99997bbb40d80fb0"
            ]
        ]
    },
    {
        "id": "99997bbb40d80fb0",
        "type": "change",
        "z": "454b7c0d2cc14647",
        "name": "Test Json",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 300,
        "y": 1120,
        "wires": [
            [
                "059296a9a604036f",
                "1ae3c6d92610a908"
            ]
        ]
    },
    {
        "id": "3f4efbddb8220f44",
        "type": "comment",
        "z": "454b7c0d2cc14647",
        "name": "For Testing",
        "info": "",
        "x": 150,
        "y": 1080,
        "wires": []
    },
    {
        "id": "a99ae555ccc4abb5",
        "type": "function",
        "z": "454b7c0d2cc14647",
        "name": "level",
        "func": "msg.payload.Füllmenge =  (2300 - msg.payload.Distance)*2.32388\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 640,
        "y": 1020,
        "wires": [
            [
                "c4aa3711222d1081",
                "ac3964d106fdecc3"
            ]
        ]
    },
    {
        "id": "ac3964d106fdecc3",
        "type": "influxdb out",
        "z": "454b7c0d2cc14647",
        "influxdb": "bb5dec3a1b53afc0",
        "name": "nodemap in",
        "measurement": "distanz",
        "precision": "",
        "retentionPolicy": "",
        "database": "database",
        "precisionV18FluxV20": "ms",
        "retentionPolicyV18Flux": "",
        "org": "organisation",
        "bucket": "bucket",
        "x": 950,
        "y": 1040,
        "wires": []
    },
    {
        "id": "bb5dec3a1b53afc0",
        "type": "influxdb",
        "hostname": "127.0.0.1",
        "port": "8086",
        "protocol": "http",
        "database": "distanz",
        "name": "",
        "usetls": false,
        "tls": "7f61ad963cfa96fb",
        "influxdbVersion": "1.x",
        "url": "http://localhost:8086",
        "rejectUnauthorized": true
    },
    {
        "id": "7f61ad963cfa96fb",
        "type": "tls-config",
        "name": "",
        "cert": "",
        "key": "",
        "ca": "",
        "certname": "",
        "keyname": "",
        "caname": "",
        "servername": "",
        "verifyservercert": true,
        "alpnprotocol": ""
    }
]

image

image

1 Like

Yes, you are completely right. The only thing I don’t like is that now I’m saving “Füllmenge” values like this: “4157.4213199999995”. I need to fix this in the next step.
Why does this message make this problem?
I need to understand what I’m able to save and what doing errors are like this.

I have a similar problem with a flow but there is no msg like that.

[
    {
        "id": "9c24fe17e2b4595c",
        "type": "tab",
        "label": "Flow 5",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "095152322e671325",
        "type": "mqtt in",
        "z": "9c24fe17e2b4595c",
        "name": "Temparatur ",
        "topic": "v3/themparatur1@ttn/devices/+/up",
        "qos": "2",
        "datatype": "json",
        "broker": "0609d37da1a4a29b",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 370,
        "y": 280,
        "wires": [
            [
                "26c486158f93296b",
                "808a392ee0f14c26"
            ]
        ]
    },
    {
        "id": "0c34f16c12515dd8",
        "type": "influxdb out",
        "z": "9c24fe17e2b4595c",
        "influxdb": "29f2f16219709fb9",
        "name": "Influxdb temparatursensor1",
        "measurement": "sensorshopf",
        "precision": "",
        "retentionPolicy": "",
        "database": "database",
        "precisionV18FluxV20": "ms",
        "retentionPolicyV18Flux": "",
        "org": "organisation",
        "bucket": "bucket",
        "x": 920,
        "y": 300,
        "wires": []
    },
    {
        "id": "26c486158f93296b",
        "type": "debug",
        "z": "9c24fe17e2b4595c",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 570,
        "y": 260,
        "wires": []
    },
    {
        "id": "36435addeb3bb719",
        "type": "debug",
        "z": "9c24fe17e2b4595c",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 850,
        "y": 260,
        "wires": []
    },
    {
        "id": "808a392ee0f14c26",
        "type": "change",
        "z": "9c24fe17e2b4595c",
        "name": "change node",
        "rules": [
            {
                "t": "set",
                "p": "temp",
                "pt": "msg",
                "to": "payload.uplink_message.decoded_payload.TempC_SHT",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "hum",
                "pt": "msg",
                "to": "payload.uplink_message.decoded_payload.Hum_SHT",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "dev_eui",
                "pt": "msg",
                "to": "payload.end_device_ids.device_id",
                "tot": "msg"
            },
            {
                "t": "delete",
                "p": "payload.uplink_message",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "payload.correlation_ids",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "payload",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "topic",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "qos",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "retain",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "qos",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "msg.payload.end_device_ids",
                "pt": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 570,
        "y": 300,
        "wires": [
            [
                "36435addeb3bb719",
                "0c34f16c12515dd8"
            ]
        ]
    },
    {
        "id": "0609d37da1a4a29b",
        "type": "mqtt-broker",
        "name": "Temparatur Sensor",
        "broker": "eu1.cloud.thethings.network",
        "port": "1883",
        "tls": "",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "sessionExpiry": ""
    },
    {
        "id": "29f2f16219709fb9",
        "type": "influxdb",
        "hostname": "localhost",
        "port": "8086",
        "protocol": "http",
        "database": "temparatursensor1",
        "name": "Influxdb temparatursensor1",
        "usetls": false,
        "tls": "",
        "influxdbVersion": "1.x",
        "url": "http://localhost:8086",
        "rejectUnauthorized": true
    }
]

Its a Dragino LHT65 and I’m filtering the messages the same way we did on the distance flow. But there is the same error but I only have the following messages.

{"_msgid":"8c0ece481a3c8051","temp":1.53,"hum":99.8,"dev_eui":"eui-a84041f4218401dc"}

And there is something else I want to know if I understand it correctly.
The “_msgid” is just a marker for the message in Node-red right?
It won’t be saved into the DB if I don’t delete it?
Its not in the db from the distance flow but im not sure if I understand this correctly.

It is just the accuracy of the calculation, you are using a constant of 2.32388, so you are going to get a few decimals.

Change the function node to

msg.payload.Füllmenge =  Math.round((2300 - msg.payload.Distance)*2.32388);

Yes, Influx needs the measurements as msg.payload.temp, msg.payload.hum, you are omitting the payload part.

Read the help

image

[
    {
        "id": "808a392ee0f14c26",
        "type": "change",
        "z": "9c24fe17e2b4595c",
        "name": "change node",
        "rules": [
            {
                "t": "set",
                "p": "payload.temp",
                "pt": "msg",
                "to": "payload.uplink_message.decoded_payload.TempC_SHT",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "payload.hum",
                "pt": "msg",
                "to": "payload.uplink_message.decoded_payload.Hum_SHT",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "payload.dev_eui",
                "pt": "msg",
                "to": "payload.end_device_ids.device_id",
                "tot": "msg"
            },
            {
                "t": "delete",
                "p": "payload.uplink_message",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "payload.correlation_ids",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "topic",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "qos",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "retain",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "qos",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "msg.payload.end_device_ids",
                "pt": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 570,
        "y": 300,
        "wires": [
            [
                "36435addeb3bb719",
                "0c34f16c12515dd8"
            ]
        ]
    }
]

For node-red only, it is to keep track of JSON, there are a few other properties it adds in certain circumstances, but I will not go into that now.

Yeah, I know. I already wrote a similar code like you did to “fix” this. Now it’s working very well.
I don’t need the value to be that exact… It’s a water tank with a little over 4000l so it’s not important that the value is that exact.

Now everything is working :slight_smile:
I hat a lot of flows with this exact same “user error” and now all of them are up and running.

Thank you very much! you helped me there a lot! @Johan_Scheepers

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.