I have constructed a flow which ends up turning a json string into an object with variables as follows:
DeviceId: "a name and number"
Site: "a city name"
UTC: "2019-07-10 07:54:49"
I am trying to use these variables (DeviceId, Site, UTC and State) and merge them into a string like "some text+DeviceId+some more text+Site" and so on. I have tried several ways of referencing the variables, but to no avail. Which is the correct way, if it is not one of the following?
msg.payload.0.DeviceId (the error here is that the function node I am using does not like the 0)
msg.payload.DeviceId (no output)
msg.payload (no output)
msg.payload[0[DeviceId]] (no output)
I am one semicolon from pulling my hair out.
Excellent, thanks. I had forgotten about that. The strange thing is, though, that even when I copy the path to DeviceId, which is allegedly "payload.DeviceId", I get nothing. Or actually, I get the error that this is not defined. I then put "msg." in front of it, but then there is just no trace of this in the debug node.
Anyways, is there an easier way of getting around this? I am currently using the json node to convert json data into an object, but what I really want is to get the information converted to variables with names and values. If this is in an array and/or an object is not important, though it seems to be my main problem right now.
Oh, just shoot me already.
In order to find out why this was not working, I was defining the variables separately instead of just putting them inside the string I need to send. What I thought was that the debug node would display the variables being defined in the node, but of course it isn't - at least unless they are part of the msg. So if I use
msg.DeviceId = msg.payload.DeviceId
it works - AND the variable is shown in the debug pane.
Thanks for trying to help me out, though I was just being a moron all along.
I have been trying to follow thw 'working with messages' documentation as mentioned repeatedly in this thread, and failing miserably. when I copy the path to the 'temp' it gives me 'payload.observations.uk_hybrid.temp', but when i run the function it gives the 'cannot read property 'uk_hybrid' of undefined.
please can someone tell me the correct path for this ?