Hi all,
Quite new with Node-Red and programming in general, but have spent now quite some evenings and hours into figuring out some data read-up from my air to water heatpump with great help of other people.
Now I am stuck, since I have no clue how to continue, and would like to ask some help to at least get me going again.
Below is the flow I currently have, at it works, but can be better to get better values out of it.
What happens is the following:
The first MQTT inject (kamstrup) is set to every 1 minute, the second (youless) is set to every 10 seconds. This cannot be changed due to other reasons in other flows.
Both come out as object, with an array of data.
I have them to join, limit the message to 1/min and run a calculation with 1 value from each array.
This works, and I have the data which I am mostly happy with.
Only 1 thing.
The data belongs together in time, and sometimes the kamstrup data (1 per min) is rather old data vs the youless (1 per 10sec), so the number that comes out is in-accurate when these figures are changes.
I have been trying with trigger and delay nodes, but without success. Is it somehow possible to trigger the flow only when the kamstrup comes in, and then use the latest received youless data?
Would appreciate the help!
[{"id":"e6ae10c6.8eb36","type":"mqtt out","z":"86e20de3.66077","name":"COP MQTT","topic":"cop","qos":"","retain":"","broker":"b7ad9d90.0babc","x":530,"y":340,"wires":[]},{"id":"e58011df.8fb57","type":"change","z":"86e20de3.66077","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.copcurrent","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":190,"y":360,"wires":[["e6ae10c6.8eb36","f06035f3.f93bd8"]]},{"id":"3d9d88c0.fa0ca8","type":"function","z":"86e20de3.66077","name":"","func":"msg.payload = Number(parseFloat(msg.payload).toFixed(1))\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":860,"y":280,"wires":[["e58011df.8fb57"]]},{"id":"e83fea40.7dbfe8","type":"change","z":"86e20de3.66077","name":"COP calc.","rules":[{"t":"set","p":"payload","pt":"msg","to":"(payload.kamstrup.powerinstvalue/payload.youless.powers0)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":280,"wires":[["3d9d88c0.fa0ca8"]]},{"id":"e3d060d2.202c8","type":"delay","z":"86e20de3.66077","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":520,"y":280,"wires":[["e83fea40.7dbfe8","2838b39b.d0101c"]]},{"id":"7be34ea6.4f5dd","type":"join","z":"86e20de3.66077","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":470,"y":220,"wires":[["e3d060d2.202c8"]]},{"id":"83c793b3.b2a8f","type":"change","z":"86e20de3.66077","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"youless","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":240,"y":240,"wires":[["7be34ea6.4f5dd"]]},{"id":"cc432643.b339f8","type":"change","z":"86e20de3.66077","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"kamstrup","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":240,"y":180,"wires":[["7be34ea6.4f5dd"]]},{"id":"92476a14.dcdc58","type":"mqtt in","z":"86e20de3.66077","name":"kamstrup","topic":"kamstrup","qos":"2","datatype":"json","broker":"d6503b94.421bc8","x":60,"y":180,"wires":[["cc432643.b339f8","dc896133.74871"]]},{"id":"bb41908f.5b5c1","type":"mqtt in","z":"86e20de3.66077","name":"","topic":"youless","qos":"2","datatype":"json","broker":"d6503b94.421bc8","x":50,"y":240,"wires":[["83c793b3.b2a8f","55db603e.712c3"]]},{"id":"b7ad9d90.0babc","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"d6503b94.421bc8","type":"mqtt-broker","z":"","name":"MQTT","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]