Sending a value to an Event
Posted: 28 Aug 2017, 18:43
Hi all,
I have an ESP8266 node fitted with a DHT11 temperature/humidity sensor that works fine publishing values to Node-Red via MQTT.
What I would like to do is send a value/parameter to an event to get the ESP8266 node to send either temperature or humidity.
I can't seem to get the following code in the "rules" section to decode the value/parameter.
on sendReadings do
if [%eventvalue%] = "TEMP"
Publish /node21/temperature,[dht11#temperature]
else if [%eventvalue%] = "HUMID"
Publish /node21/humidity,[dht11#humidity]
endif
end on
And this is what I have in a Function node that connects to MQTT output node.
msg.topic = "/wemos21/cmd";
msg.payload = "event,sendReadings=TEMP";
return msg;
I have another Function node that sends...
msg.topic = "/wemos21/cmd";
msg.payload = "event,sendReadings=HUMID";
return msg;
If anyone can spot what's wrong with my decoding I would be very grateful.
Kind regards from David.
I have an ESP8266 node fitted with a DHT11 temperature/humidity sensor that works fine publishing values to Node-Red via MQTT.
What I would like to do is send a value/parameter to an event to get the ESP8266 node to send either temperature or humidity.
I can't seem to get the following code in the "rules" section to decode the value/parameter.
on sendReadings do
if [%eventvalue%] = "TEMP"
Publish /node21/temperature,[dht11#temperature]
else if [%eventvalue%] = "HUMID"
Publish /node21/humidity,[dht11#humidity]
endif
end on
And this is what I have in a Function node that connects to MQTT output node.
msg.topic = "/wemos21/cmd";
msg.payload = "event,sendReadings=TEMP";
return msg;
I have another Function node that sends...
msg.topic = "/wemos21/cmd";
msg.payload = "event,sendReadings=HUMID";
return msg;
If anyone can spot what's wrong with my decoding I would be very grateful.
Kind regards from David.