ndarkness
ndarkness

Reputation: 1089

Credentials for mosquitto broker in Node-red?

I would be interested on using node-red output function to publish kind of payload.

I know that the command using mosquitto publisher the call would be like this

mosquitto_pub -h staging.thethingsnetwork.org -t '0807060504030201/devices/0102030405060708/down' -u 0807060504030201 -P 'I0f+e1W+CWgIiuIC4SjR5cpLxFZQfK2agDEpuCBpttI=' -m '{ "payload":"SGVsbG8gd29ybGQK","port":1,"ttl":"1h"}'

Thus I was wondering how to fill correctly those paremeters on the mosquitto publish function available in node-red, so far I have translated the previous call to the function as

-server: staging.thethingsnetwork.org

-client ID: blank

-username: 0807060504030201 

-password: I0f+e1W+CWgIiuIC4SjR5cpLxFZQfK2agDEpuCBpttI=

The field payload, will be injected from an input inject function where payload is as above and in json format.

Is that valid setup?

Thanks in advance,

REgards

EDIT suggestions of knolleary in images enter image description here

enter image description here

enter image description here

Upvotes: 0

Views: 1592

Answers (1)

knolleary
knolleary

Reputation: 10117

The MQTT nodes in Node-RED do not support passing in the broker details with the message, you must manually configure the MQTT broker node.

  1. Add an MQTT output node and double click to edit it
  2. In the 'Server' config option, click the pencil to add a new mqtt-broker config
  3. In the mqtt-broker config dialog enter the various configuration options you've copied from the mosquitto command

Once that is configured and deployed, messages passed to the MQTT output node will get published to the broker, using the payload and topic properties of the message.

Upvotes: 2

Related Questions