Data messed up after restart RPi

Hi, after a restart my course is confused:

Can I force the sequence somehow?

blue should always be "RLT", green always "AT" and black always "Hz".

:face_with_monocle:

thanks

Oooh, that is tricky.

I too have charts and want data to be certain colours.

Alas I don't know of a simple solution, but:

Options:
1 - Use a join node to make a message after 4 messages have been received. Not exactly a solution, but something that may be handy to use later.
2 - Have an inject node that is set to inject at start and use delay nodes to create a message in the order you want.

If you need to fix the order you need to send a null value to each topic at deploy time in the order you want before any live data arrives. That will preset them

This is a quick one I whipped up.

Tweak the delay values as needed so they work correctly.

[{"id":"f7906acf.3ec518","type":"inject","z":"b9924a74.4d98f8","name":"On boot","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":4700,"wires":[["b1ceefb9.070448","faf82b6a.d62d7"]]},{"id":"b1ceefb9.070448","type":"delay","z":"b9924a74.4d98f8","name":"delay","pauseType":"delay","timeout":"5","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":240,"y":4700,"wires":[["8fbadc9b.777c9","72594ad7.f113a4"]]},{"id":"faf82b6a.d62d7","type":"change","z":"b9924a74.4d98f8","name":"RLT","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":240,"y":4740,"wires":[["2c925459.e1ba8c"]]},{"id":"8fbadc9b.777c9","type":"delay","z":"b9924a74.4d98f8","name":"delay","pauseType":"delay","timeout":"5","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":380,"y":4700,"wires":[["b12b067d.1a6038"]]},{"id":"72594ad7.f113a4","type":"change","z":"b9924a74.4d98f8","name":"AT","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":4740,"wires":[["2c925459.e1ba8c"]]},{"id":"b12b067d.1a6038","type":"change","z":"b9924a74.4d98f8","name":"HZ","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":4740,"wires":[["2c925459.e1ba8c"]]},{"id":"2c925459.e1ba8c","type":"join","z":"b9924a74.4d98f8","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":510,"y":4790,"wires":[["74da10f1.36fbe8"]]},{"id":"74da10f1.36fbe8","type":"debug","z":"b9924a74.4d98f8","name":"To Chart","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":670,"y":4790,"wires":[]}]

That's a nudge in the right direction but I set the initial values to 0. Probably better to do as @dceejay says. Just edit the change nodes.

You don’t need any delays, just make sure they are in the order you want

Sorry, I'm just OCD on that to make 1,000,000 % sure. :wink:
How would I make the 3 message then without a delay node?

Oh, as in make an array and spit it out. Ok. Yeah, probably better, but I can't remember how to make an array just now.

This is the other way @dceejay was indicating - I think.

But it sends the messages and sets their order.

[{"id":"93bc2016.84d5f8","type":"function","z":"b9924a74.4d98f8","name":"","func":"msg1 = ({\"topic\":\"RLT\",\"payload\":null});\nmsg2 = ({\"topic\":\"AT\",\"payload\":null});\nmsg3 = ({\"topic\":\"HZ\",\"payload\":null});\n\nnode.send(msg1);\nnode.send(msg2);\nnode.send(msg3);\n\nreturn;","outputs":1,"noerr":0,"x":230,"y":4870,"wires":[["2124fb20.74bf5c"]]},{"id":"8d552747.9e95b","type":"inject","z":"b9924a74.4d98f8","name":"On Boot","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":4870,"wires":[["93bc2016.84d5f8"]]},{"id":"2124fb20.74bf5c","type":"debug","z":"b9924a74.4d98f8","name":"To chart node","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":390,"y":4870,"wires":[]}]

You can make that a little more tidy using

msg1 = ({"topic":"RLT","payload":null});
msg2 = ({"topic":"AT","payload":null});
msg3 = ({"topic":"HZ","payload":null});

return [[msg1, msg2, msg3]];

Note the double brackets, otherwise is will send the messages separately to three outputs, rather than sequentially to one output.

2 Likes

Thanks Colin. I’m stuck typing on phone one handed at the mo

Also just noticed the lines

msg1 = ({"topic":"RLT","payload":null});

don't need the parentheses

msg1 = {"topic":"RLT","payload":null}

order is correct, but the course stays empty - no data arrive :frowning:

This is just to preset the order. You then need to send your data as you did before.

i did nothing to send before.
maybe you can help me with pictures:

3 4 5

debug says: "null"
7

null is german for zero !?!

You should have left your original function as it was and added the new one along side it, driven by an inject node configured to inject once on startup. The new function node primes the chart then your data comes in through the old one as before.

Edit - just to clarify, both function nodes feed direct into the chart, not one into the other.

Ok, but I don´t know how to inject once after restart :face_with_monocle:

Take a look at the options of the inject node

image

this is inject:

but what should I choose ?

it doesn't matter - (eg timestamp is ok) - as your function node then replaces the msg with it's own 4 new messages. As long as you tick the box I showed (which is hidden behind that dropdown)

(If you wanted to be super compact you could select {} JSON and then create the complete message in there instead of the function node - but I wouldn't bother for now if the function node works)

1 Like

I think it works now.
grafik
just restartet once

1 Like