Help Optimize MQTT to influx functions

I could use another set of eyes on my nodes. It works, but I feel like this can't be the most efficient way. There are many places in the function where things are hard-coded that I am typing over and over. I would like to be able to just name the mqtt input node, and have that name carry on all the way to the values at the end, so that I can drop the function in more generically, and connect how ever many nodes to it as I want.

I'm receiving several strings via MQTT that look like this:

"{"value": 1}"

each mqtt address provides a single string, and all the fields are named "value"

I want to group them up into an array that I can pass to the influxdb output plugin. The influx db plugin specifies:

If msg.payload is an object containing multiple properties, the fields will be written to the measurement.

So, I first run it through a json not to end up with:

{"value":1}

Then I run it through a change node:

[{"id":"349769e9.930ee6","type":"change","z":"d8b74574.59d138","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"msg.payload.value","tot":"jsonata"},{"t":"set","p":"topic","pt":"msg","to":"mains","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":1720,"wires":[["de691611.9b18d8","cc20b7b1.30b3d8"]]}]

Here I'm setting the payload to just the value "1", and setting a msg.topic so that I can tell the measurements apart. In this example, the topic is "mains".

The output of the change module of course is just:

1

Now for my main function. I borrowed bits and pieces of this code from different places, so I have very little confidence in it, but it does work:

context.data = context.data || {};

switch (msg.topic) {

case "mains":
    context.data.mains = msg.payload;
    msg = null;
    break;
case "bulk":
    context.data.bulk = msg.payload;
    msg = null;
    break;
case "absorption":
    context.data.absorption = msg.payload;
    msg = null;
    break;
case "float":
    context.data.float = msg.payload;
    msg = null;
    break;
case "inverter":
    context.data.inverter = msg.payload;
    msg = null;
    break;
case "overload":
    context.data.overload = msg.payload;
    msg = null;
    break;
case "lowbattery":
    context.data.lowbattery = msg.payload;
    msg = null;
    break;
case "temperature":
    context.data.temperature = msg.payload;
    msg = null;
    break;

default:
    msg = null;
	break;

}

if(context.data.mains != null && context.data.bulk != null && context.data.absorption != null && context.data.float != null && context.data.inverter != null && context.data.overload != null && context.data.lowbattery != null && context.data.temperature != null ) {
	msg2 = {};
msg2.payload = {
    mains: context.data.mains,
    bulk: context.data.bulk,
    absorption: context.data.absorption,
    float: context.data.float,
    inverter: context.data.inverter,
    overload: context.data.overload,
    lowbattery: context.data.lowbattery,
    temperature: context.data.temperature
}
;

context.data=null;
	return msg2;
} 

My issue with this code is I am repeating parts over and over, it's tedious and can't be the most effective way to do things (but I don't know any better!) I connect the output of each change node to the function. The output is:

{"mains":1,"bulk":0,"absorption":0,"float":1,"inverter":0,"overload":0,"lowbattery":0,"temperature":0}

Great!

The whole spread looks like this:

And this is how it shows up at the other end, in grafana:

image image

Now, I wish I could make it say on/off instead of 1 or 0, but that's another matter, as it seems like influxdb doesn't like strings. :slight_smile:

Do you have any control over the MQTT messages? If you do, maybe make the topic be "LED" and then switch from a single MQTT node on the message payload "contains" absorption, etc. or could then switch on the msg.payload or other fields in your function instead of making msg.topic match the source.

I do not, and they aren't going to change it just for me, so this is what I'm stuck with!

Even if I could just type in the name once "main" and have it be used in all the various places, that would be good enough!

You could instead replace the Change nodes with ones configured similar to this and feed them all directly into the Influxdb node

image

(side note) - Move does the delete for you - so the delete is unnecessary

Thanks, thinking about it that is exactly what it should do of course. If it did not delete it then it would be Copy, not Move.

or set as we called it (as you can set a new value or set it to be a calculated value or copy an old one)

Is the idea of the function node to gather the values from each of the MQTT nodes and write out one record with all the data at that moment in time?

If so, as I understand what you have provided, your flow won't work. Each time a msg comes in via a MQTT node, it will pass to the function node and be processed and sent on.

Let's walk thru it.

  1. a messge comes from Mains LED
  2. you change the msg so you mnow have msg.topic = 'mains' and msg.payload = 1
  3. the function node runs Since it is the frist time you set context.data to {}
  4. the switch causes the case 'mains' to be executed so you set context.data.mains to 1
  5. next you move the data to msg2,
  6. set contect.data to null
  7. and send the msg out - note it only contains the value from the Mains LED

If you get a message from any of the other mqtt nodes, the same thing happens only that value will be sent.

If you want an aggrate of all the mqtt nodes, you will need to add a join to your flow.

Here is a way to solve the mqtt -> database problem with a generic solution...

[{"id":"c4a25e8f.ac117","type":"mqtt in","z":"b473c044.f9da7","name":"","topic":"sensor/status/#","qos":"0","broker":"e36a332b.c61f3","x":112,"y":941,"wires":[["471c3086.0d641"]]},{"id":"b331f58c.b7c228","type":"inject","z":"b473c044.f9da7","name":"cfg","topic":"","payload":"[{\"topic\":\"sensor/status/heating/kg_tr/sol/vol\",\"min\":0,\"max\":700,\"Name\":\"Volumen\"},{\"topic\":\"sensor/status/heating/kg_tr/sol/wh\",\"min\":6581248,\"max\":99981248,\"Name\":\"Wärme\"},{\"topic\":\"sensor/status/heating/kg_tr/sol/t1\",\"min\":-30,\"max\":250,\"Name\":\"Kollektor\"},{\"topic\":\"sensor/status/heating/kg_tr/sol/t3\",\"min\":-30,\"max\":250,\"Name\":\"Vorlauf\"},{\"topic\":\"sensor/status/power/power/eme/balance\",\"nodatabase\":false,\"Name\":\"Energiebilanz akt.\"},{\"topic\":\"sensor/status/freshwater/kg_tr/water/cnt\",\"min\":1,\"max\":999999,\"nodatabase\":false,\"Name\":\"Wasserzähler\"}]","payloadType":"json","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":85,"y":990,"wires":[["3124dc85.b3edc4"]]},{"id":"3124dc85.b3edc4","type":"split","z":"b473c044.f9da7","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":168,"y":1040,"wires":[["3f2d1981.4e09c6"]]},{"id":"3f2d1981.4e09c6","type":"change","z":"b473c044.f9da7","name":"prep","rules":[{"t":"set","p":"topic","pt":"msg","to":"payload.topic","tot":"msg"},{"t":"set","p":"priority","pt":"msg","to":"0","tot":"num"},{"t":"move","p":"payload","pt":"msg","to":"cfg","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":273,"y":1088,"wires":[["ddd2e928.b09658"]]},{"id":"471c3086.0d641","type":"json","z":"b473c044.f9da7","name":"","x":265,"y":996,"wires":[["ddd2e928.b09658"]]},{"id":"ddd2e928.b09658","type":"function","z":"b473c044.f9da7","name":"AJV12","func":"var countmsg = 2;          //how many items to join?\n\nvar nodublicates = false;   //only join if payload unequal existing payload\nvar limit;                 //only join if payloads are on both sides of the limit\nvar hysteresis;      //hysteresis \nvar clearaftersend = false;//clear queue after sending\nvar sendinstantly = false;\nvar reverse = false;         //reverse output array\nvar priomode = false;\nvar storagemode = false;  \nvar addconfigmode = true;\nvar topicmatch = false;\nvar samplemode = false;\nvar sampleinterval = 60000;  //ms\n//------------ different topic mode ------------------\nvar diftopics = false;      //true: join only different topics; false: join only same topics\nvar alphasort = false;\n\nvar inmsg = msg;\nvar msgs = context.get(\"aggmsgs\")||{};\nvar topicmsgs = msgs[inmsg.topic]||[];\n\nif (inmsg.topic === \"\")\n    return null;\nif (typeof inmsg.reset != \"undefined\") {\n    msgs = {};\n    topicmsgs = [];\n    lastval = undefined;\n    context.set(\"aggmsgs\",msgs);\n    context.set(\"lastval\",lastval);\n    return null;\n}\nif (typeof inmsg.resettopic != \"undefined\") {\n    topicmsgs = [];\n    lastval = undefined;\n}\nif (typeof hysteresis !== 'undefined' && typeof lastval !== 'undefined') {\n    if (Math.abs(inmsg.payload - lastval) <= hysteresis) {\n        return null;\n    }\n}\nif (typeof inmsg.payload != \"undefined\") {\n    if (typeof inmsg.payload.arraystatus != \"undefined\") {\n        inmsg.payload = msgs;\n        return inmsg;\n    }\n}\nif (typeof lastval !== 'undefined') {\n    if (nodublicates && lastval == inmsg.payload)\n        return null;\n    if (typeof limit !== 'undefined' && countmsg == 2) {\n        if (!((lastval <= limit && inmsg.payload >= limit) || (lastval >= limit && inmsg.payload <= limit)))   \n            return null;\n    }\n} \n\nif (samplemode) {\n    var tmr = msgs[inmsg.topic + \"tmr\"];\n    if (typeof tmr === \"undefined\")\n        tmr = 1;\n//node.warn(msgs);\n\n    if (topicmsgs.length === 0) {\n        topicmsgs.push(inmsg);\n        setTimeout(timer,sampleinterval,inmsg.topic,false);\n    }\n    else if (topicmsgs.length === 1) { \n        topicmsgs.push(inmsg);\n//        if (tmr === 0) \n//            setTimeout(timer,sampleinterval,inmsg.topic,false); //normal timer\n    }\n    else {\n        topicmsgs[1] = inmsg;\n//        if (tmr === 0) \n//            setTimeout(timer,sampleinterval,inmsg.topic,false); //normal timer   \n    }\n\n    msgs[inmsg.topic] = topicmsgs;\n    context.set(\"aggmsgs\",msgs);\n    context.set(\"lastval\",inmsg.payload);\n    if (tmr === 0) {\n        setTimeout(timer,5,inmsg.topic,true);   //timer expired -> send asap\n    }\n\n    return null;\n}\n\nif (topicmatch) {\n    if (typeof inmsg.payload.jointopic != \"undefined\") {\n        if (topicmsgs.length === 0) {\n            topicmsgs.push(inmsg);\n            msgs[inmsg.topic] = topicmsgs;\n            context.set(\"aggmsgs\",msgs);\n            return null;   \n        }\n        else {\n            topicmsgs[0] = inmsg;\n        }\n    }\n    else {  //only accept topics specified by jointopics\n        for (var tmsgs in msgs) {\n            if (msgs.hasOwnProperty(tmsgs)) {   \n                var bfound = false;\n                var btopicfound = false;\n                var ar = msgs[tmsgs];\n                for (var i = 0; i < ar.length; i++) {    //search and replace\n                    if (i === 0) {\n                        if (ar[i].payload.jointopic == inmsg.topic)\n                            btopicfound = true;\n                    } else {\n                        if (ar[i].topic == inmsg.topic) {\n                            ar[i] = inmsg;\n                            bfound = true;\n                        }\n                    }\n                }\n                if (!bfound && btopicfound)        //add new\n                    msgs[tmsgs].push(inmsg);\n            }\n        }\n    }\n}\n\nvar outmsg = { \"topic\": inmsg.topic , \"payload\": \"\"};\nvar lastval = context.get(\"lastval\");\nvar inprio = typeof inmsg.priority != \"undefined\" ? inmsg.priority: countmsg-1 ;     //default prio is 1\n//node.warn(topicmsgs.length);\nif (addconfigmode) {\n    if (topicmsgs.length === 0) {\n        if (typeof inmsg.priority == \"undefined\")\n            return inmsg;\n        else {\n            topicmsgs.push(inmsg);\n            msgs[inmsg.topic] = topicmsgs;\n            context.set(\"aggmsgs\",msgs);\n            context.set(\"lastval\",inmsg.payload);\n            return null;\n            }\n        }\n    else {\n        if (typeof inmsg.priority == \"undefined\") {\n            for (var i = 0; i < topicmsgs.length; i++) //append attributes from prio 0..1 where higher overwrites\n                addAtr(topicmsgs[i],inmsg);\n            return inmsg;\n        }    \n        else {\n            for (var i = 0; i <= inmsg.priority; i++) {\n                if (typeof topicmsgs[i] == \"undefined\")\n                    topicmsgs.push({});\n            }\n            topicmsgs[inmsg.priority] = inmsg;\n            msgs[inmsg.topic] = topicmsgs;\n            context.set(\"aggmsgs\",msgs);\n            context.set(\"lastval\",inmsg.payload);\n            return null;\n        }\n    }\n}\n\nif (diftopics) {\n//node.warn(topicmsgs.length);\n    if (topicmsgs.length > 0) {     //msg with same topic -> replace old msg\n        topicmsgs.shift();\n    }\n    topicmsgs.push(inmsg);\n    msgs[inmsg.topic] = topicmsgs;    \n    if (Object.keys(msgs).length > countmsg) {\n        for (var tmsgs in msgs) {\n            if (msgs.hasOwnProperty(tmsgs)) {   \n                delete msgs[tmsgs];\n                break;\n            }\n        }\n    }\n    context.set(\"aggmsgs\",msgs);\n    context.set(\"lastval\",inmsg.payload);\n//node.warn(Object.keys(msgs).length);\n    if (Object.keys(msgs).length == countmsg) {\n        var aout = [];\n        outmsg.topic = \"\";\n        for (var tmsgs in msgs) {\n            if (msgs.hasOwnProperty(tmsgs)) \n                aout.push(msgs[tmsgs][0]);\n        }\n        if (clearaftersend) {\n            context.set(\"aggmsgs\",undefined);\n            context.set(\"lastval\",undefined);\n        }\n        if (alphasort) \n            aout.sort(function(a,b) {return (a.topic > b.topic) ? 1 : ((a.topic > b.topic) ? -1 : 0);});\n        if (reverse)\n            aout.reverse();\n        \n        for (var i =0; i<aout.length;i++) {outmsg.topic += aout[i].topic + \"_\"; }\n        outmsg.topic = outmsg.topic.substr(0,String(outmsg.topic).length-1);\n        outmsg.payload = aout;\n\n        return outmsg;\n    } else\n        return null;\n} \nelse \n{\n    if (topicmsgs.length == countmsg && !storagemode && !topicmatch){\n        topicmsgs.shift();\n    }\n    if (storagemode) {\n        if (topicmsgs.length < inprio)\n            topicmsgs.push(inmsg);\n        else\n            topicmsgs[inprio] = inmsg;\n        msgs[inmsg.topic] = topicmsgs;\n    } \n    if (!topicmatch && !storagemode) {\n        topicmsgs.push(inmsg);\n        msgs[inmsg.topic] = topicmsgs;\n    }\n    context.set(\"aggmsgs\",msgs);\n    context.set(\"lastval\",inmsg.payload);\n    \n    if (storagemode) {                          //check send msg\n        if (inprio < topicmsgs.length - 1)      //only send on trigger msg => no priority\n            return null;\n        for (var i = 0; i < topicmsgs.length; i++) { //only send if storage is full\n            if (topicmsgs[i] === undefined)\n                return null;\n        }    \n    }\n//node.warn(topicmsgs.length);\n    if (topicmatch) {\n        for (var tmsgs in msgs) {\n            if (msgs.hasOwnProperty(tmsgs)) {   \n                var ar = msgs[tmsgs];\n                if (ar.length == countmsg) {\n                    for (var i = 0; i < ar.length; i++) {\n                        if (ar[i].topic == inmsg.topic) {\n                            outmsg.payload = ar;\n                            outmsg.topic = ar[0].topic;\n                            node.send(RED.util.cloneMessage(outmsg));\n                        }\n                    }\n                }\n            }\n        }\n    } else {\n        if (topicmsgs.length == countmsg || sendinstantly) {\n            outmsg.payload = Object.assign({}, topicmsgs);\n            if (topicmatch) {\n                outmsg.topic = topicmsgs[0].topicori;\n                outmsg.payload[0].topic = outmsg.topic;\n            }\n            \n            if (clearaftersend) {\n                msgs[inmsg.topic] = undefined;\n                context.set(\"aggmsgs\",msgs);\n                context.set(\"lastval\",undefined);\n            }\n            if (reverse) {\n                var revArr = outmsg.payload.map(a => Object.assign({}, a));\n                revArr.reverse();\n                outmsg.payload = revArr;\n            }\n            return outmsg;\n        }\n        else\n            return null;\n    }\n}\n\nfunction timer(topic,clear) {\n    var msgs = context.get(\"aggmsgs\")||{};\n    var topicmsgs = msgs[topic]||[];\n    var sent = false;\n    \n    var out = {\"topic\": topic, \"payload\": {\"value\": 0}};\n    if (topicmsgs.length > 1) {\n        out.payload.value = topicmsgs[1].payload - topicmsgs[0].payload;\n        out.ar = topicmsgs;\n//        node.send(RED.util.cloneMessage(out));\n        node.send(out); \n        topicmsgs.shift();\n        sent = true;\n    }\n    if (clear || sent)\n        msgs[topic+\"tmr\"] = 1;\n    else \n        msgs[topic+\"tmr\"] = 0;\n    msgs[topic] = topicmsgs;\n    context.set(\"aggmsgs\",msgs);\n\n    if (sent || clear)\n        setTimeout(timer,sampleinterval,topic,false); //normal timer   \n}\n\nfunction addAtr(src, tgt) {\n    for (var atr in src) {\n        if (src.hasOwnProperty(atr)) {\n            if (atr != \"_msgid\" && typeof tgt[atr] == \"undefined\" && typeof src[atr] != \"object\" && atr != \"priority\") {   \n                tgt[atr] = src[atr];\n            }\n            if (typeof src[atr] == \"object\") {\n                if (typeof tgt[atr] == \"undefined\")\n                    tgt[atr] = {};\n                addAtr(src[atr],tgt[atr]);\n            }\n        }\n    }\n}","outputs":1,"noerr":0,"x":404,"y":1037,"wires":[["2a6d38dc.5eb678"]]},{"id":"2a6d38dc.5eb678","type":"switch","z":"b473c044.f9da7","name":"limit?","property":"payload","propertyType":"msg","rules":[{"t":"lt","v":"cfg.min","vt":"msg"},{"t":"gt","v":"cfg.max","vt":"msg"},{"t":"else"}],"checkall":"false","repair":false,"outputs":3,"x":534,"y":1034,"wires":[[],[],["fe38e85e.2aa798"]],"outputLabels":["under limit","over limit","ok"]},{"id":"fe38e85e.2aa798","type":"switch","z":"b473c044.f9da7","name":"nodb?","property":"true","propertyType":"jsonata","rules":[{"t":"eq","v":"cfg.nodatabase","vt":"msg"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":662,"y":1074,"wires":[[],["c9f7c3f8.29e82"]],"outputLabels":["under limit","ok"]},{"id":"c9f7c3f8.29e82","type":"switch","z":"b473c044.f9da7","name":"","property":"topic","propertyType":"msg","rules":[{"t":"regex","v":"\\/heating\\/","vt":"str","case":false},{"t":"regex","v":"\\/kwl\\/","vt":"str","case":false},{"t":"else"}],"checkall":"true","outputs":3,"x":789,"y":1111,"wires":[[],[],["ee757e41.23398"]]},{"id":"ee757e41.23398","type":"change","z":"b473c044.f9da7","name":"no heating","rules":[{"t":"set","p":"payload.id","pt":"msg","to":"undefined","tot":"jsonata"},{"t":"set","p":"payload.name","pt":"msg","to":"undefined","tot":"jsonata"},{"t":"set","p":"measurement","pt":"msg","to":"$split(msg.topic, \"/\")[2]","tot":"jsonata"},{"t":"set","p":"device","pt":"msg","to":"$split(msg.topic, \"/\")[4] & $split(msg.topic, \"/\")[5]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":935,"y":1159,"wires":[["336db3a5.0af69c"]]},{"id":"336db3a5.0af69c","type":"function","z":"b473c044.f9da7","name":"prepare data","func":"newmsg = {}\nnewmsg.payload = {}\nnewmsg.measurement = msg.measurement;\n\nif (typeof msg.payload === \"object\") {\n    for (var key in msg.payload) {\n        if (isNumeric(msg.payload[key]) && msg.measurement != \"event\") {\n             newmsg.payload[key] = parseFloat(msg.payload[key]);\n        } else {\n            newmsg.payload[key] = msg.payload[key];\n        }\n    }\n} else {\n    if (isNumeric(msg.payload[key]) && msg.measurement != \"event\") {\n         newmsg.payload.value = parseFloat(msg.payload);\n    } else {\n        newmsg.payload.value = msg.payload;\n    }\n}\n\n//add tag \"Device\"\nnewmsg.payload = [ newmsg.payload, { \"Device\": msg.device} ];\n//add tag \"Beacon\"\nif (msg.beacon !== undefined)\n    newmsg.payload[1].Beacon = msg.beacon;\n//add tag \"Location\"    \nif (msg.location !== undefined)\n    newmsg.payload[1].Location = msg.location;\n//add tag \"function\"    \nif (msg.function !== undefined)\n    newmsg.payload[1].Function = msg.function;\n//add tag \"system\"    \nif (msg.system !== undefined)\n    newmsg.payload[1].system = msg.system;\n//add tag \"type\"    \nif (msg.type !== undefined)\n    newmsg.payload[1].type = msg.type;   \n//add tag \"time\"    \nif (msg.time !== undefined)\n    newmsg.payload[1].time = msg.time;   \n    \nreturn newmsg;\n\nfunction isNumeric(n) {\n  return !isNaN(parseFloat(n)) && isFinite(n);\n}\n","outputs":"1","noerr":0,"x":1106,"y":1189,"wires":[["9ab5114a.50fef"]]},{"id":"9ab5114a.50fef","type":"influxdb out","z":"b473c044.f9da7","influxdb":"4ffcfa0e.b43084","name":"","measurement":"","x":1302,"y":1231,"wires":[]},{"id":"e36a332b.c61f3","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"15","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""},{"id":"4ffcfa0e.b43084","type":"influxdb","z":"","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"infra","name":"","usetls":false,"tls":""}]
1 Like

You can certainly use strings in InfluxDB values but then you lose all the benefits that timeseries processing brings. Like being able to max/min/average/etc aggregation for a specific time period (e.g. an hour/day/week/month/etc).

Hey there,

Ive kinda jumped in to this , Not entirely knowing what im doing haha. But getting there.
I am looking to export my sensor data to InfluxDB but its not behaving as expected from
reading this post and my understanding of whats happening. I too am trying to
aggregate all my MQTT Data and place it in InfluxDB. Prior to this post I was going to make
separate databases just for each MQTT node. But this is far better to have it under one
database with the measurement being that sensor that supplies these topics..

I have included an attached copy of my flow. Please note I am new to this and still trying to
learn and experiment.

[{"id":"28078c62.9890fc","type":"tab","label":"Sensor_1 proto","disabled":false,"info":""},{"id":"9b6960ea.9750b","type":"ui_gauge","z":"28078c62.9890fc","name":"DHT221 Humi","group":"b551b358.237c68","order":1,"width":0,"height":0,"gtype":"gage","title":"DHT221 Humi","label":"units","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":640,"y":280,"wires":[]},{"id":"9394f77d.13da9","type":"ui_chart","z":"28078c62.9890fc","name":"DHT221 Temp","group":"b551b358.237c68","order":2,"width":0,"height":0,"label":"DHT221 Temp","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"step","nodata":"","dot":false,"ymin":"-2","ymax":"40","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":640,"y":160,"wires":[[]]},{"id":"5350eadd.6fce34","type":"ui_switch","z":"28078c62.9890fc","name":"Lamp Switch","label":"Lamp","tooltip":"","group":"957f84b5.bf5e","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"arduino_1/led","style":"","onvalue":"on","onvalueType":"str","onicon":"","oncolor":"","offvalue":"off","offvalueType":"str","officon":"","offcolor":"","x":310,"y":80,"wires":[["ea1020e7.70a818"]]},{"id":"41350b33.b685ec","type":"mqtt in","z":"28078c62.9890fc","name":"DHT221 Temp","topic":"Sense_1/sensor/DHT221Temp","qos":"2","datatype":"auto","broker":"647362d8.d9d214","x":310,"y":240,"wires":[["9394f77d.13da9","6247600a.a20038","2c470efd.7b9f5a","d4d9756.4dd9808"]]},{"id":"ab8bd4dd.e756e","type":"mqtt in","z":"28078c62.9890fc","name":"DHT221 Humi","topic":"Sense_1/sensor/DHT221Humi","qos":"2","datatype":"auto","broker":"647362d8.d9d214","x":310,"y":320,"wires":[["9b6960ea.9750b","61f48da7.67078c","e5729d09.e6655"]]},{"id":"ea1020e7.70a818","type":"mqtt out","z":"28078c62.9890fc","name":"Lamp","topic":"arduino_1/led","qos":"2","retain":"","broker":"647362d8.d9d214","x":610,"y":80,"wires":[]},{"id":"20139f14.9cc848","type":"mosca in","z":"28078c62.9890fc","mqtt_port":1883,"mqtt_ws_port":8080,"name":"","username":"","password":"","dburl":"","x":330,"y":40,"wires":[["4498b7b.fbac1c8"]]},{"id":"4498b7b.fbac1c8","type":"debug","z":"28078c62.9890fc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":570,"y":40,"wires":[]},{"id":"f5f6bb6e.476d2","type":"ui_gauge","z":"28078c62.9890fc","name":"DHT222 Humi","group":"12e2222f.a9959e","order":1,"width":0,"height":0,"gtype":"gage","title":"DHT222 Humi","label":"units","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":640,"y":520,"wires":[]},{"id":"dabda254.b89b38","type":"ui_chart","z":"28078c62.9890fc","name":"DHT222 Temp","group":"12e2222f.a9959e","order":2,"width":0,"height":0,"label":"DHT222 Temp","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"step","nodata":"","dot":false,"ymin":"-2","ymax":"40","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":640,"y":400,"wires":[[]]},{"id":"adf5d6b7.e6a73","type":"mqtt in","z":"28078c62.9890fc","name":"DHT222 Temp","topic":"Sense_1/sensor/DHT222Temp","qos":"2","datatype":"auto","broker":"647362d8.d9d214","x":310,"y":440,"wires":[["dabda254.b89b38","d8a21ac.0cafd68","6e827ee5.1c78f8"]]},{"id":"8c3adb8f.7000c8","type":"mqtt in","z":"28078c62.9890fc","name":"DHT222 Humi","topic":"Sense_1/sensor/DHT222Humi","qos":"2","datatype":"auto","broker":"647362d8.d9d214","x":310,"y":560,"wires":[["f5f6bb6e.476d2","bf37d5d3.204878","4a4a1ac6.4bad7c"]]},{"id":"c9791dfb.b6804","type":"mqtt in","z":"28078c62.9890fc","name":"DS18B201","topic":"Sense_1/sensor/DS18B1","qos":"2","datatype":"auto","broker":"647362d8.d9d214","x":300,"y":680,"wires":[["615e168b.69a2a8","16c0e3a8.d105a4","df0ca26d.99e848","f8df034e.5bb5b8"]]},{"id":"cfdff0cc.6c2da8","type":"mqtt in","z":"28078c62.9890fc","name":"DS18B202","topic":"Sense_1/sensor/DS18B2","qos":"2","datatype":"auto","broker":"647362d8.d9d214","x":300,"y":840,"wires":[["590855a1.812444","be349034.bd826","f7820516.8607a","875ba7a0.7655d"]]},{"id":"c8b2542.a41bba8","type":"mqtt in","z":"28078c62.9890fc","name":"DS18B203","topic":"Sense_1/sensor/DS18B3","qos":"2","datatype":"auto","broker":"647362d8.d9d214","x":300,"y":1000,"wires":[["1845ee8b.392e81","e060b7e1.2fdb38","cf183a1e.a5ed6","62d6280e.f911b"]]},{"id":"92886c00.5ad958","type":"mqtt in","z":"28078c62.9890fc","name":"DS18B204","topic":"Sense_1/sensor/DS18B4","qos":"2","datatype":"auto","broker":"647362d8.d9d214","x":300,"y":1160,"wires":[["2e37575b.b781e","c310da84.ec7b9","6bafb392.257d94","d870c9f6.1fd61"]]},{"id":"16c0e3a8.d105a4","type":"ui_chart","z":"28078c62.9890fc","name":"DS18B1 Temp","group":"cfa35f17.2887d","order":1,"width":0,"height":0,"label":"DS18B1 Temp","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"step","nodata":"","dot":false,"ymin":"-2","ymax":"100","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":640,"y":640,"wires":[[]]},{"id":"2e37575b.b781e","type":"ui_chart","z":"28078c62.9890fc","name":"DS18B4 Temp","group":"cfa35f17.2887d","order":4,"width":0,"height":0,"label":"DS18B4 Temp","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"step","nodata":"","dot":false,"ymin":"-2","ymax":"100","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":640,"y":1120,"wires":[[]]},{"id":"be349034.bd826","type":"ui_chart","z":"28078c62.9890fc","name":"DS18B2 Temp","group":"cfa35f17.2887d","order":2,"width":0,"height":0,"label":"DS18B2 Temp","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"step","nodata":"","dot":false,"ymin":"-2","ymax":"100","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":640,"y":800,"wires":[[]]},{"id":"e060b7e1.2fdb38","type":"ui_chart","z":"28078c62.9890fc","name":"DS18B3 Temp","group":"cfa35f17.2887d","order":3,"width":0,"height":0,"label":"DS18B3 Temp","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"step","nodata":"","dot":false,"ymin":"-2","ymax":"100","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":640,"y":960,"wires":[[]]},{"id":"615e168b.69a2a8","type":"ui_gauge","z":"28078c62.9890fc","name":"DS18B1 Temp","group":"f045d040.9cde18","order":1,"width":0,"height":0,"gtype":"gage","title":"DS18B1 Temp","label":"units","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":640,"y":760,"wires":[]},{"id":"590855a1.812444","type":"ui_gauge","z":"28078c62.9890fc","name":"DS18B2 Temp","group":"f045d040.9cde18","order":3,"width":0,"height":0,"gtype":"gage","title":"DS18B2 Temp","label":"units","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":640,"y":920,"wires":[]},{"id":"c310da84.ec7b9","type":"ui_gauge","z":"28078c62.9890fc","name":"DS18B4 Temp","group":"e41def3e.c1a48","order":2,"width":0,"height":0,"gtype":"gage","title":"DS18B4 Temp","label":"units","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":640,"y":1240,"wires":[]},{"id":"1845ee8b.392e81","type":"ui_gauge","z":"28078c62.9890fc","name":"DS18B3 Temp","group":"e41def3e.c1a48","order":1,"width":0,"height":0,"gtype":"gage","title":"DS18B3 Temp","label":"units","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":640,"y":1080,"wires":[]},{"id":"67b071f9.cbecc8","type":"ui_button","z":"28078c62.9890fc","name":"inject test 1","group":"957f84b5.bf5e","order":1,"width":0,"height":0,"passthru":true,"label":"inject test 1","tooltip":"","color":"","bgcolor":"","icon":"","payload":"25","payloadType":"num","topic":"Sense_1/sensor/DS18B1","x":190,"y":1360,"wires":[["8a47f012.43bf3"]]},{"id":"8a47f012.43bf3","type":"mqtt out","z":"28078c62.9890fc","name":"inject test 1","topic":"Sense_1/sensor/DS18B1","qos":"2","retain":"false","broker":"647362d8.d9d214","x":650,"y":1440,"wires":[]},{"id":"5870c22.057e73c","type":"cpu","z":"28078c62.9890fc","name":"CPU","msgCore":false,"msgOverall":true,"msgArray":false,"msgTemp":false,"x":530,"y":1940,"wires":[["33cfc9b.8b67b36"]]},{"id":"33cfc9b.8b67b36","type":"ui_chart","z":"28078c62.9890fc","name":"CPU Load","group":"e140c582.4168c8","order":4,"width":0,"height":0,"label":"CPU Load","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"step","nodata":"","dot":false,"ymin":"-2","ymax":"100","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":670,"y":1940,"wires":[[]]},{"id":"d8bb4c1a.1cf33","type":"configurable interval","z":"28078c62.9890fc","name":"Read CPU Usage Trigger","interval":"2","onstart":false,"do_enable":true,"msg":"1","showstatus":false,"unit":"seconds","statusformat":"YYYY-MM-D HH:mm:ss","x":350,"y":1940,"wires":[["5870c22.057e73c"]]},{"id":"5e829fb.6476ce","type":"random","z":"28078c62.9890fc","name":"Inject 2 Random","low":"10","high":"90","inte":"true","property":"payload","x":400,"y":1500,"wires":[["cb5e8732.8ba1a"]]},{"id":"cb5e8732.8ba1a","type":"mqtt out","z":"28078c62.9890fc","name":"inject test 2","topic":"Sense_1/sensor/DS18B2","qos":"2","retain":"false","broker":"647362d8.d9d214","x":650,"y":1500,"wires":[]},{"id":"bd7ffe87.0ab8a","type":"configurable interval","z":"28078c62.9890fc","name":"generator trigger 1","interval":"5","onstart":false,"do_enable":false,"msg":"1","showstatus":false,"unit":"seconds","statusformat":"YYYY-MM-D HH:mm:ss","x":130,"y":1540,"wires":[["b4b698cb.0b6688","3a19d962.ff7c46","4b07380f.956cd","a9ddde72.2193d8","9236285.62d81d8","5e829fb.6476ce","3df8ba28.0c4c26","932a92cf.ab1e"]]},{"id":"9236285.62d81d8","type":"random","z":"28078c62.9890fc","name":"Inject 1 Random","low":"10","high":"90","inte":"true","property":"payload","x":400,"y":1440,"wires":[["8a47f012.43bf3"]]},{"id":"3df8ba28.0c4c26","type":"random","z":"28078c62.9890fc","name":"Inject 3 Random","low":"10","high":"90","inte":"true","property":"payload","x":400,"y":1560,"wires":[["a3408327.48e89"]]},{"id":"a3408327.48e89","type":"mqtt out","z":"28078c62.9890fc","name":"inject test 3","topic":"Sense_1/sensor/DS18B3","qos":"2","retain":"false","broker":"647362d8.d9d214","x":650,"y":1560,"wires":[]},{"id":"932a92cf.ab1e","type":"random","z":"28078c62.9890fc","name":"Inject 4 Random","low":"10","high":"90","inte":"true","property":"payload","x":400,"y":1620,"wires":[["604ed26d.e12c7c"]]},{"id":"604ed26d.e12c7c","type":"mqtt out","z":"28078c62.9890fc","name":"inject test 4","topic":"Sense_1/sensor/DS18B4","qos":"2","retain":"false","broker":"647362d8.d9d214","x":650,"y":1620,"wires":[]},{"id":"f61fed99.013d7","type":"debug","z":"28078c62.9890fc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1270,"y":780,"wires":[]},{"id":"75c501b0.2b94a","type":"inject","z":"28078c62.9890fc","name":"","topic":"","payload":"","payloadType":"date","repeat":"60","crontab":"","once":false,"onceDelay":0.1,"x":330,"y":2000,"wires":[["fa05999d.ba876"]]},{"id":"fa05999d.ba876","type":"moment","z":"28078c62.9890fc","name":"","topic":"","input":"","inputType":"msg","inTz":"Africa/Cairo","adjAmount":"2","adjType":"hours","adjDir":"add","format":"","locale":"en_SA","output":"","outputType":"msg","outTz":"Africa/Cairo","x":640,"y":2000,"wires":[[]]},{"id":"bc31ec52.5b7518","type":"join","z":"28078c62.9890fc","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"8","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":890,"y":740,"wires":[["3c9ab3a1.4229e4"]]},{"id":"8aab4ba0.abf1","type":"mqtt out","z":"28078c62.9890fc","name":"inject test 5","topic":"Sense_1/sensor/DHT221Temp","qos":"2","retain":"false","broker":"647362d8.d9d214","x":650,"y":1680,"wires":[]},{"id":"792c5362.f3b684","type":"mqtt out","z":"28078c62.9890fc","name":"inject test 6","topic":"Sense_1/sensor/DHT221Humi","qos":"2","retain":"false","broker":"647362d8.d9d214","x":650,"y":1740,"wires":[]},{"id":"3ccaba3c.556386","type":"mqtt out","z":"28078c62.9890fc","name":"inject test 7","topic":"Sense_1/sensor/DHT222Temp","qos":"2","retain":"false","broker":"647362d8.d9d214","x":650,"y":1800,"wires":[]},{"id":"149cbb34.9ebbb5","type":"mqtt out","z":"28078c62.9890fc","name":"inject test 8","topic":"Sense_1/sensor/DHT222Humi","qos":"2","retain":"false","broker":"647362d8.d9d214","x":650,"y":1860,"wires":[]},{"id":"3a19d962.ff7c46","type":"random","z":"28078c62.9890fc","name":"Inject 6 Random","low":"10","high":"90","inte":"true","property":"payload","x":400,"y":1740,"wires":[["792c5362.f3b684"]]},{"id":"b4b698cb.0b6688","type":"random","z":"28078c62.9890fc","name":"Inject 5 Random","low":"10","high":"90","inte":"true","property":"payload","x":400,"y":1680,"wires":[["8aab4ba0.abf1"]]},{"id":"4b07380f.956cd","type":"random","z":"28078c62.9890fc","name":"Inject 7 Random","low":"10","high":"90","inte":"true","property":"payload","x":400,"y":1800,"wires":[["3ccaba3c.556386"]]},{"id":"a9ddde72.2193d8","type":"random","z":"28078c62.9890fc","name":"Inject 8 Random","low":"10","high":"90","inte":"true","property":"payload","x":400,"y":1860,"wires":[["149cbb34.9ebbb5"]]},{"id":"61f48da7.67078c","type":"change","z":"28078c62.9890fc","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"DHT221\" : payload}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":360,"wires":[["bc31ec52.5b7518"]]},{"id":"d8a21ac.0cafd68","type":"change","z":"28078c62.9890fc","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"payload\" : payload}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":480,"wires":[["bc31ec52.5b7518"]]},{"id":"bf37d5d3.204878","type":"change","z":"28078c62.9890fc","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"payload\" : payload}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":600,"wires":[["bc31ec52.5b7518"]]},{"id":"df0ca26d.99e848","type":"change","z":"28078c62.9890fc","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"payload\" : payload}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":720,"wires":[["bc31ec52.5b7518"]]},{"id":"f7820516.8607a","type":"change","z":"28078c62.9890fc","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"payload\" : payload}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":880,"wires":[["bc31ec52.5b7518"]]},{"id":"cf183a1e.a5ed6","type":"change","z":"28078c62.9890fc","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"payload\" : payload}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":1040,"wires":[["bc31ec52.5b7518"]]},{"id":"6bafb392.257d94","type":"change","z":"28078c62.9890fc","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"payload\" : payload}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":1200,"wires":[["bc31ec52.5b7518"]]},{"id":"a96ec3ec.7df9c","type":"csv","z":"28078c62.9890fc","name":"CSV Node","sep":",","hdrin":true,"hdrout":true,"multi":"one","ret":"\\n","temp":"Sense_1/sensor/DHT221Temp,Sense_1/sensor/DHT221Humi,Sense_1/sensor/DHT222Temp,Sense_1/sensor/DHT222Humi,Sense_1/sensor/DS18B1,Sense_1/sensor/DS18B2,Sense_1/sensor/DS18B3,Sense_1/sensor/DS18B4","skip":"0","strings":true,"x":1090,"y":740,"wires":[["25cf4f08.0d675","f61fed99.013d7"]]},{"id":"25cf4f08.0d675","type":"file","z":"28078c62.9890fc","name":"","filename":"D:\\Data\\Progs\\OneDrive\\Arduino Mega\\new test1.csv","appendNewline":false,"createDir":false,"overwriteFile":"false","encoding":"none","x":1400,"y":740,"wires":[[]]},{"id":"b436276b.bf366","type":"inject","z":"28078c62.9890fc","name":"1","topic":"","payload":"enabled","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":630,"y":1300,"wires":[["bd7ffe87.0ab8a"]]},{"id":"7b7ee0a0.bb4fd8","type":"inject","z":"28078c62.9890fc","name":"1","topic":"","payload":"disable","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":630,"y":1340,"wires":[["bd7ffe87.0ab8a"]]},{"id":"3c9ab3a1.4229e4","type":"debug","z":"28078c62.9890fc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1110,"y":660,"wires":[]},{"id":"1c500d6c.470d33","type":"debug","z":"28078c62.9890fc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1270,"y":960,"wires":[]},{"id":"e0e42372.bb3868","type":"change","z":"28078c62.9890fc","name":"","rules":[{"t":"set","p":"payload.timestamp","pt":"msg","to":"","tot":"date"}],"action":"","property":"","from":"","to":"","reg":false,"x":920,"y":920,"wires":[["fdfc27f0.214f1"]]},{"id":"fdfc27f0.214f1","type":"csv","z":"28078c62.9890fc","name":"","sep":",","hdrin":false,"hdrout":"","multi":"one","ret":"\\n","temp":"timestamp,Sense_1/sensor/DS18B1,Sense_1/sensor/DS18B2,Sense_1/sensor/DS18B3,Sense_1/sensor/DS18B4,Sense_1/sensor/DHT221Temp,Sense_1/sensor/DHT222Temp,Sense_1/sensor/DHT221Humi,Sense_1/sensor/DHT222Humi","skip":"1","strings":true,"x":1110,"y":920,"wires":[["1c500d6c.470d33","5e28c59d.bea594","403ded2e.3c1404"]]},{"id":"5e28c59d.bea594","type":"file","z":"28078c62.9890fc","name":"","filename":"D:\\Data\\Progs\\OneDrive\\Arduino Mega\\log.txt","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":1380,"y":920,"wires":[[]]},{"id":"403ded2e.3c1404","type":"file","z":"28078c62.9890fc","name":"","filename":"D:\\Data\\Progs\\OneDrive\\Arduino Mega\\new test2.csv","appendNewline":false,"createDir":false,"overwriteFile":"false","encoding":"none","x":1400,"y":880,"wires":[[]]},{"id":"6247600a.a20038","type":"delay","z":"28078c62.9890fc","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":630,"y":200,"wires":[[]]},{"id":"e5729d09.e6655","type":"delay","z":"28078c62.9890fc","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":630,"y":320,"wires":[[]]},{"id":"6e827ee5.1c78f8","type":"delay","z":"28078c62.9890fc","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":630,"y":440,"wires":[[]]},{"id":"4a4a1ac6.4bad7c","type":"delay","z":"28078c62.9890fc","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":630,"y":560,"wires":[[]]},{"id":"f8df034e.5bb5b8","type":"delay","z":"28078c62.9890fc","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":630,"y":680,"wires":[[]]},{"id":"875ba7a0.7655d","type":"delay","z":"28078c62.9890fc","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":630,"y":840,"wires":[[]]},{"id":"62d6280e.f911b","type":"delay","z":"28078c62.9890fc","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":630,"y":1000,"wires":[[]]},{"id":"d870c9f6.1fd61","type":"delay","z":"28078c62.9890fc","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":630,"y":1160,"wires":[[]]},{"id":"92c2e55a.ebf19","type":"influxdb out","z":"28078c62.9890fc","influxdb":"386f5ba6.05766c","name":"DHT221_Temp DB","measurement":"DHT221T.","precision":"","retentionPolicy":"","x":1110,"y":540,"wires":[]},{"id":"a01a746b.edaae8","type":"influxdb out","z":"28078c62.9890fc","influxdb":"eae1257.a4e17d8","name":"DHT221_Humi DB","measurement":"DHT221H.","precision":"","retentionPolicy":"","x":1110,"y":580,"wires":[]},{"id":"6a68dc62.c14084","type":"debug","z":"28078c62.9890fc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1190,"y":320,"wires":[]},{"id":"43a4c02f.0aeb3","type":"influxdb out","z":"28078c62.9890fc","influxdb":"997a1055.eca848","name":"Sensory_Field1 DB","measurement":"Sensor_1","precision":"","retentionPolicy":"","x":1110,"y":500,"wires":[]},{"id":"d4d9756.4dd9808","type":"json","z":"28078c62.9890fc","name":"","property":"payload","action":"","pretty":false,"x":610,"y":240,"wires":[["604917b9.7dcdc8"]]},{"id":"1a701b62.3c767d","type":"debug","z":"28078c62.9890fc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1050,"y":140,"wires":[]},{"id":"2c470efd.7b9f5a","type":"debug","z":"28078c62.9890fc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":470,"y":120,"wires":[]},{"id":"ceeb21e2.f06d28","type":"change","z":"28078c62.9890fc","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"DHT221_Temp","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"{\"DHT221_Temp\" : payload}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":140,"wires":[["1a701b62.3c767d"]]},{"id":"1a06b381.b17664","type":"debug","z":"28078c62.9890fc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1010,"y":240,"wires":[]},{"id":"604917b9.7dcdc8","type":"change","z":"28078c62.9890fc","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"DHT221_Temp","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":240,"wires":[["1a06b381.b17664","dd9ce2c7.413d1"]]},{"id":"dd9ce2c7.413d1","type":"function","z":"28078c62.9890fc","name":"Amalgamate Sensory data","func":"context.data = context.data || {};\n\nswitch (msg.topic) {\n\ncase \"DHT221_Temp\":\n    context.data.DHT221_Temp = msg.payload;\n    msg = null;\n    break;\ncase \"bulk\":\n    context.data.bulk = msg.payload;\n    msg = null;\n    break;\ncase \"absorption\":\n    context.data.absorption = msg.payload;\n    msg = null;\n    break;\ncase \"float\":\n    context.data.float = msg.payload;\n    msg = null;\n    break;\ncase \"inverter\":\n    context.data.inverter = msg.payload;\n    msg = null;\n    break;\ncase \"overload\":\n    context.data.overload = msg.payload;\n    msg = null;\n    break;\ncase \"lowbattery\":\n    context.data.lowbattery = msg.payload;\n    msg = null;\n    break;\ncase \"temperature\":\n    context.data.temperature = msg.payload;\n    msg = null;\n    break;\n\ndefault:\n    msg = null;\n\tbreak;\n\n}\n\nif(context.data.mains !== null && context.data.bulk !== null && context.data.absorption !== null && context.data.float !== null && context.data.inverter !== null && context.data.overload !== null && context.data.lowbattery !== null && context.data.temperature !== null ) {\n\tmsg2 = {};\nmsg2.payload = {\n    mains: context.data.mains,\n    bulk: context.data.bulk,\n    absorption: context.data.absorption,\n    float: context.data.float,\n    inverter: context.data.inverter,\n    overload: context.data.overload,\n    lowbattery: context.data.lowbattery,\n    temperature: context.data.temperature\n}\n;\n\ncontext.data=null;\n\treturn msg2;\n}","outputs":1,"noerr":0,"x":960,"y":320,"wires":[["6a68dc62.c14084"]]},{"id":"b551b358.237c68","type":"ui_group","z":"","name":"DHT221","tab":"dd3b154c.f7d79","order":2,"disp":true,"width":"6","collapse":false},{"id":"957f84b5.bf5e","type":"ui_group","z":"","name":"Interact","tab":"dd3b154c.f7d79","order":7,"disp":true,"width":"6","collapse":false},{"id":"647362d8.d9d214","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"12e2222f.a9959e","type":"ui_group","z":"","name":"DHT222","tab":"dd3b154c.f7d79","order":3,"disp":true,"width":"6","collapse":false},{"id":"cfa35f17.2887d","type":"ui_group","z":"","name":"charts","tab":"dd3b154c.f7d79","order":1,"disp":true,"width":"6","collapse":false},{"id":"f045d040.9cde18","type":"ui_group","z":"","name":"Probe's_1","tab":"dd3b154c.f7d79","order":4,"disp":true,"width":"6","collapse":false},{"id":"e41def3e.c1a48","type":"ui_group","z":"","name":"Probe's_2","tab":"dd3b154c.f7d79","order":5,"disp":true,"width":"6","collapse":false},{"id":"e140c582.4168c8","type":"ui_group","z":"","name":"Server Info","tab":"dd3b154c.f7d79","order":8,"disp":true,"width":"6","collapse":false},{"id":"386f5ba6.05766c","type":"influxdb","z":"","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"DHT221_Temp","name":"","usetls":false,"tls":""},{"id":"eae1257.a4e17d8","type":"influxdb","z":"","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"DHT221_Humi","name":"","usetls":false,"tls":""},{"id":"997a1055.eca848","type":"influxdb","z":"","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"Sensory_Field1","name":"","usetls":false,"tls":""},{"id":"dd3b154c.f7d79","type":"ui_tab","z":"","name":"Home","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

flows.json (26.4 KB)