I'm communicating NR with an ESP8266 with MQTT.
In dashboard, using a switch it works perfect. The switch output contains "on" or "off" and it works perfect.
I would like to use an MQTT output, with the output of a function. The function turns on or off a water valve depending on a time shedule.
¿Wich format needs the function output to "match" with the MQTT out?
PD- I have searched in the forum, but I hav'nt find it.
I'm doing something similar, using @knolleary's "PubSubClient" library, but I would expect other libs to work in a similar way. As an example of how to do it, here's my setup for an MQTT out node which sends a regular "tick" to any ESP8266 devices which need to keep an accurate time.
The message is generated by a simple Inject node sending a timestamp every 15 minutes, but as mentioned already, whatever you pass in as the message payload will be sent.
The code in the ESP8266 simply subscribes to "sys/tick" to receive the messages.