I use four DS18B20 sensors on One ESP8266 device with tasmota firmware.
To send all four values without recompiling own Tasmota. I use node red as an intermediary between Domoticz and Tasmota.
Code: Select all
[
{
"id": "4dc31f8a.b4d0b",
"type": "mqtt in",
"z": "361da2b3.1527de",
"name": "",
"topic": "strych/tele/SENSOR/#",
"qos": "2",
"datatype": "auto",
"broker": "9748a36f.44bdd",
"x": 280,
"y": 280,
"wires": [
[
"fdbcab3.28aba58"
]
]
},
{
"id": "fdbcab3.28aba58",
"type": "json",
"z": "361da2b3.1527de",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 450,
"y": 280,
"wires": [
[
"2f400adb.82bdc6"
]
]
},
{
"id": "2f400adb.82bdc6",
"type": "function",
"z": "361da2b3.1527de",
"name": "Split key value",
"func": "var keys = Object.keys(msg.payload);\n\nvar msgs = keys.map(function(key) {\n return { topic: key, payload: msg.payload[key] };\n});\nreturn [msgs];",
"outputs": 1,
"noerr": 0,
"x": 600,
"y": 280,
"wires": [
[
"e795a78e.355998"
]
]
},
{
"id": "e795a78e.355998",
"type": "switch",
"z": "361da2b3.1527de",
"name": "",
"property": "topic",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "DS18B20-1",
"vt": "str"
},
{
"t": "eq",
"v": "DS18B20-2",
"vt": "str"
},
{
"t": "eq",
"v": "DS18B20-3",
"vt": "str"
},
{
"t": "eq",
"v": "DS18B20-4",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 4,
"x": 770,
"y": 280,
"wires": [
[
"60a83551.9b506c"
],
[
"60a83551.9b506c"
],
[
"60a83551.9b506c"
],
[
"60a83551.9b506c"
]
]
},
{
"id": "60a83551.9b506c",
"type": "function",
"z": "361da2b3.1527de",
"name": "prepare to send",
"func": "\nif ( msg.topic == \"DS18B20-1\" ) \n{\n wartosc = msg.payload.Temperature;\n msg.payload = {};\n msg.payload.idx = 94;\n msg.payload.nvalue = 0;\n msg.payload.svalue = String(wartosc);\n \n}\nelse if ( msg.topic == \"DS18B20-2\" ) \n{\n wartosc = msg.payload.Temperature;\n msg.payload = {};\n msg.payload.idx = 96;\n msg.payload.nvalue = 0;\n msg.payload.svalue = String(wartosc);\n \n}\nelse if ( msg.topic == \"DS18B20-3\" ) \n{\n wartosc = msg.payload.Temperature;\n msg.payload = {};\n msg.payload.idx = 95;\n msg.payload.nvalue = 0;\n msg.payload.svalue = String(wartosc);\n \n}\nelse if ( msg.topic == \"DS18B20-4\" ) \n{\n wartosc = msg.payload.Temperature;\n msg.payload = {};\n msg.payload.idx = 97;\n msg.payload.nvalue = 0;\n msg.payload.svalue = String(wartosc);\n}\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 940,
"y": 280,
"wires": [
[
"816b0a0d.2c4b98"
]
]
},
{
"id": "816b0a0d.2c4b98",
"type": "mqtt out",
"z": "361da2b3.1527de",
"name": "",
"topic": "domoticz/in",
"qos": "2",
"retain": "",
"broker": "9748a36f.44bdd",
"x": 1110,
"y": 280,
"wires": []
},
{
"id": "9748a36f.44bdd",
"type": "mqtt-broker",
"z": "",
"broker": "localhost",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": true,
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
}
]