@Beothuk the Switch node does not do what you think it does.
The Switch node can be used to route a message to different outputs depending on which rules pass in the node. It does not change the message in anyway.
In your example, you have the Change node configured like this:
This will set the property msg.payload
to the value of msg.msg.payload.Z[0].MZ.P
. Note you have an extra msg
in there because you have put msg.
at the start of the field. If you have selected msg.
as the type, you do not include msg.
in the value field.
Here's an example if fixed Change nodes.
[{"id":"9703b666.e35128","type":"inject","z":"b6cfa8c8.cbc768","name":"Status","topic":"","payload":"{\"Z\":[{\"MZ\":{\"P\":0,\"V\": 90,\"M\":0,\"F\": 1}},{\"Z2\":{\"P\":0,\"V\": 51,\"M\":0,\"F\": 1}},{\"Z3\":{\"P\":0,\"V\": 59,\"M\":0,\"F\": 1}},{\"HZ\":{\"P\":0,\"V\": -1,\"M\":0,\"F\": 6}}],\"DSP\":2,\"L\":\"020d\",\"A\":-1,\"HOA\":1,\"LC\":\"PWR\" ,\"MA\":0,\"MS\":\"0000000\",\"MC\":0,\"HP\":0,\"HM\":0 ,\"DLBES\":1,\"DLBSR\":1,\"MN\":\"SC-85/CUXJ\"}","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":300,"wires":[["5e12c61e.e6ed28"]]},{"id":"5e12c61e.e6ed28","type":"json","z":"b6cfa8c8.cbc768","name":"","property":"payload","action":"","pretty":false,"x":330,"y":300,"wires":[["599d42b9.33fcac","7a33fa82.51faf4","faa5e067.6f432","afb6ebfb.47f4b8"]]},{"id":"599d42b9.33fcac","type":"change","z":"b6cfa8c8.cbc768","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.Z[0].MZ.P","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":240,"wires":[["7bd73809.f4ef58"]]},{"id":"7a33fa82.51faf4","type":"change","z":"b6cfa8c8.cbc768","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.Z[0].MZ.V","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":280,"wires":[["aee5c84b.5baf28"]]},{"id":"faa5e067.6f432","type":"change","z":"b6cfa8c8.cbc768","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.Z[0].MZ.M","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":320,"wires":[["a04576eb.4f92b8"]]},{"id":"afb6ebfb.47f4b8","type":"change","z":"b6cfa8c8.cbc768","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.Z[0].MZ.F","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":360,"wires":[["8991c70e.d96bd8"]]},{"id":"7bd73809.f4ef58","type":"debug","z":"b6cfa8c8.cbc768","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":240,"wires":[]},{"id":"aee5c84b.5baf28","type":"debug","z":"b6cfa8c8.cbc768","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":280,"wires":[]},{"id":"a04576eb.4f92b8","type":"debug","z":"b6cfa8c8.cbc768","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":320,"wires":[]},{"id":"8991c70e.d96bd8","type":"debug","z":"b6cfa8c8.cbc768","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":360,"wires":[]}]
As @ukmoose says, you can also do this with a function node configured with 4 outputs:
return [
{ payload: msg.payload.Z[0].MZ.P },
{ payload: msg.payload.Z[0].MZ.V },
{ payload: msg.payload.Z[0].MZ.M },
{ payload: msg.payload.Z[0].MZ.F }
]