node-red / node-red

Low-code programming for event-driven applications
http://nodered.org
Apache License 2.0
19.76k stars 3.41k forks source link

Dynamyc MQTT subscription not returning JSON object #3215

Closed juanbaldovi closed 3 years ago

juanbaldovi commented 3 years ago

Current Behavior

MQTT IN node is returning string while configured for returning parsed JSON object. This is only happening using the new functionality of Dynamic subscription. Same node configured for single topic returns a json object for the same topic subscription

Attached there's a demonstration flow.

image

Expected Behavior

Send output as json

Steps To Reproduce

No response

Example flow

[{"id":"19980b40dbba5f60","type":"tab","label":"Flow 3","disabled":false,"info":"","env":[]},{"id":"9c2d482981552296","type":"inject","z":"19980b40dbba5f60","name":"json","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"Time\":\"2021-10-22T21:59:27\",\"Uptime\":\"22T03:28:49\",\"UptimeSec\":1913329,\"Heap\":26,\"SleepMode\":\"Dynamic\",\"Sleep\":50,\"LoadAvg\":19,\"MqttCount\":836,\"POWER1\":\"OFF\",\"POWER2\":\"OFF\",\"Wifi\":{\"AP\":1,\"SSId\":\"AL_IOT\",\"BSSId\":\"EC:08:6B:61:2D:92\",\"Channel\":5,\"RSSI\":88,\"Signal\":-56,\"LinkCount\":10,\"Downtime\":\"0T00:03:10\"}}","payloadType":"json","x":240,"y":180,"wires":[["bce0843ba8fe3ab7"]]},{"id":"bce0843ba8fe3ab7","type":"mqtt out","z":"19980b40dbba5f60","name":"test/mqtt","topic":"test/mqtt","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"a1214186.1acad","x":355,"y":180,"wires":[],"l":false},{"id":"e781f12745609710","type":"mqtt in","z":"19980b40dbba5f60","name":"single topic ","topic":"test/mqtt","qos":"2","datatype":"json","broker":"a1214186.1acad","nl":false,"rap":true,"rh":0,"inputs":0,"x":220,"y":240,"wires":[["c32fcdc06e609ae2"]]},{"id":"c32fcdc06e609ae2","type":"debug","z":"19980b40dbba5f60","name":"single topic","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":335,"y":240,"wires":[],"l":false},{"id":"de27b93e52196937","type":"inject","z":"19980b40dbba5f60","name":"subscription","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"action","v":"subscribe","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"test/mqtt","payloadType":"date","x":250,"y":120,"wires":[["ba19c00ea3a72413"]]},{"id":"ba19c00ea3a72413","type":"mqtt in","z":"19980b40dbba5f60","name":"dynamyc","topic":"","qos":"2","datatype":"json","broker":"a1214186.1acad","nl":false,"rap":true,"rh":0,"inputs":1,"x":385,"y":120,"wires":[["90b0c92a3cf92465"]],"l":false},{"id":"90b0c92a3cf92465","type":"debug","z":"19980b40dbba5f60","name":"dynamyc","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":445,"y":120,"wires":[],"l":false},{"id":"a1214186.1acad","type":"mqtt-broker","name":"domoserver","broker":"192.168.2.46","port":"1883","clientid":"nodeRed","autoConnect":true,"usetls":false,"compatmode":false,"protocolVersion":4,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

Environment

Steve-Mcl commented 3 years ago

I believe I know what's going on here. In the beta versions before release, the selection for return type was hidden because you can specify the return type per subscription.

I can't remember the property name at this moment, I'll update this message shortly with info.

@knolleary I believe the return type should either be hidden or should include an additional entry "Set by msg"

Steve-Mcl commented 3 years ago

@juanbaldovi

Below is a demo flow I was using during development. Look at the inject 1 and inject 2 for using auto/json return types.

[{"id":"a44858cb4f9a7624","type":"inject","z":"b872cb4b.5a6448","name":"sub [{test/test3},{test/test4},\"test/test5\"]","props":[{"p":"action","v":"subscribe","vt":"str"},{"p":"topic","v":"[{\"topic\":\"test/test3\",\"datatype\":\"json\",\"qos\":0},{\"topic\":\"test/test4\",\"datatype\":\"utf8\",\"qos\":1},\"test/test5\"]","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":410,"y":680,"wires":[["22bc0452e33ae532"]]},{"id":"c93e455cf8a3300c","type":"inject","z":"b872cb4b.5a6448","name":"test/test1 (datatype auto)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"test/test1","payload":"{\"key\":\"payload should be a string because subscription datatype was 'auto'\"}","payloadType":"json","x":1330,"y":780,"wires":[["0cd070c3e7d76af3"]]},{"id":"6278eb39fc0977f9","type":"inject","z":"b872cb4b.5a6448","name":"test/test2 (datatype json)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"test/test2","payload":"{\"key\":\"payload should be an object because subscription datatype was 'json'\"}","payloadType":"json","x":1330,"y":820,"wires":[["0cd070c3e7d76af3"]]},{"id":"0cd070c3e7d76af3","type":"mqtt out","z":"b872cb4b.5a6448","name":"","topic":"","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"d98ab0d0f2c84665","x":1670,"y":740,"wires":[]},{"id":"dcfbaf334cc4c95a","type":"inject","z":"b872cb4b.5a6448","name":"sub single string \"test/test1\"","props":[{"p":"action","v":"subscribe","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"test/test1","x":380,"y":600,"wires":[["22bc0452e33ae532"]]},{"id":"06e4355aa8357e68","type":"inject","z":"b872cb4b.5a6448","name":"sub single object {test/test2}","props":[{"p":"action","v":"subscribe","vt":"str"},{"p":"topic","v":"{\"topic\":\"test/test2\",\"datatype\":\"json\",\"qos\":0}","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":380,"y":640,"wires":[["22bc0452e33ae532"]]},{"id":"12aa7c7be8d1b18f","type":"inject","z":"b872cb4b.5a6448","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"test/test3","payload":"{\"key\": \"value\"}","payloadType":"json","x":1330,"y":860,"wires":[["0cd070c3e7d76af3"]]},{"id":"bac9e9ae6b9da2c5","type":"inject","z":"b872cb4b.5a6448","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"test/test4","payload":"{\"key\": \"value\"}","payloadType":"json","x":1330,"y":900,"wires":[["0cd070c3e7d76af3"]]},{"id":"df8dd5cba1197ac1","type":"inject","z":"b872cb4b.5a6448","name":"test/test5 (with v5 props)","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"userProperties","v":"{\"fred\":\"123\"}","vt":"json"},{"p":"responseTopic","v":"test/reply","vt":"str"},{"p":"contentType","v":"JSON","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"test/test5","payload":"{\"key\": \"value\"}","payloadType":"json","x":1330,"y":940,"wires":[["0cd070c3e7d76af3"]]},{"id":"f4afec0a0c146668","type":"comment","z":"b872cb4b.5a6448","name":"publish to regular mqtt out","info":"","x":1310,"y":740,"wires":[]},{"id":"aa82e9cf3227066c","type":"comment","z":"b872cb4b.5a6448","name":"Subscribe topics","info":"","x":320,"y":560,"wires":[]},{"id":"c8afed87a5818c8f","type":"comment","z":"b872cb4b.5a6448","name":"connect / disconnect / other","info":"","x":360,"y":300,"wires":[]},{"id":"86d14a88aea7f2af","type":"inject","z":"b872cb4b.5a6448","name":"unsub single test/test1","props":[{"p":"action","v":"unsubscribe","vt":"str"},{"p":"topic","v":"{\"topic\":\"test/test1\"}","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":360,"y":780,"wires":[["22bc0452e33ae532"]]},{"id":"439475bbd6137052","type":"inject","z":"b872cb4b.5a6448","name":"unsub all","props":[{"p":"action","v":"unsubscribe","vt":"str"},{"p":"topic","v":"true","vt":"bool"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":320,"y":820,"wires":[["22bc0452e33ae532"]]},{"id":"085faf61cce5c2ea","type":"comment","z":"b872cb4b.5a6448","name":"Unsubscribe topics","info":"","x":330,"y":740,"wires":[]},{"id":"22bc0452e33ae532","type":"mqtt in","z":"b872cb4b.5a6448","name":"Dynamic 1","topic":"","qos":"2","datatype":"auto","broker":"d98ab0d0f2c84665","nl":false,"rap":true,"rh":0,"inputs":1,"x":690,"y":600,"wires":[["16a5af7930d4bf85"]]},{"id":"70df6aaf14055b65","type":"complete","z":"b872cb4b.5a6448","name":"","scope":["5650e9b7e6f87d25"],"uncaught":false,"x":690,"y":1080,"wires":[["73f39c48f18cf5ea"]]},{"id":"73f39c48f18cf5ea","type":"debug","z":"b872cb4b.5a6448","name":"Complete messages from dyn 2","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"msg","x":930,"y":1080,"wires":[]},{"id":"a4ad40ea1646c2a2","type":"inject","z":"b872cb4b.5a6448","name":"sub single string \"test/test1\"","props":[{"p":"action","v":"subscribe","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"test/test1","x":380,"y":960,"wires":[["5650e9b7e6f87d25"]]},{"id":"30fac3fb64e22589","type":"inject","z":"b872cb4b.5a6448","name":"sub single object {test/test2}","props":[{"p":"action","v":"subscribe","vt":"str"},{"p":"topic","v":"{\"topic\":\"test/test2\",\"datatype\":\"json\",\"qos\":0}","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":380,"y":1000,"wires":[["5650e9b7e6f87d25"]]},{"id":"91d592021302d915","type":"comment","z":"b872cb4b.5a6448","name":"Subscribe topics","info":"","x":320,"y":920,"wires":[]},{"id":"084f2b137449dbdf","type":"debug","z":"b872cb4b.5a6448","name":"MQTT messages dyn 2","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"topic & \" : \" & payload","statusType":"jsonata","x":950,"y":1000,"wires":[]},{"id":"93ead290d3373322","type":"comment","z":"b872cb4b.5a6448","name":"Unsubscribe topics","info":"","x":330,"y":1060,"wires":[]},{"id":"5650e9b7e6f87d25","type":"mqtt in","z":"b872cb4b.5a6448","name":"Dynamic 2","topic":"","qos":"2","datatype":"auto","broker":"d98ab0d0f2c84665","nl":false,"rap":true,"rh":0,"inputs":1,"x":690,"y":1000,"wires":[["4bf75fc081d8c2ee"]]},{"id":"f59d806b296935e2","type":"inject","z":"b872cb4b.5a6448","name":"get subscriptions","props":[{"p":"action","v":"getSubscriptions","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":340,"y":1180,"wires":[["5650e9b7e6f87d25"]]},{"id":"aa6213febbe0bde0","type":"inject","z":"b872cb4b.5a6448","name":"get subscriptions","props":[{"p":"action","v":"getSubscriptions","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":340,"y":500,"wires":[["22bc0452e33ae532"]]},{"id":"7812e66c6e25e290","type":"complete","z":"b872cb4b.5a6448","name":"","scope":["22bc0452e33ae532"],"uncaught":false,"x":690,"y":720,"wires":[["a5ad4471bc9a9c1f"]]},{"id":"a5ad4471bc9a9c1f","type":"debug","z":"b872cb4b.5a6448","name":"Complete messages from dyn 1","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"msg","x":930,"y":720,"wires":[]},{"id":"00f833d0690a3a25","type":"inject","z":"b872cb4b.5a6448","name":"connect","props":[{"p":"action","v":"connect","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":1270,"y":540,"wires":[["0cd070c3e7d76af3"]]},{"id":"2c98ce849c275c3b","type":"inject","z":"b872cb4b.5a6448","name":"disconnect","props":[{"p":"action","v":"disconnect","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":1280,"y":500,"wires":[["0cd070c3e7d76af3"]]},{"id":"482f5c6d02e57597","type":"inject","z":"b872cb4b.5a6448","name":"connect with opts V1","props":[{"p":"broker","v":"{\"url\":\"mqtt://broker.hivemq.com:1883\",\"protocolVersion\":3,\"birth\":{\"topic\":\"test/lwt/birth-V1\",\"qos\":0,\"retain\":false,\"payload\":\"birth-V1\",\"properties\":{\"correlationData\":\"hello birth-V1\",\"userProperties\":{\"prop1\":\"birth-V1\"},\"contentType\":\"application/text\"}},\"close\":{\"topic\":\"test/lwt/close-V1\",\"qos\":0,\"retain\":false,\"payload\":\"close-V1\",\"properties\":{\"correlationData\":\"hello close-V1\",\"userProperties\":{\"prop1\":\"close-V1\"},\"contentType\":\"application/text\"}},\"will\":{\"topic\":\"test/lwt/will-V1\",\"qos\":0,\"retain\":false,\"payload\":\"will-V1\",\"properties\":{\"correlationData\":\"hello will-V1\",\"userProperties\":{\"prop1\":\"will-V1\"},\"contentType\":\"application/text\"}}}","vt":"json"},{"p":"action","v":"connect","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":1310,"y":580,"wires":[["0cd070c3e7d76af3"]]},{"id":"9942e57661119659","type":"inject","z":"b872cb4b.5a6448","name":"connect with opts V2","props":[{"p":"broker","v":"{\"broker\":\"broker.emqx.io\",\"port\":1883,\"cleansession\":false,\"clientid\":\"smacsmac_test_test_gotta_unique\",\"protocolVersion\":5,\"birth\":{\"topic\":\"test/lwt/birth-V2\",\"qos\":0,\"retain\":false,\"payload\":\"birth-V2\",\"properties\":{\"correlationData\":\"hello birth-V2\",\"userProperties\":{\"prop1\":\"birth-V2\"},\"contentType\":\"application/text\"}},\"close\":{\"topic\":\"test/lwt/close-V2\",\"qos\":0,\"retain\":false,\"payload\":\"close-V2\",\"properties\":{\"correlationData\":\"hello close-V2\",\"userProperties\":{\"prop1\":\"close-V2\"},\"contentType\":\"application/text\"}},\"will\":{\"topic\":\"test/lwt/will-V2\",\"qos\":0,\"retain\":false,\"payload\":\"will-V2\",\"properties\":{\"correlationData\":\"hello will-V2\",\"userProperties\":{\"prop1\":\"will-V2\"},\"contentType\":\"application/text\"}}}","vt":"json"},{"p":"action","v":"connect","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":1310,"y":620,"wires":[["0cd070c3e7d76af3"]]},{"id":"6ebd8e1a153e3398","type":"complete","z":"b872cb4b.5a6448","name":"","scope":["0cd070c3e7d76af3"],"uncaught":false,"x":1670,"y":840,"wires":[["68c12d86d6a7682e"]]},{"id":"afa8ca7ce723c740","type":"debug","z":"b872cb4b.5a6448","name":"Complete messages mqtt-out","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"msg","x":1760,"y":920,"wires":[]},{"id":"2fa51c0994dfdf8f","type":"comment","z":"b872cb4b.5a6448","name":"Testing connect / disconnect actions with an mqtt-out","info":"","x":1390,"y":460,"wires":[]},{"id":"68c12d86d6a7682e","type":"switch","z":"b872cb4b.5a6448","name":"has msg.action","property":"action","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":1700,"y":880,"wires":[["afa8ca7ce723c740"]]},{"id":"42c8756ff2db3b9b","type":"inject","z":"b872cb4b.5a6448","name":"unsub all","props":[{"p":"action","v":"unsubscribe","vt":"str"},{"p":"topic","v":"true","vt":"bool"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":320,"y":1100,"wires":[["5650e9b7e6f87d25"]]},{"id":"fdca8a97b79e0a8c","type":"debug","z":"b872cb4b.5a6448","name":"action response","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":980,"y":540,"wires":[]},{"id":"16a5af7930d4bf85","type":"switch","z":"b872cb4b.5a6448","name":"has msg.action","property":"action","propertyType":"msg","rules":[{"t":"eq","v":"getSubscriptions","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":740,"y":540,"wires":[["fdca8a97b79e0a8c"],["49664da44719d200"]]},{"id":"49664da44719d200","type":"debug","z":"b872cb4b.5a6448","name":"MQTT messages dyn 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":950,"y":600,"wires":[]},{"id":"4bf75fc081d8c2ee","type":"switch","z":"b872cb4b.5a6448","name":"has msg.action","property":"action","propertyType":"msg","rules":[{"t":"eq","v":"getSubscriptions","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":740,"y":940,"wires":[["218ba9660b257012"],["084f2b137449dbdf"]]},{"id":"218ba9660b257012","type":"debug","z":"b872cb4b.5a6448","name":"action response","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":980,"y":940,"wires":[]},{"id":"b02e334881c59f79","type":"mqtt in","z":"b872cb4b.5a6448","name":"birth/close/will V1 (broker.hivemq.com)","topic":"test/lwt/#","qos":"2","datatype":"auto","broker":"a56f8945.7b8388","nl":false,"rap":true,"rh":0,"inputs":0,"x":810,"y":340,"wires":[["a5477ecc1a6304a4"]]},{"id":"4ac0a5f5d913477d","type":"mqtt in","z":"b872cb4b.5a6448","name":"birth/close/will V2 (broker.emqx.io)","topic":"test/lwt/#","qos":"2","datatype":"auto","broker":"dc811dae.05f5","nl":false,"rap":true,"rh":0,"inputs":0,"x":800,"y":400,"wires":[["da1e21e4b879b8b7"]]},{"id":"da1e21e4b879b8b7","type":"debug","z":"b872cb4b.5a6448","name":"Check LWT V2","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"topic","statusType":"msg","x":1080,"y":400,"wires":[]},{"id":"a5477ecc1a6304a4","type":"debug","z":"b872cb4b.5a6448","name":"Check LWT V1","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"topic","statusType":"msg","x":1080,"y":340,"wires":[]},{"id":"3ed3df35b7583457","type":"comment","z":"b872cb4b.5a6448","name":"separate connections to V1 and V2 to monitor LWT","info":"","x":850,"y":300,"wires":[]},{"id":"34872679cc42ebe7","type":"inject","z":"b872cb4b.5a6448","name":"disconnect","props":[{"p":"action","v":"disconnect","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":320,"y":340,"wires":[["22bc0452e33ae532"]]},{"id":"100c8d90dc58a5e8","type":"inject","z":"b872cb4b.5a6448","name":"connect","props":[{"p":"action","v":"connect","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":310,"y":380,"wires":[["22bc0452e33ae532"]]},{"id":"943b22d0c93ba287","type":"inject","z":"b872cb4b.5a6448","name":"connect with opts V1","props":[{"p":"broker","v":"{\"url\":\"mqtt://broker.hivemq.com:1883\",\"protocolVersion\":3,\"birth\":{\"topic\":\"test/lwt/birth-V1\",\"qos\":0,\"retain\":false,\"payload\":\"birth-V1\",\"properties\":{\"correlationData\":\"hello birth-V1\",\"userProperties\":{\"prop1\":\"birth-V1\"},\"contentType\":\"application/text\"}},\"close\":{\"topic\":\"test/lwt/close-V1\",\"qos\":0,\"retain\":false,\"payload\":\"close-V1\",\"properties\":{\"correlationData\":\"hello close-V1\",\"userProperties\":{\"prop1\":\"close-V1\"},\"contentType\":\"application/text\"}},\"will\":{\"topic\":\"test/lwt/will-V1\",\"qos\":0,\"retain\":false,\"payload\":\"will-V1\",\"properties\":{\"correlationData\":\"hello will-V1\",\"userProperties\":{\"prop1\":\"will-V1\"},\"contentType\":\"application/text\"}}}","vt":"json"},{"p":"action","v":"connect","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":350,"y":420,"wires":[["22bc0452e33ae532"]]},{"id":"85061c93d2966f6a","type":"inject","z":"b872cb4b.5a6448","name":"connect with opts V2","props":[{"p":"broker","v":"{\"broker\":\"broker.emqx.io\",\"port\":1883,\"cleansession\":false,\"clientid\":\"smacsmac_test_test_gotta_unique\",\"protocolVersion\":5,\"birth\":{\"topic\":\"test/lwt/birth-V2\",\"qos\":0,\"retain\":false,\"payload\":\"birth-V2\",\"properties\":{\"correlationData\":\"hello birth-V2\",\"userProperties\":{\"prop1\":\"birth-V2\"},\"contentType\":\"application/text\"}},\"close\":{\"topic\":\"test/lwt/close-V2\",\"qos\":0,\"retain\":false,\"payload\":\"close-V2\",\"properties\":{\"correlationData\":\"hello close-V2\",\"userProperties\":{\"prop1\":\"close-V2\"},\"contentType\":\"application/text\"}},\"will\":{\"topic\":\"test/lwt/will-V2\",\"qos\":0,\"retain\":false,\"payload\":\"will-V2\",\"properties\":{\"correlationData\":\"hello will-V2\",\"userProperties\":{\"prop1\":\"will-V2\"},\"contentType\":\"application/text\"}}}","vt":"json"},{"p":"action","v":"connect","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":350,"y":460,"wires":[["22bc0452e33ae532"]]},{"id":"d98ab0d0f2c84665","type":"mqtt-broker","name":"broker_to_test_mqtt_control","broker":"localhost","port":"1883","clientid":"","autoConnect":false,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":"","credentials":{}},{"id":"a56f8945.7b8388","type":"mqtt-broker","name":"broker.hivemq.com","broker":"broker.hivemq.com","port":"1883","clientid":"","autoConnect":true,"usetls":false,"compatmode":false,"protocolVersion":"4","keepalive":"45","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""},{"id":"dc811dae.05f5","type":"mqtt-broker","name":"","broker":"broker.emqx.io","port":"1883","clientid":"","autoConnect":true,"usetls":false,"compatmode":false,"protocolVersion":"5","keepalive":"50","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]

image

knolleary commented 3 years ago

I felt it was more useful on balance to be able to set the return type at the top level - a default behaviour to apply to all subs.

But I forgot to follow through whilst sorting everything else out.

I don't recall seeing what msg property would be used to specify the return type... but it wasn't something I went looking for.

I suggest:

I don't think it's necessary to have a "set by msg" option - I think it's far more useful to be able to set the default that can be overridden per subscription if it's really needed. And a user isn't likely to accidentally override it, so the usual concerns about msg overriding node don't apply in the usual way.

Steve-Mcl commented 3 years ago

Seems like a sensible approach Nick. 👍