Modbus TCP - convert payload to single bits

3,054 views
Skip to first unread message

Marcus Jelsch

unread,
Mar 12, 2016, 7:05:19 AM3/12/16
to Node-RED
Hi

i have a modbus tcp buscoupler from phoenix contact - il eth bk di8 do4 2tx-pac.

the problem is that i can only read complete registers (function code 3 - modbus class 0).

Now i have to convert the 16bit word to single bits that i can use to see the state of my inputs.

if that works i have to do the same for my outputs because i cannot write a coil, i can only write the whole
register.

Please help me!

Thank u much.

Lawrence Griffiths

unread,
Mar 12, 2016, 3:21:01 PM3/12/16
to Node-RED
Marcus what modbus node are using modbustcp?
Assume the phoenix contact is moving coils into a single register?

I will have to set up a modbustcp node as I think it returns a string.
So if it is then you need to convert it to HEX and then create a new Buffer.
Then you should be able to access each bit.
This you would do in a function node.

If I have time I will have a go but there are real Devs. on the forum so someone might step in in mean time.

Lawrence

Marcus Jelsch

unread,
Mar 12, 2016, 5:04:51 PM3/12/16
to node...@googlegroups.com

Hi Lawrance,

It is a buscoupler with an Ethernet port. It communicates over Modbus top. It's like wago 750-341.

But the problem is that I can only read and write registers. Not like common devices were I can read and write single coils or discrete inputs.

And now is my problem how to handle that register to get the boolean for each coil or input.

Marcus

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/N4uQ8eStTvE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
For more options, visit https://groups.google.com/d/optout.

Lawrence Griffiths

unread,
Mar 13, 2016, 6:19:31 AM3/13/16
to Node-RED
Marcus, is this the modbus node you are using to talk to the  buscoupler 
https://www.npmjs.com/package/node-red-contrib-modbustcp

Can you provide a link to a data sheet/manual for the device?
Or is just a branded version of the Wago

Ok will put as solution something together hopefully by Wednesday!

Lawrence

Marcus Jelsch

unread,
Mar 13, 2016, 9:09:11 AM3/13/16
to node...@googlegroups.com
Yes, this is the node i use. And it works.
I got the message and i can inject a number to write the register to the buscoupler.

Here the link to the datasheet:


On page 23 u find the supported function codes.
On page 26 u see the dynamic address table wich i use.

Marcus

Message has been deleted

Marcus Jelsch

unread,
Mar 13, 2016, 9:16:14 AM3/13/16
to Node-RED
Here is my actual flow:

[{"id":"d18ae16f.2e752","type":"modbustcp-server","z":"dc4d268d.23b2d8","host":"192.168.0.20","port":"502","unit_id":"1"},{"id":"2c6cd8fa.d39328","type":"debug","z":"dc4d268d.23b2d8","name":"","active":true,"console":"false","complete":"true","x":1070,"y":60,"wires":[]},{"id":"48e2b671.b71d48","type":"modbustcp-read","z":"dc4d268d.23b2d8","name":"IL ETH BK DI8 DO4 TX2-PAC - 4 Digitale Eingänge","dataType":"HoldingRegister","adr":"0","quantity":"1","rate":"1","server":"d18ae16f.2e752","x":250,"y":60,"wires":[["2c6cd8fa.d39328"]]},{"id":"851fa56a.7ae058","type":"inject","z":"dc4d268d.23b2d8","name":"","topic":"","payload":"15","payloadType":"num","repeat":"","crontab":"","once":false,"x":510,"y":200,"wires":[["da6646a1.2599b8"]]},{"id":"da6646a1.2599b8","type":"modbustcp-write","z":"dc4d268d.23b2d8","name":"","dataType":"HoldingRegister","adr":"384","server":"d18ae16f.2e752","x":1090,"y":200,"wires":[]},{"id":"15cf61c9.ea309e","type":"modbustcp-write","z":"dc4d268d.23b2d8","name":"","dataType":"HoldingRegister","adr":"385","server":"d18ae16f.2e752","x":1080,"y":280,"wires":[]},{"id":"366550a9.c99ab","type":"inject","z":"dc4d268d.23b2d8","name":"","topic":"","payload":"65535","payloadType":"num","repeat":"","crontab":"","once":false,"x":510,"y":280,"wires":[["15cf61c9.ea309e"]]}]


Marcus Jelsch

unread,
Mar 16, 2016, 4:16:19 PM3/16/16
to Node-RED
Hey Lawrence,

still i have no solution.

But maybe here is a way to solve this:

If i read a register at given adress its payload is 0.
But in binary it is: 00 00 00 00 00 00 00 00

Depending on the used module on my buscoupler i have 1, 2, 4, 8 or 16 inputs or coils that i want to read out.
that means i need for example only 8 digits of the 16 only.

But since i'm only a "glue-man" and no real programmer i need a function that 
takes my msg.payload "0".
Makes the 16-bit binary from it - 00 00 00 00 00 00 00 00
and let me then choose how much of these binarys i want to use, depending on my inputs or coils
wich or  hidden behind these binarys.
And then makes like the switch-node the same number of outputs.

sorry for my maybe bad english.

Dave C-J

unread,
Mar 16, 2016, 4:22:22 PM3/16/16
to node...@googlegroups.com
What do you get for some other example binary inputs ?
do you get   65280   = 0xFF00  = binary 11 11 11 11 00 00 00 00 ?
etc ? ie is it one bit per coil simply packed ?

Marcus Jelsch

unread,
Mar 16, 2016, 4:30:12 PM3/16/16
to node...@googlegroups.com

You are right for example msg.payload = 65535 = 11 11 11 11 11 11 11 11 means all inputs or outputs are activated.

--

Marcus Jelsch

unread,
Mar 16, 2016, 4:31:04 PM3/16/16
to node...@googlegroups.com

Yes one bit per coil simply packed to a 16 bit word.

Am 16.03.2016 21:22 schrieb "Dave C-J" <dce...@gmail.com>:
--

Marcus Jelsch

unread,
Mar 17, 2016, 4:16:54 PM3/17/16
to node...@googlegroups.com
hi,

today i found out that in javascript i can do the following:

var i = msg.payload; // for example 20
var str = i.toString(2);  
msg.payload = str;
return msg;   // in javascript it returns - 10100

but this does not work in node-red??!! Why? This would be my solution.

Please help me.


Nicholas O'Leary

unread,
Mar 17, 2016, 4:45:59 PM3/17/16
to Node-RED Mailing List
Hi,

what result do you get?

That code assumes msg.payload is a number type. If msg.payload is actually a string representation of a number, then it won't work.

Here's an example flow that demonstrates the two:

[{"id":"5db4d51e.a24b2c","type":"function","z":"ad2c075c.52d3f8","name":"","func":"var i = msg.payload; // for example 20\nvar str = i.toString(2);  \nmsg.payload = str;\nreturn msg;","outputs":1,"noerr":0,"x":311.5,"y":237,"wires":[["57e1b84a.a81e48"]]},{"id":"57e1b84a.a81e48","type":"debug","z":"ad2c075c.52d3f8","name":"","active":true,"console":"false","complete":"false","x":466,"y":239,"wires":[]},{"id":"1cdef660.e3210a","type":"inject","z":"ad2c075c.52d3f8","name":"Number 20","topic":"","payload":"20","payloadType":"num","repeat":"","crontab":"","once":false,"x":157,"y":225,"wires":[["5db4d51e.a24b2c"]]},{"id":"c7331061.38ccf","type":"inject","z":"ad2c075c.52d3f8","name":"String \"20\"","topic":"","payload":"20","payloadType":"str","repeat":"","crontab":"","once":false,"x":160,"y":272,"wires":[["5db4d51e.a24b2c"]]}]








You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.

Colin Law

unread,
Mar 17, 2016, 4:51:04 PM3/17/16
to node...@googlegroups.com
Hi
I am a newcommer to node-red and have come late to this thread, but
you can test whether a particular bit is set using something like, for
the rightmost bit
if ((msg.payload & 1) != 0 ) {
// this will be executed if bit 0 is set
}
if ((msg.payload & 2) != 0 ) {
// this will be executed if bit 1 is set
}
if ((msg.payload & 4) != 0 ) {
// this will be executed if bit 2 is set
}
etc, where the test goes on against 8, 16. 32 etc.

Looking at the Function node I see that if you build an array of
messages and pass that to node.send then it sends the messages to the
outputs, sending no message if the entry in the array is null, so I
think you could send messages on the relevant outputs based on which
bits were set. If the payload coming is in actually a string, as
suggested by Nicholas then you would have to convert it to a number
first. Is that the sort of thing you are attempting to achieve?

There are more concise methods of writing the above code if it is what
you want to do.

Colin


On 17 March 2016 at 20:16, 'Marcus Jelsch' via Node-RED
<node...@googlegroups.com> wrote:
> You received this message because you are subscribed to the Google Groups
> "Node-RED" group.
> To unsubscribe from this group and stop receiving emails from it, send an

Marcus Jelsch

unread,
Mar 17, 2016, 4:52:39 PM3/17/16
to node...@googlegroups.com

My result is still 20...

Nicholas O'Leary

unread,
Mar 17, 2016, 4:55:39 PM3/17/16
to Node-RED Mailing List
My result is still 20...

which implies the msg.payload you are passing in is a string representation of the number, not a number type.

So you need to convert it to a number type before the .toString(2) trick will work:


if (typeof msg.payload !== 'number') {
    msg.payload = Number(msg.payload);
}
var i = msg.payload; // for example 20
var str = i.toString(2);  
msg.payload = str;
return msg; 

Marcus Jelsch

unread,
Mar 17, 2016, 5:04:13 PM3/17/16
to Node-RED
Thank u Nick u made my day!!!!

Colin, i thought about a solution like yours, but the result that i want is a function node with
16 outputs - each output representing 1bit (a coil or a input).
Your solution is too much work because after processing i have to glue them together.


Marcus Jelsch

unread,
Mar 17, 2016, 5:16:14 PM3/17/16
to Node-RED
Here is the final solution with 2 outputs working very nice!!!

Thank u very much for helping me!!!!



[{"id":"d18ae16f.2e752","type":"modbustcp-server","z":"dc4d268d.23b2d8","host":"192.168.0.20","port":"502","unit_id":"1"},{"id":"2c6cd8fa.d39328","type":"debug","z":"dc4d268d.23b2d8","name":"","active":true,"console":"false","complete":"true","x":1070,"y":60,"wires":[]},{"id":"48e2b671.b71d48","type":"modbustcp-read","z":"dc4d268d.23b2d8","name":"IL ETH BK DI8 DO4 TX2-PAC - 4 Digitale Eingänge","dataType":"HoldingRegister","adr":"0","quantity":"1","rate":"1","server":"d18ae16f.2e752","x":510,"y":60,"wires":[["2c6cd8fa.d39328","8bef2dd0.f190e"]]},{"id":"8bef2dd0.f190e","type":"function","z":"dc4d268d.23b2d8","name":"int 2 bit","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nvar base2_ = msg.payload.toString(2).split(\"\").reverse().join(\"\");\nvar baseL_ = new Array(17 - base2_.length).join(\"0\");\nvar base2 = base2_ + baseL_;\n\nmsg.payload = base2[0];\n\nvar msg2 = {};\nmsg2.payload = base2[1];\n\nreturn [msg, msg2];","outputs":"2","noerr":0,"x":840,"y":140,"wires":[["84df73d9.bd824"],["f44548d2.705398"]]},{"id":"84df73d9.bd824","type":"debug","z":"dc4d268d.23b2d8","name":"","active":true,"console":"false","complete":"false","x":1050,"y":120,"wires":[]},{"id":"f44548d2.705398","type":"debug","z":"dc4d268d.23b2d8","name":"","active":true,"console":"false","complete":"false","x":1050,"y":160,"wires":[]}]

Colin Law

unread,
Mar 17, 2016, 5:50:58 PM3/17/16
to node...@googlegroups.com
On 17 March 2016 at 21:04, 'Marcus Jelsch' via Node-RED
<node...@googlegroups.com> wrote:
> ...
> Colin, i thought about a solution like yours, but the result that i want is
> a function node with
> 16 outputs - each output representing 1bit (a coil or a input).
> Your solution is too much work because after processing i have to glue them
> together.

I think I did not explain clearly what I meant, it is basically the
same as you have done but but using bitwise testing to determine which
messages to return rather than converting it to a string. I may have
a go at coding it if I have some spare time just to see how it
compares. I would not actually test the individual bits as I have
shown, it would be done in a loop, building the resulting array based
on the bits. Your solution looks good though.

Cheers

Colin

Dave C-J

unread,
Mar 18, 2016, 1:17:29 PM3/18/16
to node...@googlegroups.com
Marcus

no idea if this helps - this function accepts a number 0 - 65535 and sets the various 16 outputs true or false according to the bits set.
Bit 15 is at the top and bit 0 at the bottom.

[{"id":"630b34aa.f30c3c","type":"function","z":"4affede3.af6f44","name":"Split16","func":"var p = parseInt(msg.payload);\nvar m = [];\nfor (var i=0; i<16; i++) {\n    // test top bit and set corresponding payload\n    m[i] = {payload: ((p & 0x8000) ? true : false) };\n    p = p << 1; // divide by two and keep as an integer\n}\n\nreturn m;","outputs":"16","noerr":0,"x":300,"y":1086,"wires":[["f44eb922.65d8c8"],[],[],[],[],[],[],[],[],[],[],[],[],[],[],["427204b2.71419c"]]},{"id":"f2970fdc.4b56","type":"inject","z":"4affede3.af6f44","name":"","topic":"","payload":"65280","payloadType":"num","repeat":"","crontab":"","once":false,"x":101,"y":1086,"wires":[["630b34aa.f30c3c"]]},{"id":"f44eb922.65d8c8","type":"debug","z":"4affede3.af6f44","name":"","active":true,"console":"false","complete":"false","x":548,"y":991,"wires":[]},{"id":"427204b2.71419c","type":"debug","z":"4affede3.af6f44","name":"","active":true,"console":"false","complete":"false","x":540,"y":1183,"wires":[]}]

Marcus Jelsch

unread,
Mar 18, 2016, 5:48:01 PM3/18/16
to node...@googlegroups.com
Hey Dave,

your code is great, much better than my!
Thank u for that!

Now i have the next problem:

The 16 channels will now be processed and must be glued together to
a payload that i can write the a register with outputs.

U have an idea?

Marcus Jelsch

unread,
Mar 18, 2016, 5:52:43 PM3/18/16
to node...@googlegroups.com
Here is my actual flow.


[{"id":"d18ae16f.2e752","type":"modbustcp-server","z":"dc4d268d.23b2d8","host":"192.168.0.20","port":"502","unit_id":"1"},{"id":"48e2b671.b71d48","type":"modbustcp-read","z":"dc4d268d.23b2d8","name":"IL ETH BK DI8 DO4 TX2-PAC - 8 digital inputs","dataType":"HoldingRegister","adr":"0","quantity":"1","rate":"1","server":"d18ae16f.2e752","x":340,"y":240,"wires":[["b07dfa09.04d0b8"]]},{"id":"84df73d9.bd824","type":"debug","z":"dc4d268d.23b2d8","name":"8","active":true,"console":"false","complete":"payload","x":1070,"y":100,"wires":[]},{"id":"f44548d2.705398","type":"debug","z":"dc4d268d.23b2d8","name":"7","active":true,"console":"false","complete":"payload","x":1070,"y":140,"wires":[]},{"id":"d5277cf5.b86f","type":"debug","z":"dc4d268d.23b2d8","name":"6","active":true,"console":"false","complete":"payload","x":1070,"y":180,"wires":[]},{"id":"80aaf2f1.cc37c","type":"debug","z":"dc4d268d.23b2d8","name":"5","active":true,"console":"false","complete":"payload","x":1070,"y":220,"wires":[]},{"id":"37ee2d5c.4bb852","type":"debug","z":"dc4d268d.23b2d8","name":"4","active":true,"console":"false","complete":"payload","x":1070,"y":260,"wires":[]},{"id":"311f546f.93b5dc","type":"debug","z":"dc4d268d.23b2d8","name":"3","active":true,"console":"false","complete":"payload","x":1070,"y":300,"wires":[]},{"id":"aa2b83b6.aa62a","type":"debug","z":"dc4d268d.23b2d8","name":"2","active":true,"console":"false","complete":"payload","x":1070,"y":340,"wires":[]},{"id":"b1f4e5a1.303888","type":"debug","z":"dc4d268d.23b2d8","name":"1","active":true,"console":"false","complete":"payload","x":1070,"y":380,"wires":[]},{"id":"b07dfa09.04d0b8","type":"function","z":"dc4d268d.23b2d8","name":"Split16","func":"var p = parseInt(msg.payload);\nvar m = [];\nfor (var i=0; i<16; i++) {\n    // test top bit and set corresponding payload\n    m[i] = {payload: ((p & 0x8000) ? true : false) };\n    p = p << 1; // divide by two and keep as an integer\n}\n\nreturn m;","outputs":"16","noerr":0,"x":650,"y":240,"wires":[[],[],[],[],[],[],[],[],["84df73d9.bd824"],["f44548d2.705398"],["d5277cf5.b86f"],["80aaf2f1.cc37c"],["37ee2d5c.4bb852"],["311f546f.93b5dc"],["aa2b83b6.aa62a"],["b1f4e5a1.303888"]]}]

Marcus Jelsch

unread,
Mar 19, 2016, 4:00:05 PM3/19/16
to node...@googlegroups.com
Hey,

another desperate attempt of mine to solve my problem.
Can u plz have a look at the flow and tell me why i get "NaN"
as result.

[{"id":"d18ae16f.2e752","type":"modbustcp-server","z":"dc4d268d.23b2d8","host":"192.168.0.20","port":"502","unit_id":"1"},{"id":"48e2b671.b71d48","type":"modbustcp-read","z":"dc4d268d.23b2d8","name":"IL ETH BK DI8 DO4 TX2-PAC - 8 digital inputs","dataType":"HoldingRegister","adr":"0","quantity":"1","rate":"5","server":"d18ae16f.2e752","x":220,"y":260,"wires":[["b07dfa09.04d0b8"]]},{"id":"84df73d9.bd824","type":"debug","z":"dc4d268d.23b2d8","name":"8","active":true,"console":"false","complete":"payload","x":1310,"y":40,"wires":[]},{"id":"f44548d2.705398","type":"debug","z":"dc4d268d.23b2d8","name":"7","active":true,"console":"false","complete":"payload","x":1310,"y":80,"wires":[]},{"id":"d5277cf5.b86f","type":"debug","z":"dc4d268d.23b2d8","name":"6","active":true,"console":"false","complete":"payload","x":1310,"y":120,"wires":[]},{"id":"80aaf2f1.cc37c","type":"debug","z":"dc4d268d.23b2d8","name":"5","active":true,"console":"false","complete":"payload","x":1310,"y":160,"wires":[]},{"id":"37ee2d5c.4bb852","type":"debug","z":"dc4d268d.23b2d8","name":"4","active":true,"console":"false","complete":"payload","x":1310,"y":200,"wires":[]},{"id":"311f546f.93b5dc","type":"debug","z":"dc4d268d.23b2d8","name":"3","active":true,"console":"false","complete":"payload","x":1310,"y":240,"wires":[]},{"id":"aa2b83b6.aa62a","type":"debug","z":"dc4d268d.23b2d8","name":"2","active":true,"console":"false","complete":"payload","x":1310,"y":280,"wires":[]},{"id":"b1f4e5a1.303888","type":"debug","z":"dc4d268d.23b2d8","name":"1","active":true,"console":"false","complete":"payload","x":1310,"y":320,"wires":[]},{"id":"a55ea062.6e1a","type":"modbustcp-write","z":"dc4d268d.23b2d8","name":"8 Outputs","dataType":"HoldingRegister","adr":"384","server":"d18ae16f.2e752","x":1300,"y":360,"wires":[]},{"id":"9c3485da.be7838","type":"function","z":"dc4d268d.23b2d8","name":"Merge the bits before writing to buscoupler","func":"context.data = context.data || {};\n/*\nif (typeof msg.payload !== 'string') \n{\n    msg.payload = String(msg.payload);\n}    \n*/\nswitch (msg.topic) \n{\n    case \"task1\":\n        context.data.task1 = msg.payload;\n        msg = null;\n        break;\n    case \"task2\":\n        context.data.task2 = msg.payload;\n        msg = null;\n        break;\n    case \"task3\":\n        context.data.task3 = msg.payload;\n        msg = null;\n        break;\n    case \"task4\":\n        context.data.task4 = msg.payload;\n        msg = null;\n        break;    \n    case \"task5\":\n        context.data.task5 = msg.payload;\n        msg = null;\n        break;    \n    case \"task6\":\n        context.data.task6 = msg.payload;\n        msg = null;\n        break;\n    case \"task7\":\n        context.data.task7 = msg.payload;\n        msg = null;\n        break;\n    case \"task8\":\n        context.data.task8 = msg.payload;\n        msg = null;\n        break;    \n}\n\nif(context.data.task1 !== null && context.data.task2 !== null && context.data.task3 !== null && context.data.task4 !== null && context.data.task5 !== null && context.data.task6 !== null && context.data.task7 !== null && context.data.task8 !== null) \n{\n\tvar msg2 = {};\n\tmsg2.payload = context.data.task1 + context.data.task2 + context.data.task3 + context.data.task4 + context.data.task5 + context.data.task6 + context.data.task7 + context.data.task8;\n    context.data=null;\n\treturn msg2;\n} \n","outputs":1,"noerr":0,"x":1010,"y":440,"wires":[["a55ea062.6e1a","9d584677.e98bb8"]]},{"id":"b07dfa09.04d0b8","type":"function","z":"dc4d268d.23b2d8","name":"Split16","func":"var p = parseInt(msg.payload);\nvar m = [];\nfor (var i=0; i<16; i++) {\n    // test top bit and set corresponding payload\n    m[i] = {payload: ((p & 0x8000) ? 1 : 0) };\n    p = p << 1; // divide by two and keep as an integer\n}\n\nreturn m;","outputs":"16","noerr":0,"x":470,"y":260,"wires":[[],[],[],[],[],[],[],[],["5dd76fce.1b35a"],["60133072.bd8e4"],["ed20559e.588468"],["3d1b255a.7b9d7a"],["e357ced7.1c5cd"],["3697e630.82b27a"],["a941b92e.489ec8"],["54250fcf.01dde"]]},{"id":"9d584677.e98bb8","type":"debug","z":"dc4d268d.23b2d8","name":"","active":true,"console":"false","complete":"payload","x":1290,"y":440,"wires":[]},{"id":"54250fcf.01dde","type":"function","z":"dc4d268d.23b2d8","name":"Task1","func":"msg.topic=\"task1\";\nreturn msg;","outputs":1,"noerr":0,"x":710,"y":360,"wires":[["9c3485da.be7838","b1f4e5a1.303888"]]},{"id":"a941b92e.489ec8","type":"function","z":"dc4d268d.23b2d8","name":"Task2","func":"msg.topic=\"task2\";\nreturn msg;","outputs":1,"noerr":0,"x":710,"y":320,"wires":[["9c3485da.be7838","aa2b83b6.aa62a"]]},{"id":"3697e630.82b27a","type":"function","z":"dc4d268d.23b2d8","name":"Task3","func":"msg.topic=\"task3\";\nreturn msg;","outputs":1,"noerr":0,"x":710,"y":280,"wires":[["9c3485da.be7838","311f546f.93b5dc"]]},{"id":"e357ced7.1c5cd","type":"function","z":"dc4d268d.23b2d8","name":"Task4","func":"msg.topic=\"task4\";\nreturn msg;","outputs":1,"noerr":0,"x":710,"y":240,"wires":[["9c3485da.be7838","37ee2d5c.4bb852"]]},{"id":"3d1b255a.7b9d7a","type":"function","z":"dc4d268d.23b2d8","name":"Task5","func":"msg.topic=\"task5\";\nreturn msg;","outputs":1,"noerr":0,"x":710,"y":200,"wires":[["9c3485da.be7838","80aaf2f1.cc37c"]]},{"id":"ed20559e.588468","type":"function","z":"dc4d268d.23b2d8","name":"Task6","func":"msg.topic=\"task6\";\nreturn msg;","outputs":1,"noerr":0,"x":710,"y":160,"wires":[["9c3485da.be7838","d5277cf5.b86f"]]},{"id":"60133072.bd8e4","type":"function","z":"dc4d268d.23b2d8","name":"Task7","func":"msg.topic=\"task7\";\nreturn msg;","outputs":1,"noerr":0,"x":710,"y":120,"wires":[["9c3485da.be7838","f44548d2.705398"]]},{"id":"5dd76fce.1b35a","type":"function","z":"dc4d268d.23b2d8","name":"Task8","func":"msg.topic=\"task8\";\nreturn msg;","outputs":1,"noerr":0,"x":710,"y":80,"wires":[["9c3485da.be7838","84df73d9.bd824"]]}]

Mark Setrem

unread,
Mar 19, 2016, 5:07:36 PM3/19/16
to Node-RED
So whilst its not the answer to your question ( sorry!)

The way you are using context whilst still currently supported has been deprecated in favour of the way documented here:
http://nodered.org/docs/writing-functions#storing-data

So as you are writing this now I'd suggest using the new way to future proof yourself.


Marcus Jelsch

unread,
Mar 20, 2016, 8:55:28 AM3/20/16
to node...@googlegroups.com

Hey Mark,

Thank you for the hint. But I'm bad in English. But what seems interesting to me is the global variables.

Do I understand it right, that this let me read the buscoupler, store the data in global variables, I manipulate them to my needs and then write back to my buscoupler. If this works, then I have to find out how to do this.

Dave C-J

unread,
Mar 20, 2016, 9:48:57 AM3/20/16
to node...@googlegroups.com
Hi

here is a modified version.
I have changed the split function to tag each message with its bit number...  then used that in the join - rather than topic (only joining the bottom 8 as you had) - then converting back to a number as I expect that is what the register will want...

The changes to global that Mark mentioned are so thaht we can then persist the values externally to Node-RED at some point in the future... the current way of doing things won't go away for a good while (and may in fact stay as a volatile alternative for things you don;t want/need to persist)



[{"id":"f0f602b6.864c7","type":"inject","z":"4affede3.af6f44","name":"","topic":"","payload":"241","payloadType":"num","repeat":"","crontab":"","once":false,"x":89.5,"y":1674,"wires":[["8c23af99.a6aa4"]]},{"id":"8c23af99.a6aa4","type":"function","z":"4affede3.af6f44","name":"Split16","func":"var p = parseInt(msg.payload);\nvar m = [];\nfor (var i=0; i<16; i++) {\n    // test top bit and set corresponding payload\n    m[i] = {payload: ((p & 0x8000) ? 1 : 0), bit:(15-i)};\n    p = p << 1; // divide by two and keep as an integer\n}\n\nreturn m;","outputs":"16","noerr":0,"x":365,"y":1646,"wires":[[],[],[],[],[],[],[],[],["42ae562a.849d08"],["357b553f.f148aa"],["7e88ca1f.a5b3d4"],["d28207f.61c4ef8"],["2721eb15.0df5a4"],["3650da42.af86d6"],["3472c858.2c8f98"],["7c6f1d05.fa4bc4"]]},{"id":"42ae562a.849d08","type":"function","z":"4affede3.af6f44","name":"Task8","func":"msg.topic=\"task8\";\nreturn msg;","outputs":1,"noerr":0,"x":605,"y":1466,"wires":[["bfc7f71a.8d8d48","e0e9df40.c8e44"]]},{"id":"357b553f.f148aa","type":"function","z":"4affede3.af6f44","name":"Task7","func":"msg.topic=\"task7\";\nreturn msg;","outputs":1,"noerr":0,"x":605,"y":1506,"wires":[["bfc7f71a.8d8d48","ce44dcd6.9815"]]},{"id":"7e88ca1f.a5b3d4","type":"function","z":"4affede3.af6f44","name":"Task6","func":"msg.topic=\"task6\";\nreturn msg;","outputs":1,"noerr":0,"x":605,"y":1546,"wires":[["bfc7f71a.8d8d48","c88daa81.581d78"]]},{"id":"d28207f.61c4ef8","type":"function","z":"4affede3.af6f44","name":"Task5","func":"msg.topic=\"task5\";\nreturn msg;","outputs":1,"noerr":0,"x":605,"y":1586,"wires":[["bfc7f71a.8d8d48","aeb7d360.6bea"]]},{"id":"2721eb15.0df5a4","type":"function","z":"4affede3.af6f44","name":"Task4","func":"msg.topic=\"task4\";\nreturn msg;","outputs":1,"noerr":0,"x":605,"y":1626,"wires":[["bfc7f71a.8d8d48","a6392caa.1a98b"]]},{"id":"3650da42.af86d6","type":"function","z":"4affede3.af6f44","name":"Task3","func":"msg.topic=\"task3\";\nreturn msg;","outputs":1,"noerr":0,"x":605,"y":1666,"wires":[["bfc7f71a.8d8d48","472344ca.8a896c"]]},{"id":"3472c858.2c8f98","type":"function","z":"4affede3.af6f44","name":"Task2","func":"msg.topic=\"task2\";\nreturn msg;","outputs":1,"noerr":0,"x":605,"y":1706,"wires":[["bfc7f71a.8d8d48","5ab8b985.dd1bc8"]]},{"id":"7c6f1d05.fa4bc4","type":"function","z":"4affede3.af6f44","name":"Task1","func":"msg.topic=\"task1\";\nreturn msg;","outputs":1,"noerr":0,"x":605,"y":1746,"wires":[["bfc7f71a.8d8d48","b91d7c5a.24529"]]},{"id":"bfc7f71a.8d8d48","type":"function","z":"4affede3.af6f44","name":"Join 8","func":"context.data = context.data || new Array(16);\ncontext.data[msg.bit] = msg.payload;\n\nif(context.data[0] !== undefined && context.data[1] !== undefined && context.data[2] !== undefined && context.data[3] !== undefined && context.data[4] !== undefined && context.data[5] !== undefined && context.data[6] !== undefined && context.data[7] !== undefined) {\n\tvar msg2 = {};\n\tmsg2.payload = \"\" + context.data[7] + context.data[6] + context.data[5] + context.data[4] + context.data[3] + context.data[2] + context.data[1] + context.data[0];\n    msg2.payload = parseInt(msg2.payload,2);\n    context.data = new Array(8);\n\treturn msg2;\n} \n","outputs":1,"noerr":0,"x":872,"y":1826,"wires":[["1fbf344a.353f9c"]]},{"id":"e0e9df40.c8e44","type":"debug","z":"4affede3.af6f44","name":"8","active":false,"console":"false","complete":"payload","x":1205,"y":1426,"wires":[]},{"id":"ce44dcd6.9815","type":"debug","z":"4affede3.af6f44","name":"7","active":false,"console":"false","complete":"payload","x":1205,"y":1466,"wires":[]},{"id":"c88daa81.581d78","type":"debug","z":"4affede3.af6f44","name":"6","active":false,"console":"false","complete":"payload","x":1205,"y":1506,"wires":[]},{"id":"aeb7d360.6bea","type":"debug","z":"4affede3.af6f44","name":"5","active":false,"console":"false","complete":"payload","x":1205,"y":1546,"wires":[]},{"id":"a6392caa.1a98b","type":"debug","z":"4affede3.af6f44","name":"4","active":false,"console":"false","complete":"payload","x":1205,"y":1586,"wires":[]},{"id":"472344ca.8a896c","type":"debug","z":"4affede3.af6f44","name":"3","active":false,"console":"false","complete":"payload","x":1205,"y":1626,"wires":[]},{"id":"5ab8b985.dd1bc8","type":"debug","z":"4affede3.af6f44","name":"2","active":false,"console":"false","complete":"payload","x":1205,"y":1666,"wires":[]},{"id":"b91d7c5a.24529","type":"debug","z":"4affede3.af6f44","name":"1","active":false,"console":"false","complete":"payload","x":1205,"y":1706,"wires":[]},{"id":"1fbf344a.353f9c","type":"debug","z":"4affede3.af6f44","name":"","active":true,"console":"false","complete":"payload","x":1066,"y":1826,"wires":[]}]

Marcus Jelsch

unread,
Mar 20, 2016, 10:17:40 AM3/20/16
to node...@googlegroups.com
Dave!! All Thumbs up!

Exactly what i want and ur code is much more lightweight than my horrible attempt.

Now i have the scaffolding for my next attempts to get the smarthome running.

If you are in germany we have a beer together! 

Dave C-J

unread,
Mar 20, 2016, 10:26:58 AM3/20/16
to node...@googlegroups.com
Cheers !

warning - there are some very bad assumptions in that code ...  like converting numbers to strings (to concatenate them all) and then converting back to a number. but I didn't want to change your code too much - so you could see what was going on., and relate it to your current thinking. Net is there are many, many ways that you can break that - but that is half the fun :-)

Marcus Jelsch

unread,
Mar 25, 2016, 4:50:48 PM3/25/16
to Node-RED
Hey,

i have a new problem i have an idea what the problem is but dont know how to solve this.

I get no output from the "Join 16"- function node. I think he is waiting for all payloads till he begin
working. But i cant wait for all tasks to continue. Do u have a solution for this problem?

Here is my actual flow. 

For explanation: 
First i read the inputsregister.
Second i split them into 16 payloads and publish to different mqtt topics
Then the magic should happen in openhab.
Openhab then publishs the state of the needed outputs.

But now i'm missing the polling that is needed to get all my payloads and write the whole register.

The magic stops at that "join 16"-functon node.

Please help me.

[{"id":"37917c80.9ff644","type":"mqtt-broker","z":"","broker":"192.168.0.127","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willRetain":null,"willPayload":"","birthTopic":"","birthQos":"0","birthRetain":null,"birthPayload":""},{"id":"713bc2a8.0ed9bc","type":"modbustcp-server","z":"5071d51a.c2177c","host":"192.168.0.20","port":"502","unit_id":"1"},{"id":"97be4710.4f8588","type":"modbustcp-read","z":"5071d51a.c2177c","name":"IL ETH BK DI8 DO4 TX2-PAC - 16 digital inputs","dataType":"HoldingRegister","adr":"1","quantity":"1","rate":"1","server":"713bc2a8.0ed9bc","x":200,"y":40,"wires":[["70efa39b.a2fa8c"]]},{"id":"9468cbf4.f687c8","type":"modbustcp-write","z":"5071d51a.c2177c","name":"16 Outputs","dataType":"HoldingRegister","adr":"385","server":"713bc2a8.0ed9bc","x":970,"y":880,"wires":[]},{"id":"70efa39b.a2fa8c","type":"function","z":"5071d51a.c2177c","name":"Split16","func":"var p = parseInt(msg.payload);\nvar m = [];\nfor (var i=0; i<16; i++) {\n    // test top bit and set corresponding payload\n    m[i] = {payload: ((p & 0x8000) ? 1 : 0), bit:(15-i)};\n    p = p << 1; // divide by two and keep as an integer\n}\n\nreturn m;","outputs":"16","noerr":0,"x":110,"y":340,"wires":[["301708e9.091438"],["208fdf94.5bb5c"],["41bd1bdf.637c24"],["e3f93e42.c1aba"],["b5bef40a.f13878"],["f0f8b41b.78bd18"],["3589ab94.757b64"],["392e46ae.a42eaa"],["b0c54704.c6c6a8"],["bd76bb73.d03158"],["8e5d63a9.630c3"],["17128e94.af11e1"],["d56780d7.ef7ee"],["6b23ed5.1a46314"],["bfb9c542.7df128"],["43231887.aa5008"]]},{"id":"dca56044.3617","type":"function","z":"5071d51a.c2177c","name":"Task8","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nmsg.topic=\"task8\";\nreturn msg;","outputs":1,"noerr":0,"x":1190,"y":440,"wires":[["208dff28.7d0d8"]]},{"id":"5e3df95b.697df8","type":"function","z":"5071d51a.c2177c","name":"Task7","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nmsg.topic=\"task7\";\nreturn msg;","outputs":1,"noerr":0,"x":1190,"y":480,"wires":[["208dff28.7d0d8"]]},{"id":"a405ab76.7d35b8","type":"function","z":"5071d51a.c2177c","name":"Task6","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nmsg.topic=\"task6\";\nreturn msg;","outputs":1,"noerr":0,"x":1190,"y":520,"wires":[["208dff28.7d0d8"]]},{"id":"db1bcd87.2e238","type":"function","z":"5071d51a.c2177c","name":"Task5","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nmsg.topic=\"task5\";\nreturn msg;","outputs":1,"noerr":0,"x":1190,"y":560,"wires":[["208dff28.7d0d8"]]},{"id":"ef65ae36.d7673","type":"function","z":"5071d51a.c2177c","name":"Task4","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nmsg.topic=\"task4\";\nreturn msg;","outputs":1,"noerr":0,"x":1190,"y":600,"wires":[["208dff28.7d0d8"]]},{"id":"58c26ebe.a310a","type":"function","z":"5071d51a.c2177c","name":"Task3","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nmsg.topic=\"task3\";\nreturn msg;","outputs":1,"noerr":0,"x":1190,"y":640,"wires":[["208dff28.7d0d8","11d8dde6.a69b52"]]},{"id":"63b8bf36.33f6e","type":"function","z":"5071d51a.c2177c","name":"Task2","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nmsg.topic=\"task2\";\nreturn msg;","outputs":1,"noerr":0,"x":1190,"y":680,"wires":[["208dff28.7d0d8","23468271.1e75ce"]]},{"id":"688ceeba.c0e49","type":"function","z":"5071d51a.c2177c","name":"Task1","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nmsg.topic=\"task1\";\nreturn msg;","outputs":1,"noerr":0,"x":1191,"y":717,"wires":[["208dff28.7d0d8","75eb9e61.3464"]]},{"id":"208dff28.7d0d8","type":"function","z":"5071d51a.c2177c","name":"Join 16","func":"context.data = context.data || new Array(16);\ncontext.data[msg.bit] = msg.payload;\n\nif(context.data[0] !== undefined && context.data[1] !== undefined && context.data[2] !== undefined && context.data[3] !== undefined && context.data[4] !== undefined && context.data[5] !== undefined && context.data[6] !== undefined && context.data[7] !== undefined && context.data[8] !== undefined && context.data[9] !== undefined && context.data[10] !== undefined && context.data[11] !== undefined && context.data[12] !== undefined && context.data[13] !== undefined && context.data[14] !== undefined && context.data[15] !== undefined)\n{\n\tvar msg2 = {};\n\tmsg2.payload = \"\"+ context.data[15]+ context.data[14]+ context.data[13]+ context.data[12]+ context.data[11]+ context.data[10]+ context.data[9] + context.data[8] + context.data[7] + context.data[6] + context.data[5] + context.data[4] + context.data[3] + context.data[2] + context.data[1] + context.data[0];\n    msg2.payload = parseInt(msg2.payload,2);\n    context.data = new Array(16);\n\treturn msg2;\n} \n","outputs":1,"noerr":0,"x":1420,"y":740,"wires":[["23047d76.096842","9468cbf4.f687c8"]]},{"id":"23047d76.096842","type":"debug","z":"5071d51a.c2177c","name":"16 Outputs","active":true,"console":"false","complete":"payload","x":1190,"y":880,"wires":[]},{"id":"b1eb2872.352d28","type":"function","z":"5071d51a.c2177c","name":"Task16","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nmsg.topic=\"task16\";\nreturn msg;","outputs":1,"noerr":0,"x":1200,"y":120,"wires":[["208dff28.7d0d8"]]},{"id":"3b99ed85.b2bda2","type":"function","z":"5071d51a.c2177c","name":"Task15","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nmsg.topic=\"task15\";\nreturn msg;","outputs":1,"noerr":0,"x":1200,"y":160,"wires":[["208dff28.7d0d8"]]},{"id":"e2cf97b9.a3b0c8","type":"function","z":"5071d51a.c2177c","name":"Task14","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nmsg.topic=\"task14\";\nreturn msg;","outputs":1,"noerr":0,"x":1200,"y":200,"wires":[["208dff28.7d0d8"]]},{"id":"6aa2816c.2c498","type":"function","z":"5071d51a.c2177c","name":"Task13","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nmsg.topic=\"task13\";\nreturn msg;","outputs":1,"noerr":0,"x":1200,"y":240,"wires":[["208dff28.7d0d8"]]},{"id":"61f12532.fa4ddc","type":"function","z":"5071d51a.c2177c","name":"Task12","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nmsg.topic=\"task12\";\nreturn msg;","outputs":1,"noerr":0,"x":1200,"y":280,"wires":[["208dff28.7d0d8"]]},{"id":"c60ed4b1.ffd998","type":"function","z":"5071d51a.c2177c","name":"Task11","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nmsg.topic=\"task11\";\nreturn msg;","outputs":1,"noerr":0,"x":1200,"y":320,"wires":[["208dff28.7d0d8"]]},{"id":"3c9a7cc9.2b4064","type":"function","z":"5071d51a.c2177c","name":"Task10","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nmsg.topic=\"task10\";\nreturn msg;","outputs":1,"noerr":0,"x":1200,"y":360,"wires":[["208dff28.7d0d8"]]},{"id":"1f986f77.8334b1","type":"function","z":"5071d51a.c2177c","name":"Task9","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nmsg.topic=\"task9\";\nreturn msg;","outputs":1,"noerr":0,"x":1190,"y":400,"wires":[["208dff28.7d0d8"]]},{"id":"41bd1bdf.637c24","type":"mqtt out","z":"5071d51a.c2177c","name":"Hausanschlussraum/Rollorunter","topic":"Hausanschlussraum/Rollorunter","qos":"0","retain":"","broker":"37917c80.9ff644","x":550,"y":300,"wires":[]},{"id":"e3f93e42.c1aba","type":"mqtt out","z":"5071d51a.c2177c","name":"Hausanschlussraum/Rollohoch","topic":"Hausanschlussraum/Rollohoch","qos":"0","retain":"","broker":"37917c80.9ff644","x":550,"y":340,"wires":[]},{"id":"b5bef40a.f13878","type":"mqtt out","z":"5071d51a.c2177c","name":"Hausanschlussraum/Lichtschalter","topic":"Hausanschlussraum/Lichtschalter","qos":"0","retain":"","broker":"37917c80.9ff644","x":560,"y":380,"wires":[]},{"id":"f0f8b41b.78bd18","type":"mqtt out","z":"5071d51a.c2177c","name":"Hausanschlussraum/Praesenz","topic":"Hausanschlussraum/Praesenz","qos":"0","retain":"","broker":"37917c80.9ff644","x":550,"y":420,"wires":[]},{"id":"3589ab94.757b64","type":"mqtt out","z":"5071d51a.c2177c","name":"Hausanschlussraum/Fenster","topic":"Hausanschlussraum/Fenster","qos":"0","retain":"","broker":"37917c80.9ff644","x":540,"y":460,"wires":[]},{"id":"392e46ae.a42eaa","type":"mqtt out","z":"5071d51a.c2177c","name":"WC/Rollorunter","topic":"WC/Rollorunter","qos":"0","retain":"","broker":"37917c80.9ff644","x":500,"y":520,"wires":[]},{"id":"b0c54704.c6c6a8","type":"mqtt out","z":"5071d51a.c2177c","name":"WC/Rollohoch","topic":"WC/Rollohoch","qos":"0","retain":"","broker":"37917c80.9ff644","x":500,"y":560,"wires":[]},{"id":"bd76bb73.d03158","type":"mqtt out","z":"5071d51a.c2177c","name":"WC/Lichtschalter","topic":"WC/Lichtschalter","qos":"0","retain":"","broker":"37917c80.9ff644","x":510,"y":600,"wires":[]},{"id":"8e5d63a9.630c3","type":"mqtt out","z":"5071d51a.c2177c","name":"WC/Praesenz","topic":"WC/Praesenz","qos":"0","retain":"","broker":"37917c80.9ff644","x":500,"y":640,"wires":[]},{"id":"17128e94.af11e1","type":"mqtt out","z":"5071d51a.c2177c","name":"WC/Fenster","topic":"WC/Fenster","qos":"0","retain":"","broker":"37917c80.9ff644","x":490,"y":680,"wires":[]},{"id":"d56780d7.ef7ee","type":"mqtt out","z":"5071d51a.c2177c","name":"Flur/Praesenz","topic":"Flur/Praesenz","qos":"0","retain":"","broker":"37917c80.9ff644","x":500,"y":740,"wires":[]},{"id":"6b23ed5.1a46314","type":"mqtt out","z":"5071d51a.c2177c","name":"Flur/Lichtschalter1","topic":"Flur/Lichtschalter1","qos":"0","retain":"","broker":"37917c80.9ff644","x":510,"y":780,"wires":[]},{"id":"bfb9c542.7df128","type":"mqtt out","z":"5071d51a.c2177c","name":"Flur/Lichtschalter2","topic":"Flur/Lichtschalter2","qos":"0","retain":"","broker":"37917c80.9ff644","x":510,"y":820,"wires":[]},{"id":"43231887.aa5008","type":"mqtt out","z":"5071d51a.c2177c","name":"Flur/Haustür","topic":"Flur/Haustür","qos":"0","retain":"","broker":"37917c80.9ff644","x":490,"y":860,"wires":[]},{"id":"301708e9.091438","type":"mqtt out","z":"5071d51a.c2177c","name":"Schlafzimmer/Praesenz","topic":"Schlafzimmer/Praesenz","qos":"0","retain":"","broker":"37917c80.9ff644","x":530,"y":200,"wires":[]},{"id":"208fdf94.5bb5c","type":"mqtt out","z":"5071d51a.c2177c","name":"Schlafzimmer/Fenster","topic":"Schlafzimmer/Fenster","qos":"0","retain":"","broker":"37917c80.9ff644","x":520,"y":240,"wires":[]},{"id":"23510186.5abc9e","type":"mqtt in","z":"5071d51a.c2177c","name":"Schlafzimmer/Output/Licht","topic":"Schlafzimmer/Output/Licht","broker":"37917c80.9ff644","x":910,"y":780,"wires":[["688ceeba.c0e49","4831478a.ee30f8"]]},{"id":"8cd3216.1faa0e","type":"mqtt in","z":"5071d51a.c2177c","name":"Schlafzimmer/Output/Heizung","topic":"Schlafzimmer/Output/Heizung","broker":"37917c80.9ff644","x":920,"y":740,"wires":[["63b8bf36.33f6e"]]},{"id":"32aaf83a.b7ccc8","type":"mqtt in","z":"5071d51a.c2177c","name":"Schlafzimmer/Output/Rollohoch","topic":"Schlafzimmer/Output/Rollohoch","broker":"37917c80.9ff644","x":930,"y":700,"wires":[["58c26ebe.a310a"]]},{"id":"3f6d4aaa.7beeb6","type":"mqtt in","z":"5071d51a.c2177c","name":"Schlafzimmer/Output/Rollorunter","topic":"Schlafzimmer/Output/Rollorunter","broker":"37917c80.9ff644","x":930,"y":660,"wires":[["ef65ae36.d7673"]]},{"id":"2af4cb77.30af34","type":"mqtt in","z":"5071d51a.c2177c","name":"Leon/Output/Steckdosen","topic":"Leon/Output/Steckdosen","broker":"37917c80.9ff644","x":950,"y":360,"wires":[["3c9a7cc9.2b4064"]]},{"id":"686bdb81.bd8404","type":"mqtt in","z":"5071d51a.c2177c","name":"Leon/Output/Licht","topic":"Leon/Output/Licht","broker":"37917c80.9ff644","x":930,"y":520,"wires":[["a405ab76.7d35b8"]]},{"id":"81e22bb3.059d68","type":"mqtt in","z":"5071d51a.c2177c","name":"Leon/Output/Heizung","topic":"Leon/Output/Heizung","broker":"37917c80.9ff644","x":940,"y":480,"wires":[["5e3df95b.697df8"]]},{"id":"5a12d0dc.ee37e","type":"mqtt in","z":"5071d51a.c2177c","name":"Leon/Output/Rollohoch","topic":"Leon/Output/Rollohoch","broker":"37917c80.9ff644","x":940,"y":440,"wires":[["dca56044.3617"]]},{"id":"d4783f6c.79754","type":"mqtt in","z":"5071d51a.c2177c","name":"Leon/Output/Rollorunter","topic":"Leon/Output/Rollorunter","broker":"37917c80.9ff644","x":950,"y":400,"wires":[["1f986f77.8334b1"]]},{"id":"e712e99c.35a0e8","type":"mqtt in","z":"5071d51a.c2177c","name":"Ankleidezimmer/Output/Licht","topic":"Ankleidezimmer/Output/Licht","broker":"37917c80.9ff644","x":920,"y":600,"wires":[["db1bcd87.2e238"]]},{"id":"4b820fd6.2b9da","type":"mqtt in","z":"5071d51a.c2177c","name":"Basti/Output/Licht","topic":"Basti/Output/Licht","broker":"37917c80.9ff644","x":930,"y":300,"wires":[["c60ed4b1.ffd998"]]},{"id":"ba9e0b49.1f09d8","type":"mqtt in","z":"5071d51a.c2177c","name":"Basti/Output/Heizung","topic":"Basti/Output/Heizung","broker":"37917c80.9ff644","x":940,"y":260,"wires":[["61f12532.fa4ddc"]]},{"id":"10d06356.5c0f9d","type":"mqtt in","z":"5071d51a.c2177c","name":"Basti/Output/Rollohoch","topic":"Basti/Output/Rollohoch","broker":"37917c80.9ff644","x":940,"y":220,"wires":[["6aa2816c.2c498"]]},{"id":"b7f30725.89c278","type":"mqtt in","z":"5071d51a.c2177c","name":"Basti/Output/Rollorunter","topic":"Basti/Output/Rollorunter","broker":"37917c80.9ff644","x":950,"y":180,"wires":[["e2cf97b9.a3b0c8"]]},{"id":"5501b7a3.e3bd68","type":"mqtt in","z":"5071d51a.c2177c","name":"Basti/Output/Steckdosen","topic":"Basti/Output/Steckdosen","broker":"37917c80.9ff644","x":950,"y":140,"wires":[["3b99ed85.b2bda2"]]},{"id":"2d962712.982458","type":"mqtt in","z":"5071d51a.c2177c","name":"Fluroben/Output/Licht","topic":"Fluroben/Output/Licht","broker":"37917c80.9ff644","x":940,"y":80,"wires":[["b1eb2872.352d28"]]},{"id":"75eb9e61.3464","type":"debug","z":"5071d51a.c2177c","name":"Task1","active":true,"console":"false","complete":"payload","x":1410,"y":660,"wires":[]},{"id":"4831478a.ee30f8","type":"debug","z":"5071d51a.c2177c","name":"Schlafzimmerlicht","active":true,"console":"false","complete":"payload","x":1220,"y":780,"wires":[]},{"id":"23468271.1e75ce","type":"debug","z":"5071d51a.c2177c","name":"Task2","active":true,"console":"false","complete":"payload","x":1410,"y":620,"wires":[]},{"id":"11d8dde6.a69b52","type":"debug","z":"5071d51a.c2177c","name":"Task3","active":true,"console":"false","complete":"payload","x":1410,"y":580,"wires":[]}]

Mark Setrem

unread,
Mar 25, 2016, 5:22:35 PM3/25/16
to Node-RED

If you look at the function "join 16" you have the

line context.data[msg.bit] = msg.payload;

but I'm not sure you are setting "msg.bit" anywhere

You can check by
changing the output debug nodes e.g. "Task1" to Output "Complete msg object" so it will show you the complete msg object

or change the "join 16" so it reads...

node.warn("MSG.BIT"+msg.bit);
context.data[msg.bit] = msg.payload;

Marcus Jelsch

unread,
Mar 29, 2016, 3:02:32 PM3/29/16
to node...@googlegroups.com
Hi Mark,

this is not the solution.

I think the Problem is that the MQTT Message is only send once.
After that the "Task"-nodes recieve no-more message and stop working.

A solution could be to store the value of the MQTT message ( 1 or 0 ) and then send all 16 bits periodically to
the "join16"-function-node.

But i dont know how. Could this be my solution?
Maybe someone has a hint for me and i first try myself.

Thank you!


Marcus

Marcus Jelsch

unread,
Mar 29, 2016, 4:19:46 PM3/29/16
to node...@googlegroups.com
Maybe a solution could be the trigger-node but it sends messages only twice.
Do you know how to send msg.payload every second like the 
trigger-node but endless?

Marcus Jelsch

unread,
Apr 2, 2016, 4:22:05 PM4/2/16
to Node-RED
problem is solved.

if someone is interested tell me and i post the whole flow.

Marcus Jelsch

unread,
May 4, 2016, 3:48:28 PM5/4/16
to Node-RED
Here for u maybe helpful fopr others 2. And a backup for me!


[{"id":"5f2468d1.fce278","type":"mqtt-broker","z":"","broker":"192.168.0.127","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willRetain":"true","willPayload":"","birthTopic":"","birthQos":"0","birthRetain":"true","birthPayload":""},{"id":"b0d1a6e8.26d948","type":"function","z":"3677a67d.31317a","name":"Join 16","func":"\ncontext.data = context.data || [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0];\ncontext.data[msg.bit] = msg.payload;\n\n//if(context.data[0] !== undefined && context.data[1] !== undefined && context.data[2] !== undefined && context.data[3] !== undefined && context.data[4] !== undefined && context.data[5] !== undefined && context.data[6] !== undefined && context.data[7] !== undefined && context.data[8] !== undefined && context.data[9] !== undefined && context.data[10] !== undefined && context.data[11] !== undefined && context.data[12] !== undefined && context.data[13] !== undefined && context.data[14] !== undefined && context.data[15] !== undefined)\n//{\n\tvar msg2 = {};\n\tmsg2.payload = \"\"+ context.data[15]+ context.data[14]+ context.data[13]+ context.data[12]+ context.data[11]+ context.data[10]+ context.data[9] + context.data[8] + context.data[7] + context.data[6] + context.data[5] + context.data[4] + context.data[3] + context.data[2] + context.data[1] + context.data[0];\n    msg2.payload = parseInt(msg2.payload,2);\n    //context.data = new Array(16);\n    return msg2;\n//}","outputs":1,"noerr":0,"x":700,"y":80,"wires":[["4411d1f3.58915"]]},{"id":"4411d1f3.58915","type":"debug","z":"3677a67d.31317a","name":"16 Outputs","active":true,"console":"false","complete":"payload","x":850,"y":180,"wires":[]},{"id":"a2fd8387.8e5ca","type":"mqtt in","z":"3677a67d.31317a","name":"Schlafzimmer/Output/Licht","topic":"Schlafzimmer/Output/Licht","broker":"5f2468d1.fce278","x":130,"y":760,"wires":[["d3867dd8.233ec"]]},{"id":"66f2902b.b2a36","type":"mqtt in","z":"3677a67d.31317a","name":"Schlafzimmer/Output/Heizung","topic":"Schlafzimmer/Output/Heizung","broker":"5f2468d1.fce278","x":140,"y":720,"wires":[["5eddec37.246b34"]]},{"id":"7d7d4fd.10824b","type":"mqtt in","z":"3677a67d.31317a","name":"Schlafzimmer/Output/Rollohoch","topic":"Schlafzimmer/Output/Rollohoch","broker":"5f2468d1.fce278","x":150,"y":680,"wires":[["d0d93528.95e338"]]},{"id":"92da12d7.4a794","type":"mqtt in","z":"3677a67d.31317a","name":"Schlafzimmer/Output/Rollorunter","topic":"Schlafzimmer/Output/Rollorunter","broker":"5f2468d1.fce278","x":150,"y":640,"wires":[["7e1c0625.70f1e8"]]},{"id":"fa4fea4.f2bef18","type":"mqtt in","z":"3677a67d.31317a","name":"Leon/Output/Steckdosen","topic":"Leon/Output/Steckdosen","broker":"5f2468d1.fce278","x":130,"y":360,"wires":[["3fa1f5ba.5998aa"]]},{"id":"f9521d90.db35b","type":"mqtt in","z":"3677a67d.31317a","name":"Leon/Output/Licht","topic":"Leon/Output/Licht","broker":"5f2468d1.fce278","x":110,"y":520,"wires":[["889aa5e3.b9bea8"]]},{"id":"7cc9b390.b2906c","type":"mqtt in","z":"3677a67d.31317a","name":"Leon/Output/Heizung","topic":"Leon/Output/Heizung","broker":"5f2468d1.fce278","x":120,"y":480,"wires":[["7204b9e8.aebe88"]]},{"id":"cc711c5c.337bc","type":"mqtt in","z":"3677a67d.31317a","name":"Leon/Output/Rollohoch","topic":"Leon/Output/Rollohoch","broker":"5f2468d1.fce278","x":120,"y":440,"wires":[["fd38fa58.ed9df8"]]},{"id":"19fb9c49.72fb94","type":"mqtt in","z":"3677a67d.31317a","name":"Leon/Output/Rollorunter","topic":"Leon/Output/Rollorunter","broker":"5f2468d1.fce278","x":130,"y":400,"wires":[["91342ed9.eac2d"]]},{"id":"16e1f54.93d1b0b","type":"mqtt in","z":"3677a67d.31317a","name":"Ankleidezimmer/Output/Licht","topic":"Ankleidezimmer/Output/Licht","broker":"5f2468d1.fce278","x":140,"y":580,"wires":[["82077ae0.5a7c48"]]},{"id":"c13689c4.fe31a8","type":"mqtt in","z":"3677a67d.31317a","name":"Basti/Output/Licht","topic":"Basti/Output/Licht","broker":"5f2468d1.fce278","x":110,"y":300,"wires":[["3f8ba80f.fad938"]]},{"id":"9740fca4.98802","type":"mqtt in","z":"3677a67d.31317a","name":"Basti/Output/Heizung","topic":"Basti/Output/Heizung","broker":"5f2468d1.fce278","x":120,"y":260,"wires":[["a457609b.0347"]]},{"id":"f7d30df0.1d6","type":"mqtt in","z":"3677a67d.31317a","name":"Basti/Output/Rollohoch","topic":"Basti/Output/Rollohoch","broker":"5f2468d1.fce278","x":120,"y":220,"wires":[["5b659b23.724c54"]]},{"id":"3339057b.12557a","type":"mqtt in","z":"3677a67d.31317a","name":"Basti/Output/Rollorunter","topic":"Basti/Output/Rollorunter","broker":"5f2468d1.fce278","x":120,"y":180,"wires":[["7f45c916.6d7018"]]},{"id":"3e13feb3.71c252","type":"mqtt in","z":"3677a67d.31317a","name":"Basti/Output/Steckdosen","topic":"Basti/Output/Steckdosen","broker":"5f2468d1.fce278","x":130,"y":140,"wires":[["94feaa2b.ae83f8"]]},{"id":"ca5f0283.fb097","type":"mqtt in","z":"3677a67d.31317a","name":"Fluroben/Output/Licht","topic":"Fluroben/Output/Licht","broker":"5f2468d1.fce278","x":120,"y":80,"wires":[["83f80f02.877b4"]]},{"id":"d3867dd8.233ec","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 1","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n    msg.payload = 0;\n}\n\nmsg.bit = 0;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":760,"wires":[["b0d1a6e8.26d948"]]},{"id":"5eddec37.246b34","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 2","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n    msg.payload = 0;\n}\n\nmsg.bit = 1;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":720,"wires":[["b0d1a6e8.26d948"]]},{"id":"d0d93528.95e338","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 3","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n    msg.payload = 0;\n}\n\nmsg.bit = 2;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":680,"wires":[["b0d1a6e8.26d948"]]},{"id":"7e1c0625.70f1e8","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 4","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n    msg.payload = 0;\n}\n\nmsg.bit = 3;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":640,"wires":[["b0d1a6e8.26d948"]]},{"id":"82077ae0.5a7c48","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 5","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n    msg.payload = 0;\n}\n\nmsg.bit = 4;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":580,"wires":[["b0d1a6e8.26d948"]]},{"id":"889aa5e3.b9bea8","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 6","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n    msg.payload = 0;\n}\n\nmsg.bit = 5;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":520,"wires":[["b0d1a6e8.26d948"]]},{"id":"7204b9e8.aebe88","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 7","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n    msg.payload = 0;\n}\n\nmsg.bit = 6;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":480,"wires":[["b0d1a6e8.26d948"]]},{"id":"fd38fa58.ed9df8","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 8","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n    msg.payload = 0;\n}\n\nmsg.bit = 7;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":440,"wires":[["b0d1a6e8.26d948"]]},{"id":"91342ed9.eac2d","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 9","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n    msg.payload = 0;\n}\n\nmsg.bit = 8;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":400,"wires":[["b0d1a6e8.26d948"]]},{"id":"3fa1f5ba.5998aa","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 10","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n    msg.payload = 0;\n}\n\nmsg.bit = 9;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":360,"wires":[["b0d1a6e8.26d948"]]},{"id":"3f8ba80f.fad938","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 11","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n    msg.payload = 0;\n}\n\nmsg.bit = 10;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":300,"wires":[["b0d1a6e8.26d948"]]},{"id":"a457609b.0347","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 12","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n    msg.payload = 0;\n}\n\nmsg.bit = 11;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":260,"wires":[["b0d1a6e8.26d948"]]},{"id":"5b659b23.724c54","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 13","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n    msg.payload = 0;\n}\n\nmsg.bit = 12;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":220,"wires":[["b0d1a6e8.26d948"]]},{"id":"7f45c916.6d7018","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 14","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n    msg.payload = 0;\n}\n\nmsg.bit = 13;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":180,"wires":[["b0d1a6e8.26d948"]]},{"id":"94feaa2b.ae83f8","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 15","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n    msg.payload = 0;\n}\n\nmsg.bit = 14;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":140,"wires":[["b0d1a6e8.26d948"]]},{"id":"83f80f02.877b4","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 16","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n    msg.payload = 0;\n}\n\nmsg.bit = 15;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":80,"wires":[["b0d1a6e8.26d948"]]},{"id":"2447dcc5.4e5f04","type":"comment","z":"3677a67d.31317a","name":"Inject zero-state once at startup, all default to 0","info":"","x":200,"y":860,"wires":[]},{"id":"38ce52ac.69a9be","type":"comment","z":"3677a67d.31317a","name":"set the required msg.bit","info":"","x":400,"y":40,"wires":[]},{"id":"78594874.ab91b8","type":"comment","z":"3677a67d.31317a","name":"Merge all bits to one 16bit-register","info":"","x":680,"y":40,"wires":[]},{"id":"24e09216.25d37e","type":"inject","z":"3677a67d.31317a","name":"","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":true,"x":90,"y":900,"wires":[["d3867dd8.233ec"]]}]

Kemp Maritz

unread,
Apr 2, 2017, 2:08:00 AM4/2/17
to Node-RED
Hi Marcus,

Can you post the join side of your flow please?
Hopefully you still have it...

Basically, I want to set bits in a WORD that gets sent to a PLC.

Thanx!


On Wednesday, 4 May 2016 21:48:28 UTC+2, Marcus Jelsch wrote:
Here for u maybe helpful fopr others 2. And a backup for me!


[{"id":"5f2468d1.fce278","type":"mqtt-broker","z":"","broker":"192.168.0.127","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willRetain":"true","willPayload":"","birthTopic":"","birthQos":"0","birthRetain":"true","birthPayload":""},{"id":"b0d1a6e8.26d948","type":"function","z":"3677a67d.31317a","name":"Join 16","func":"\ncontext.data = context.data || [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0];\ncontext.data[msg.bit] = msg.payload;\n\n//if(context.data[0] !== undefined && context.data[1] !== undefined && context.data[2] !== undefined && context.data[3] !== undefined && context.data[4] !== undefined && context.data[5] !== undefined && context.data[6] !== undefined && context.data[7] !== undefined && context.data[8] !== undefined && context.data[9] !== undefined && context.data[10] !== undefined && context.data[11] !== undefined && context.data[12] !== undefined && context.data[13] !== undefined && context.data[14] !== undefined && context.data[15] !== undefined)\n//{\n\tvar msg2 = {};\n\tmsg2.payload = \"\"+ context.data[15]+ context.data[14]+ context.data[13]+ context.data[12]+ context.data[11]+ context.data[10]+ context.data[9] + context.data[8] + context.data[7] + context.data[6] + context.data[5] + context.data[4] + context.data[3] + context.data[2] + context.data[1] + context.data[0];\n    msg2.payload = parseInt(msg2.payload,2);\n    //context.data = new Array(16);\n    return msg2;\n//}","outputs":1,"noerr":0,"x":700,"y":80,"wires":[["4411d1f3.58915"]]},{"id":"4411d1f3.58915","type":"debug","z":"3677a67d.31317a","name":"16 Outputs","active":true,"console":"false","complete":"payload","x":850,"y":180,"wires":[]},{"id":"a2fd8387.8e5ca","type":"mqtt in","z":"3677a67d.31317a","name":"Schlafzimmer/Output/Licht","topic":"Schlafzimmer/Output/Licht","broker":"5f2468d1.fce278","x":130,"y":760,"wires":[["d3867dd8.233ec"]]},{"id":"66f2902b.b2a36","type":"mqtt in","z":"3677a67d.31317a","name":"Schlafzimmer/Output/Heizung","topic":"Schlafzimmer/Output/Heizung","broker":"5f2468d1.fce278","x":140,"y":720,"wires":[["5eddec37.246b34"]]},{"id":"7d7d4fd.10824b","type":"mqtt in","z":"3677a67d.31317a","name":"Schlafzimmer/Output/Rollohoch","topic":"Schlafzimmer/Output/Rollohoch","broker":"5f2468d1.fce278","x":150,"y":680,"wires":[["d0d93528.95e338"]]},{"id":"92da12d7.4a794","type":"mqtt in","z":"3677a67d.31317a","name":"Schlafzimmer/Output/Rollorunter","topic":"Schlafzimmer/Output/Rollorunter","broker":"5f2468d1.fce278","x":150,"y":640,"wires":[["7e1c0625.70f1e8"]]},{"id":"fa4fea4.f2bef18","type":"mqtt in","z":"3677a67d.31317a","name":"Leon/Output/Steckdosen","topic":"Leon/Output/Steckdosen","broker":"5f2468d1.fce278","x":130,"y":360,"wires":[["3fa1f5ba.5998aa"]]},{"id":"f9521d90.db35b","type":"mqtt in","z":"3677a67d.31317a","name":"Leon/Output/Licht","topic":"Leon/Output/Licht","broker":"5f2468d1.fce278","x":110,"y":520,"wires":[["889aa5e3.b9bea8"]]},{"id":"7cc9b390.b2906c","type":"mqtt in","z":"3677a67d.31317a","name":"Leon/Output/Heizung","topic":"Leon/Output/Heizung","broker":"5f2468d1.fce278","x":120,"y":480,"wires":[["7204b9e8.aebe88"]]},{"id":"cc711c5c.337bc","type":"mqtt in","z":"3677a67d.31317a","name":"Leon/Output/Rollohoch","topic":"Leon/Output/Rollohoch","broker":"5f2468d1.fce278","x":120,"y":440,"wires":[["fd38fa58.ed9df8"]]},{"id":"19fb9c49.72fb94","type":"mqtt in","z":"3677a67d.31317a","name":"Leon/Output/Rollorunter","topic":"Leon/Output/Rollorunter","broker":"5f2468d1.fce278","x":130,"y":400,"wires":[["91342ed9.eac2d"]]},{"id":"16e1f54.93d1b0b","type":"mqtt in","z":"3677a67d.31317a","name":"Ankleidezimmer/Output/Licht","topic":"Ankleidezimmer/Output/Licht","broker":"5f2468d1.fce278","x":140,"y":580,"wires":[["82077ae0.5a7c48"]]},{"id":"c13689c4.fe31a8","type":"mqtt in","z":"3677a67d.31317a","name":"Basti/Output/Licht","topic":"Basti/Output/Licht","broker":"5f2468d1.fce278","x":110,"y":300,"wires":[["3f8ba80f.fad938"]]},{"id":"9740fca4.98802","type":"mqtt in","z":"3677a67d.31317a","name":"Basti/Output/Heizung","topic":"Basti/Output/Heizung","broker":"5f2468d1.fce278","x":120,"y":260,"wires":[["a457609b.0347"]]},{"id":"f7d30df0.1d6","type":"mqtt in","z":"3677a67d.31317a","name":"Basti/Output/Rollohoch","topic":"Basti/Output/Rollohoch","broker":"5f2468d1.fce278","x":120,"y":220,"wires":[["5b659b23.724c54"]]},{"id":"3339057b.12557a","type":"mqtt in","z":"3677a67d.31317a","name":"Basti/Output/Rollorunter","topic":"Basti/Output/Rollorunter","broker":"5f2468d1.fce278","x":120,"y":180,"wires":[["7f45c916.6d7018"]]},{"id":"3e13feb3.71c252","type":"mqtt in","z":"3677a67d.31317a","name":"Basti/Output/Steckdosen","topic":"Basti/Output/Steckdosen","broker":"5f2468d1.fce278","x":130,"y":140,"wires":[["94feaa2b.ae83f8"]]},{"id":"ca5f0283.fb097","type":"mqtt in","z":"3677a67d.31317a","name":"Fluroben/Output/Licht","topic":"Fluroben/Output/Licht","broker":"5f2468d1.fce278","x":120,"y":80,"wires":[["83f80f02.877b4"]]},{"id":"d3867dd8.233ec","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 1","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n    msg.payload = 0;\n}\n\nmsg.bit = 0;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":760,"wires":[["b0d1a6e8.26d948"]]},{"id":"5eddec37.246b34","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 2","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n    msg.payload = 0;\n}\n\nmsg.bit = 1;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":720,"wires":[["b0d1a6e8.26d948"]]},{"id":"d0d93528.95e338","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 3","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n    msg.payload = 0;\n}\n\nmsg.bit = 2;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":680,"wires":[["b0d1a6e8.26d948"]]},{"id":"7e1c0625.70f1e8","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 4","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n    msg.payload = 0;\n}\n\nmsg.bit = 3;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":640,"wires":[["b0d1a6e8.26d948"]]},{"id":"82077ae0.5a7c48","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 5","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n    msg.payload = 0;\n}\n\nmsg.bit = 4;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":580,"wires":[["b0d1a6e8.26d948"]]},{"id":"889aa5e3.b9bea8","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 6","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n    msg.payload = 0;\n}\n\nmsg.bit = 5;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":520,"wires":[["b0d1a6e8.26d948"]]},{"id":"7204b9e8.aebe88","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 7","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n    msg.payload = 0;\n}\n\nmsg.bit = 6;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":480,"wires":[["b0d1a6e8.26d948"]]},{"id":"fd38fa58.ed9df8","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 8","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n    msg.payload = 0;\n}\n\nmsg.bit = 7;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":440,"wires":[["b0d1a6e8.26d948"]]},{"id":"91342ed9.eac2d","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 9","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n    msg.payload = 0;\n}\n\nmsg.bit = 8;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":400,"wires":[["b0d1a6e8.26d948"]]},{"id":"3fa1f5ba.5998aa","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 10","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n    msg.payload = 0;\n}\n\nmsg.bit = 9;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":360,"wires":[["b0d1a6e8.26d948"]]},{"id":"3f8ba80f.fad938","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 11","func":"if (typeof msg.payload !== 'number') \n{\n    msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n    msg.payload = 0;\n}\n\nmsg.bit = 10;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":300,"wires":[["b0d1a6e8.26d948"]]},{"id":"<wbr style="font-family: tahoma, sans-serif; font-s

Marcus Jelsch

unread,
Apr 2, 2017, 4:57:08 AM4/2/17
to node...@googlegroups.com
Hi,

What do u mean with join side?

I posted the whole working code.

Marcus

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/N4uQ8eStTvE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Kemp Maritz

unread,
Apr 2, 2017, 12:48:40 PM4/2/17
to Node-RED
I think your last post got truncated. The flow you posted will not import correctly.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.

Rob Conway

unread,
Apr 3, 2017, 7:16:45 AM4/3/17
to Node-RED
Reply all
Reply to author
Forward
0 new messages