Hi,
@redkooga
As an example find below a small test flow.
- Screenshot_TEMP-HUM_flow.png (12.33 KiB) Viewed 4243 times
Brief description.
Left you find an "inject" node, just to start the flow. You should replace it with your flow.
Next you will find the function node in order to prepare it for Domoticz.
As indicated in the links above the TEMP/HUM sensor requires 3 parameters, as follows:
1. Temperature (degrees centigrade, as a string value)
2. Humidity (percentage 0-100, as a string value)
3. Humidity level as follows:
0=Normal
1=Comfortable
2=Dry
3=Wet
The contents of the function node is as follows:
Code: Select all
//var TEMP = msg.payload.air_temp;
var TEMP = "20";
//var HUM= msg.payload.humidity;
var HUM = "45";
var HUM_STAT=0;
if (HUM < 30) {
HUM_STAT=2;
} else if ((HUM >= 30) & (HUM < 45)) {
HUM_STAT=0;
} else if ((HUM >= 45) & (HUM < 70)) {
HUM_STAT=1;
} else if (HUM >= 70) {
HUM_STAT=3;
}
msg.payload = {"command":"udevice","idx":397,"nvalue":0,"svalue":TEMP + ";" + HUM + ";" + HUM_STAT};
return msg;
My thanks goes also to @EddyG to sort out the values for HUM_STAT.
(There might exist some discussions how the percentages are divided and it will differ a little bit between winter and summer)
If you run this flow, you will see in the "debug" node:
- Screenshot_TEMP-HUM_flow2.png (9.95 KiB) Viewed 4243 times
The "svalue" is a string consisting of three parameters, separated by a semicolon (;).
So take care that the calculated/collected values for temperature and humidity are string values.
The whole string, you should concatenate it with + sign.
I use in this example a temperature of 20 degrees and a humidity of 45%.
You should finally remove these lines and use the lines that I have commented out (//)
Replace also the IDX (397) for your IDX number.
If everything is correct you will find the next result:
- Screenshot_TEMP-HUM_flow3.png (46.84 KiB) Viewed 4243 times
Below you will find the complete flow:
Code: Select all
[{"id":"71372723.d13458","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"b1659882.c25798","type":"inject","z":"71372723.d13458","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":220,"wires":[["1f47577c.90fc49"]]},{"id":"1f47577c.90fc49","type":"function","z":"71372723.d13458","name":"","func":"//var tm = msg.payload.air_temp;\nvar TEMP = \"20\";\n//var hu = msg.payload.humidity;\nvar HUM = \"45\";\nvar HUM_STAT=0;\nif (HUM < 30) {\n HUM_STAT=2;\n} else if ((HUM >= 30) & (HUM < 45)) {\n HUM_STAT=0;\n} else if ((HUM >= 45) & (HUM < 70)) {\n HUM_STAT=1;\n} else if (HUM >= 70) {\n HUM_STAT=3;\n}\nmsg.payload = {\"command\":\"udevice\",\"idx\":397,\"nvalue\":0,\"svalue\":TEMP + \";\" + HUM + \";\" + HUM_STAT};\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":220,"wires":[["bfc7a14b.5a7998","c028db47.8757a"]]},{"id":"bfc7a14b.5a7998","type":"debug","z":"71372723.d13458","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":590,"y":260,"wires":[]},{"id":"c028db47.8757a","type":"mqtt out","z":"71372723.d13458","name":"Domoticz In","topic":"domoticz/in","qos":"2","retain":"false","broker":"f9f13036.e28b58","x":590,"y":180,"wires":[]},{"id":"f9f13036.e28b58","type":"mqtt-broker","z":"","name":"RPI1_ MQTT_Broker","broker":"192.168.10.51","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
Best regards