(Though its better than going around squares - bad attempt at a pun. around......)
I've had fun learning more about JS, but I am not sure that has helped me.
Problem:
I am receiving a message from 3 different machines.
Message: (eg)
{"_msgid":"849fba65.79ecd8","topic":"","payload":{"Who":"TelePi","Modem":"Online","Uplink":"Online"}}
{"_msgid":"849fba65.79ecd8","topic":"","payload":{"Who":"TimePi","Modem":"Online","Uplink":"Online"}}
{"_msgid":"849fba65.79ecd8","topic":"","payload":{"Who":"BedPi","Modem":"Online","Uplink":"Online"}}
I want to feed that (those three messages) into something and get two outputs.
The Modem
and Uplink
can be Online
, Offline
or Unknown
The Unknown
is if all 3 devices report back the Modem
is Offline
, and only for the Uplink
output.
Each device's message will have a colour
..... field (?) to show who is sending the message.
If more than 1 device show the Modem
as Online
, a specific device's message is sent.
Similar with the Uplink
.
I am sure I will nut it out, as I often do, but would like a bit of help in case I get dizzy going around the circle.
Please clarify 'two outputs', 2 debug messages or 2 output-ports on the node (ie function node).
What should the output look like ? Per device, or do you just want an overal status of:
{modem:online/offline}
and {uplink:online/offline/unknown}
The unknown state will be a hassle to deal with as you won't know if 1 device won't send anything at all (ie if it is dead), so waiting for 3 messages won't work. Neither would keeping track of it with a counter for the same reason (plus when deploying you could mess up the counter).
I am not sure what you are trying to accomplish, but it sounds overly complicated.
Hi Bakman2.
That post was bashed out in a hurry, I know.
I am/was wanting a way of getting the messages from 3 devices - all scanning 2 IP addresses and sending messages back - and displaying the result with 2 indicators on the dashboard.
I believe I have got it resolved. Yesterday I was up at 06:15 local and though not the only thing I did all day I went to bed at 01:40 today.
Basically from about 19:00 to 01:45 I was working on the problem.
Thus all my questions about JSON
and messages.
It took 2 function nodes and context to do it. With a few other nodes to format the messages.
There was also the priority of messages. If 2 devices sent back the same message: who's would be shown?
Fun fun fun.
And with the arrival being a bit asynchronous, it made it just that little bit harder.
It seems to be working now, and I need to now give it a full test to see if things work correctly REALLY.
I made a mock of the flow on this machine - as deploys are seconds - but something went very wrong when I put it on the real machines - where deploy can take a minute or so.
If you want I could upload the dummy flow, but I don't know it would be of much use to anyone but for the sake of seeing what I was talking about.