Send command to mqtt output after a function node

Hi,

I need to process the msg.consumototal that my function receives.

I read and process the msg.consumototal value and I want to send a different mqtt command depending on the value that msg has.

MQTT commands:
shellies/shellyplug1/relay/0/command/on
shellies/shellyplug1/relay/0/command/off

Thanks

Firstly, you've taken out the bit that will actually send a message on to the next node. return msg

Next, you need to understand that the "commands" you list are MQTT "topics". Node-RED makes using MQTT easy because it mostly follows the same conventions.

So you can set msg.topic = 'shellies/shellyplug1/relay/0/command' and msg.payload = 'on'.

2 Likes

It works!!
Many thanks!!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.