Sending MQTT username/password in flow JSON

870 views
Skip to first unread message

Adam Schaible

unread,
Oct 25, 2017, 3:12:36 PM10/25/17
to Node-RED
Hi Guys,

Is there any way to store MQTT username/password in flow JSON?  I don't want to read the password from the flow, just send in a flow with a username/password set.

Thanks!

Nick O'Leary

unread,
Oct 25, 2017, 3:17:09 PM10/25/17
to Node-RED Mailing List
Hi Adam,

can you clarify what you mean by 'send in a flow with a u/p set'?

Nick

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/a1182adc-3204-456d-be1f-645cc7b76167%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Adam Schaible

unread,
Oct 25, 2017, 3:50:50 PM10/25/17
to Node-RED
Yes, and thank you for the quick response.

From what I understand, Node-RED flows can be stored in JSON.  When I export a flow, it seems to strip the username/password properties from my MQTT definition.  I'm just wondering how to add those to the JSON so that when I import the flow, those values can be preconfigured.

Nick O'Leary

unread,
Oct 25, 2017, 4:15:30 PM10/25/17
to Node-RED Mailing List
Hi Adam,

yes, it is possible to import a flow that includes credentials. The trick is to add a 'credentials' object to the node config that includes the credential properties.

The only tricky part is knowing what the credential property names are. Now that we encrypt credentials by default, you can't easily refer to what you have in your existing creds file.


So... you'd do something like:

[
    {
        "id": "77c4f259.737e5c",
        "type": "mqtt-broker",
        "z": "",
        "broker": "localhost",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "compatmode": true,
        "keepalive": "60",
        "cleansession": true,
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "credentials": {
            "user": "my-username",
            "password": "my-password"
        }
    }
]



On 25 October 2017 at 19:50, Adam Schaible <adam.s...@gmail.com> wrote:
Yes, and thank you for the quick response.

From what I understand, Node-RED flows can be stored in JSON.  When I export a flow, it seems to strip the username/password properties from my MQTT definition.  I'm just wondering how to add those to the JSON so that when I import the flow, those values can be preconfigured.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Adam Schaible

unread,
Oct 26, 2017, 7:33:21 AM10/26/17
to Node-RED
Thanks, this is exactly what I was looking for.

Eelco Folkertsma

unread,
Oct 30, 2017, 12:29:17 PM10/30/17
to Node-RED
Hi Nick,
can you expand your example to show how a (self signed) CA for broker can be embedded in flow?  Or alternatively, how I can construct a flow-object including credentials from a flows_host.json and a flows_host_cred.json.

Thanks, Eelco
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
Reply all
Reply to author
Forward
0 new messages