• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

MQTT values not updating

Q&A Forum › Category: Home Automation › MQTT values not updating
0 Vote Up Vote Down
Heribert Houben asked 1 year ago

Now that I finally managed to connect my influx DB to a  tasmota sensor reading in node red  a new problemm comes up:
The values are not updating. The tasmota device publishes values every second.
Node Red says: MQTT is connected.
But I get old values and differing timestamps like this:
31.1.2024, 22:30:28 node: debug   <–  this  is the timestamp i get when I update the node manually         
tasmota/discovery/A848FADECFE9/sensors : msg.payload : Object
object
sn: object
Time: “2024-01-31T21:52:45”       <— this ist the timestamp of the values I get after this update, they are  OLD

SML: object
1_8_0: 7946.0170116

…..
I need the current values every second  Why is the noden not updating when the MQTT device fires a message to the Broker?
 
Here is my flow:
 
 
[
{
“id”: “89ec33379a2f6a44”,
“type”: “tab”,
“label”: “Flow 1”,
“disabled”: false,
“info”: “”,
“env”: []
},
{
“id”: “57bfbe92105984a7”,
“type”: “mqtt in”,
“z”: “89ec33379a2f6a44”,
“name”: “”,
“topic”: “tasmota/discovery/A848FADECFE9/sensors”,
“qos”: “0”,
“datatype”: “json”,
“broker”: “9c160e61426b97c6”,
“nl”: false,
“rap”: true,
“rh”: 0,
“inputs”: 0,
“x”: 190,
“y”: 100,
“wires”: [
[
“7548e4605d5acba9”,
“90d2e020fc0e19b7”,
“f32617966e3c4c21”,
“1bf34ed7a9052b90”,
“945c14892f6dd987”,
“dbc8178f5f4a3fd9”
]
]
},
{
“id”: “cf2de51948212849”,
“type”: “debug”,
“z”: “89ec33379a2f6a44”,
“name”: “debug”,
“active”: true,
“tosidebar”: true,
“console”: false,
“tostatus”: false,
“complete”: “payload”,
“targetType”: “msg”,
“statusVal”: “”,
“statusType”: “auto”,
“x”: 1250,
“y”: 40,
“wires”: []
},
{
“id”: “7548e4605d5acba9”,
“type”: “function”,
“z”: “89ec33379a2f6a44”,
“name”: “function 1”,
“func”: “var str = msg.topic;\nvar array = str.split(‘/’)\nvar myDevice = array[2];\n\nif (!flow.get(\”tasmota_devices\”)) {\n flow.set(\”tasmota_devices\”, new Set());\n}\nflow.get(\”tasmota_devices\”).add(myDevice);\n\nvar sensorData = {\n device: myDevice,\n event: ‘tele’,\n total: msg.payload.sn.SML[\”1_8_0\”],\n aktpower: msg.payload.sn.SML[\”16_7_0\”],\n l1: msg.payload.sn.SML[\”36_7_0\”],\n l2: msg.payload.sn.SML[\”56_7_0\”],\n l3: msg.payload.sn.SML[\”76_7_0\”]\n}\nmsg.payload=sensorData.device;\n\n\n\nreturn msg;\n\n”,
“outputs”: 1,
“timeout”: 0,
“noerr”: 0,
“initialize”: “”,
“finalize”: “”,
“libs”: [],
“x”: 520,
“y”: 100,
“wires”: [
[
“2fc62debad9384b8”
]
]
},
{
“id”: “84b94a52bcaa8b0e”,
“type”: “ui_gauge”,
“z”: “89ec33379a2f6a44”,
“name”: “”,
“group”: “59ed30af4c06545f”,
“order”: 1,
“width”: 0,
“height”: 0,
“gtype”: “gage”,
“title”: “gauge1”,
“label”: “kWh”,
“format”: “{{value}}”,
“min”: 0,
“max”: “15000”,
“colors”: [
“#00b500”,
“#e6e600”,
“#ca3838”
],
“seg1”: “”,
“seg2”: “”,
“diff”: false,
“className”: “”,
“x”: 1280,
“y”: 240,
“wires”: []
},
{
“id”: “5d790abd1b5c4f9b”,
“type”: “ui_gauge”,
“z”: “89ec33379a2f6a44”,
“name”: “”,
“group”: “59ed30af4c06545f”,
“order”: 2,
“width”: 0,
“height”: 0,
“gtype”: “gage”,
“title”: “gauge2”,
“label”: “Watt”,
“format”: “{{value}}”,
“min”: 0,
“max”: “3000”,
“colors”: [
“#00b500”,
“#e6e600”,
“#ca3838”
],
“seg1”: “”,
“seg2”: “”,
“diff”: false,
“className”: “”,
“x”: 1280,
“y”: 280,
“wires”: []
},
{
“id”: “0eb99da93adb7db0”,
“type”: “ui_gauge”,
“z”: “89ec33379a2f6a44”,
“name”: “”,
“group”: “630144b18364e6f6”,
“order”: 5,
“width”: 0,
“height”: 0,
“gtype”: “gage”,
“title”: “gauge3”,
“label”: “units”,
“format”: “{{value}}”,
“min”: 0,
“max”: “3000”,
“colors”: [
“#00b500”,
“#e6e600”,
“#ca3838”
],
“seg1”: “”,
“seg2”: “”,
“diff”: false,
“className”: “”,
“x”: 1280,
“y”: 320,
“wires”: []
},
{
“id”: “3b04c08db61dc4c8”,
“type”: “ui_gauge”,
“z”: “89ec33379a2f6a44”,
“name”: “”,
“group”: “630144b18364e6f6”,
“order”: 6,
“width”: 0,
“height”: 0,
“gtype”: “gage”,
“title”: “gauge4”,
“label”: “units”,
“format”: “{{value}}”,
“min”: 0,
“max”: “3000”,
“colors”: [
“#00b500”,
“#e6e600”,
“#ca3838”
],
“seg1”: “”,
“seg2”: “”,
“diff”: false,
“className”: “”,
“x”: 1280,
“y”: 360,
“wires”: []
},
{
“id”: “3f8189accf225af8”,
“type”: “ui_gauge”,
“z”: “89ec33379a2f6a44”,
“name”: “”,
“group”: “c9ad275a4919e408”,
“order”: 1,
“width”: 0,
“height”: 0,
“gtype”: “gage”,
“title”: “gauge5”,
“label”: “units”,
“format”: “{{value}}”,
“min”: 0,
“max”: “3000”,
“colors”: [
“#00b500”,
“#e6e600”,
“#ca3838”
],
“seg1”: “”,
“seg2”: “”,
“diff”: false,
“className”: “”,
“x”: 1280,
“y”: 400,
“wires”: []
},
{
“id”: “22d4eedb8633f5da”,
“type”: “ui_text”,
“z”: “89ec33379a2f6a44”,
“group”: “39ae889322e0a09b”,
“order”: 2,
“width”: “3”,
“height”: “1”,
“name”: “”,
“label”: “text2”,
“format”: “{{msg.payload}}”,
“layout”: “col-center”,
“className”: “”,
“style”: true,
“font”: “”,
“fontSize”: “12”,
“color”: “#e01b24”,
“x”: 1270,
“y”: 200,
“wires”: []
},
{
“id”: “2fc62debad9384b8”,
“type”: “ui_text”,
“z”: “89ec33379a2f6a44”,
“group”: “39ae889322e0a09b”,
“order”: 1,
“width”: “2”,
“height”: “1”,
“name”: “”,
“label”: “text1”,
“format”: “{{msg.payload}}”,
“layout”: “col-center”,
“className”: “”,
“style”: true,
“font”: “”,
“fontSize”: “12”,
“color”: “#ff7f0e”,
“x”: 1270,
“y”: 160,
“wires”: []
},
{
“id”: “90d2e020fc0e19b7”,
“type”: “function”,
“z”: “89ec33379a2f6a44”,
“name”: “function 2”,
“func”: “var str = msg.topic;\nvar array = str.split(‘/’)\nvar myDevice = array[2];\n\nif (!flow.get(\”tasmota_devices\”)) {\n flow.set(\”tasmota_devices\”, new Set());\n}\nflow.get(\”tasmota_devices\”).add(myDevice);\n\nvar sensorData = {\n device: myDevice,\n event: ‘tele’,\n total: msg.payload.sn.SML[\”1_8_0\”],\n aktpower: msg.payload.sn.SML[\”16_7_0\”],\n l1: msg.payload.sn.SML[\”36_7_0\”],\n l2: msg.payload.sn.SML[\”56_7_0\”],\n l3: msg.payload.sn.SML[\”76_7_0\”]\n}\nmsg.payload=sensorData.event;\n\n\n\nreturn msg;\n\n”,
“outputs”: 1,
“timeout”: 0,
“noerr”: 0,
“initialize”: “”,
“finalize”: “”,
“libs”: [],
“x”: 520,
“y”: 160,
“wires”: [
[
“22d4eedb8633f5da”
]
]
},
{
“id”: “f32617966e3c4c21”,
“type”: “function”,
“z”: “89ec33379a2f6a44”,
“name”: “Gesamtverbrauch”,
“func”: “var str = msg.topic;\nvar array = str.split(‘/’)\nvar myDevice = array[2];\n\nif (!flow.get(\”tasmota_devices\”)) {\n flow.set(\”tasmota_devices\”, new Set());\n}\nflow.get(\”tasmota_devices\”).add(myDevice);\n\nvar sensorData = {\n device: myDevice,\n event: ‘tele’,\n total: msg.payload.sn.SML[\”1_8_0\”],\n aktpower: msg.payload.sn.SML[\”16_7_0\”],\n l1: msg.payload.sn.SML[\”36_7_0\”],\n l2: msg.payload.sn.SML[\”56_7_0\”],\n l3: msg.payload.sn.SML[\”76_7_0\”]\n}\nmsg.payload=sensorData.total;\n\n\n\nreturn msg;\n\n”,
“outputs”: 1,
“timeout”: 0,
“noerr”: 0,
“initialize”: “”,
“finalize”: “”,
“libs”: [],
“x”: 550,
“y”: 220,
“wires”: [
[
“84b94a52bcaa8b0e”,
“a8855c4f40d43411”
]
]
},
{
“id”: “1bf34ed7a9052b90”,
“type”: “function”,
“z”: “89ec33379a2f6a44”,
“name”: “L_total”,
“func”: “var str = msg.topic;\nvar array = str.split(‘/’)\nvar myDevice = array[2];\n\nif (!flow.get(\”tasmota_devices\”)) {\n flow.set(\”tasmota_devices\”, new Set());\n}\nflow.get(\”tasmota_devices\”).add(myDevice);\n\nvar sensorData = {\n device: myDevice,\n event: ‘tele’,\n total: msg.payload.sn.SML[\”1_8_0\”],\n aktpower: msg.payload.sn.SML[\”16_7_0\”],\n l1: msg.payload.sn.SML[\”36_7_0\”],\n l2: msg.payload.sn.SML[\”56_7_0\”],\n l3: msg.payload.sn.SML[\”76_7_0\”]\n}\nmsg.payload=sensorData.aktpower;\n\n\n\nreturn msg;\n\n”,
“outputs”: 1,
“timeout”: 0,
“noerr”: 0,
“initialize”: “”,
“finalize”: “”,
“libs”: [],
“x”: 510,
“y”: 280,
“wires”: [
[
“5d790abd1b5c4f9b”,
“8bc82d142984fb14”,
“654fa4528ff9f659”
]
]
},
{
“id”: “945c14892f6dd987”,
“type”: “function”,
“z”: “89ec33379a2f6a44”,
“name”: “L1”,
“func”: “var str = msg.topic;\nvar array = str.split(‘/’)\nvar myDevice = array[2];\n\nif (!flow.get(\”tasmota_devices\”)) {\n flow.set(\”tasmota_devices\”, new Set());\n}\nflow.get(\”tasmota_devices\”).add(myDevice);\n\nvar sensorData = {\n device: myDevice,\n event: ‘tele’,\n total: msg.payload.sn.SML[\”1_8_0\”],\n aktpower: msg.payload.sn.SML[\”16_7_0\”],\n l1: msg.payload.sn.SML[\”36_7_0\”],\n l2: msg.payload.sn.SML[\”56_7_0\”],\n l3: msg.payload.sn.SML[\”76_7_0\”]\n}\nmsg.payload=sensorData.l1;\n\n\n\nreturn msg;\n\n”,
“outputs”: 1,
“timeout”: 0,
“noerr”: 0,
“initialize”: “”,
“finalize”: “”,
“libs”: [],
“x”: 510,
“y”: 340,
“wires”: [
[
“0eb99da93adb7db0”,
“e4b2e7cfdd4b20a5”
]
]
},
{
“id”: “dbc8178f5f4a3fd9”,
“type”: “function”,
“z”: “89ec33379a2f6a44”,
“name”: “L2”,
“func”: “var str = msg.topic;\nvar array = str.split(‘/’)\nvar myDevice = array[2];\n\nif (!flow.get(\”tasmota_devices\”)) {\n flow.set(\”tasmota_devices\”, new Set());\n}\nflow.get(\”tasmota_devices\”).add(myDevice);\n\nvar sensorData = {\n device: myDevice,\n event: ‘tele’,\n total: msg.payload.sn.SML[\”1_8_0\”],\n aktpower: msg.payload.sn.SML[\”16_7_0\”],\n l1: msg.payload.sn.SML[\”36_7_0\”],\n l2: msg.payload.sn.SML[\”56_7_0\”],\n l3: msg.payload.sn.SML[\”76_7_0\”]\n}\nmsg.payload=sensorData.l2;\n\n\n\nreturn msg;\n\n”,
“outputs”: 1,
“timeout”: 0,
“noerr”: 0,
“initialize”: “”,
“finalize”: “”,
“libs”: [],
“x”: 510,
“y”: 400,
“wires”: [
[
“3b04c08db61dc4c8”,
“42857490893e3db5”
]
]
},
{
“id”: “32fab910e8780dee”,
“type”: “function”,
“z”: “89ec33379a2f6a44”,
“name”: “L3”,
“func”: “var str = msg.topic;\nvar array = str.split(‘/’)\nvar myDevice = array[2];\n\nif (!flow.get(\”tasmota_devices\”)) {\n flow.set(\”tasmota_devices\”, new Set());\n}\nflow.get(\”tasmota_devices\”).add(myDevice);\n\nvar sensorData = {\n device: myDevice,\n event: ‘tele’,\n total: msg.payload.sn.SML[\”1_8_0\”],\n aktpower: msg.payload.sn.SML[\”16_7_0\”],\n l1: msg.payload.sn.SML[\”36_7_0\”],\n l2: msg.payload.sn.SML[\”56_7_0\”],\n l3: msg.payload.sn.SML[\”76_7_0\”]\n}\nmsg.payload=sensorData.l3;\n\n\n\nreturn msg;\n\n”,
“outputs”: 1,
“timeout”: 0,
“noerr”: 0,
“initialize”: “”,
“finalize”: “”,
“libs”: [],
“x”: 510,
“y”: 460,
“wires”: [
[
“3f8189accf225af8”,
“ab83b6d4c3cef048”
]
]
},
{
“id”: “8bc82d142984fb14”,
“type”: “ui_chart”,
“z”: “89ec33379a2f6a44”,
“name”: “”,
“group”: “81aab2320a8645e2”,
“order”: 2,
“width”: “6”,
“height”: “6”,
“label”: “Watt Aktuell”,
“chartType”: “line”,
“legend”: “true”,
“xformat”: “HH:mm:ss”,
“interpolate”: “linear”,
“nodata”: “”,
“dot”: true,
“ymin”: “-100”,
“ymax”: “1000”,
“removeOlder”: 1,
“removeOlderPoints”: “”,
“removeOlderUnit”: “60”,
“cutout”: 0,
“useOneColor”: false,
“useUTC”: false,
“colors”: [
“#1f77b4”,
“#aec7e8”,
“#ff7f0e”,
“#2ca02c”,
“#98df8a”,
“#d62728”,
“#ff9896”,
“#9467bd”,
“#c5b0d5”
],
“outputs”: 1,
“useDifferentColor”: false,
“className”: “”,
“x”: 1310,
“y”: 540,
“wires”: [
[]
]
},
{
“id”: “a8855c4f40d43411”,
“type”: “influxdb out”,
“z”: “89ec33379a2f6a44”,
“influxdb”: “fba76e4b9a6289e9”,
“name”: “Z”,
“measurement”: “Z”,
“precision”: “m”,
“retentionPolicy”: “”,
“database”: “database”,
“precisionV18FluxV20”: “s”,
“retentionPolicyV18Flux”: “”,
“org”: “solar1”,
“bucket”: “tasmota”,
“x”: 850,
“y”: 580,
“wires”: []
},
{
“id”: “654fa4528ff9f659”,
“type”: “influxdb out”,
“z”: “89ec33379a2f6a44”,
“influxdb”: “fba76e4b9a6289e9”,
“name”: “L_total”,
“measurement”: “L_total”,
“precision”: “m”,
“retentionPolicy”: “”,
“database”: “database”,
“precisionV18FluxV20”: “s”,
“retentionPolicyV18Flux”: “”,
“org”: “solar1”,
“bucket”: “tasmota”,
“x”: 850,
“y”: 620,
“wires”: []
},
{
“id”: “e4b2e7cfdd4b20a5”,
“type”: “influxdb out”,
“z”: “89ec33379a2f6a44”,
“influxdb”: “fba76e4b9a6289e9”,
“name”: “L1”,
“measurement”: “L1”,
“precision”: “m”,
“retentionPolicy”: “”,
“database”: “database”,
“precisionV18FluxV20”: “s”,
“retentionPolicyV18Flux”: “”,
“org”: “solar1”,
“bucket”: “tasmota”,
“x”: 850,
“y”: 660,
“wires”: []
},
{
“id”: “42857490893e3db5”,
“type”: “influxdb out”,
“z”: “89ec33379a2f6a44”,
“influxdb”: “fba76e4b9a6289e9”,
“name”: “L2”,
“measurement”: “L2”,
“precision”: “m”,
“retentionPolicy”: “”,
“database”: “database”,
“precisionV18FluxV20”: “s”,
“retentionPolicyV18Flux”: “”,
“org”: “solar1”,
“bucket”: “tasmota”,
“x”: 850,
“y”: 700,
“wires”: []
},
{
“id”: “ab83b6d4c3cef048”,
“type”: “influxdb out”,
“z”: “89ec33379a2f6a44”,
“influxdb”: “fba76e4b9a6289e9”,
“name”: “L3”,
“measurement”: “L3”,
“precision”: “m”,
“retentionPolicy”: “”,
“database”: “database”,
“precisionV18FluxV20”: “s”,
“retentionPolicyV18Flux”: “”,
“org”: “solar1”,
“bucket”: “tasmota”,
“x”: 850,
“y”: 740,
“wires”: []
},
{
“id”: “269d9a58bce8a7c5”,
“type”: “mqtt in”,
“z”: “89ec33379a2f6a44”,
“name”: “mqtt-in”,
“topic”: “tasmota/discovery/A848FADECFE9/sensors”,
“qos”: “2”,
“datatype”: “auto-detect”,
“broker”: “9c160e61426b97c6”,
“nl”: false,
“rap”: true,
“rh”: 0,
“inputs”: 0,
“x”: 110,
“y”: 220,
“wires”: [
[
“cf2de51948212849”
]
]
},
{
“id”: “9c160e61426b97c6”,
“type”: “mqtt-broker”,
“name”: “tasmotabroker”,
“broker”: “192.168.178.37”,
“port”: “1883”,
“clientid”: “”,
“autoConnect”: true,
“usetls”: false,
“protocolVersion”: “4”,
“keepalive”: “5”,
“cleansession”: true,
“autoUnsubscribe”: true,
“birthTopic”: “”,
“birthQos”: “0”,
“birthRetain”: “false”,
“birthPayload”: “”,
“birthMsg”: {},
“closeTopic”: “”,
“closeQos”: “0”,
“closeRetain”: “false”,
“closePayload”: “”,
“closeMsg”: {},
“willTopic”: “”,
“willQos”: “0”,
“willRetain”: “false”,
“willPayload”: “”,
“willMsg”: {},
“userProps”: “”,
“sessionExpiry”: “”
},
{
“id”: “59ed30af4c06545f”,
“type”: “ui_group”,
“name”: “Gauges 1-2”,
“tab”: “74f60f1f31952bba”,
“order”: 2,
“disp”: true,
“width”: “2”,
“collapse”: false,
“className”: “”
},
{
“id”: “630144b18364e6f6”,
“type”: “ui_group”,
“name”: “Gauges 3-4”,
“tab”: “74f60f1f31952bba”,
“order”: 3,
“disp”: true,
“width”: “2”,
“collapse”: false,
“className”: “”
},
{
“id”: “c9ad275a4919e408”,
“type”: “ui_group”,
“name”: “Gauges 5-6”,
“tab”: “74f60f1f31952bba”,
“order”: 4,
“disp”: true,
“width”: “2”,
“collapse”: false,
“className”: “”
},
{
“id”: “39ae889322e0a09b”,
“type”: “ui_group”,
“name”: “tasmota”,
“tab”: “74f60f1f31952bba”,
“order”: 1,
“disp”: true,
“width”: “7”,
“collapse”: false,
“className”: “”
},
{
“id”: “81aab2320a8645e2”,
“type”: “ui_group”,
“name”: “chart L2”,
“tab”: “74f60f1f31952bba”,
“order”: 5,
“disp”: true,
“width”: “6”,
“collapse”: false,
“className”: “”
},
{
“id”: “fba76e4b9a6289e9”,
“type”: “influxdb”,
“hostname”: “127.0.0.1”,
“port”: “8086”,
“protocol”: “http”,
“database”: “solar2”,
“name”: “solar1”,
“usetls”: false,
“tls”: “”,
“influxdbVersion”: “2.0”,
“url”: “http://localhost:8086&#8221;,
“timeout”: “10”,
“rejectUnauthorized”: true
},
{
“id”: “74f60f1f31952bba”,
“type”: “ui_tab”,
“name”: “Home”,
“icon”: “dashboard”,
“order”: 1,
“disabled”: false,
“hidden”: false
}
]

Question Tags: nodered
3 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 1 year ago

Hi.
 
I’m not familiar with those tasmota devices, but do they have the option to set their MQTT settings? Make sure you set the retain flag to false both on your Tasmota devices and on Node-RED so that it doesn’t pick some old value retained on the MQTT broker.
 
Regards,
Sara

0 Vote Up Vote Down
Heribert Houben answered 1 year ago

Thanks Sara,
The tasmota doesn’t have an option to avoid retain. But this is not the problem.
Problem is, that the values are not updating in node red. New values do not appear at the end of the flow.
In MQTT-Explorer the values from the broker are updating each second. In node red they are only updating once when I manually redeploy the flow. Should update each second without redeploy….

0 Vote Up Vote Down
Sara Santos Staff answered 1 year ago

Hi again.
 
Usually, Node-RED MQTT In nodes will automatically detect incoming MQTT messages without having to refresh anything. At least, it works like that in all my examples.
 
I’m not sure if you have some setting that is not correct or something… Do you have different IDs for the MQTT Clients? Note that the MQTT Client ID in node-red must be different than the MQTT ID in your tasmota device.
 
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.