Sensor in combination with timeswitch not working

Hi,

I admit, I'm new...and I hope it's something stupid...but I don't see it...

I'trying to start a pump (or whatever, an output on the Pi) if the temperature sensor is higher than a certain value AND at a certain time (for this the timeswitch)

It seems to work fine with the manual injections of payload value 0 or 1...but not responding to the paylad injection from the timeswitch.
(the bigtimer part is working fine)

As I (as a new user) cannot attach the exported flow as a file , below you can find the text version.

I must be handling it the wrong way...if anybody has any suggestions, they're VERY welcome!

[{"id":"b45877fe.988608","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"98469948.7c1678","type":"rpi-gpio out","z":"b45877fe.988608","name":"Output 11 - Pomp","pin":"11","set":true,"level":"0","freq":"","out":"out","x":810,"y":240,"wires":[]},{"id":"72ff1b77.c68a44","type":"ds18b20","z":"b45877fe.988608","name":"idsensor","sensorid":"28-062017e155c1","timer":"0.1","x":120,"y":540,"wires":[["3edca94b.95ef56","65982f10.395f3"]],"outputLabels":["idsensor"]},{"id":"9a66e16f.df6c5","type":"bigtimer","z":"b45877fe.988608","outtopic":"","outpayload1":"","outpayload2":"","name":"Big Timer","comment":"","lat":0,"lon":0,"starttime":"0","endtime":"0","starttime2":0,"endtime2":0,"startoff":0,"endoff":0,"startoff2":0,"endoff2":0,"offs":0,"outtext1":"","outtext2":"","timeout":1440,"sun":true,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"jan":true,"feb":true,"mar":true,"apr":true,"may":true,"jun":true,"jul":true,"aug":true,"sep":true,"oct":true,"nov":true,"dec":true,"day1":0,"month1":0,"day2":0,"month2":0,"day3":0,"month3":0,"day4":0,"month4":0,"day5":0,"month5":0,"day6":0,"month6":0,"day7":0,"month7":0,"day8":0,"month8":0,"day9":0,"month9":0,"day10":0,"month10":0,"day11":0,"month11":0,"day12":0,"month12":0,"d1":0,"w1":0,"d2":0,"w2":0,"d3":0,"w3":0,"d4":0,"w4":0,"d5":0,"w5":0,"d6":0,"w6":0,"xday1":0,"xmonth1":0,"xday2":0,"xmonth2":0,"xday3":0,"xmonth3":0,"xday4":0,"xmonth4":0,"xday5":0,"xmonth5":0,"xday6":0,"xmonth6":0,"xday7":0,"xmonth7":0,"xday8":0,"xmonth8":0,"xday9":0,"xmonth9":0,"xday10":0,"xmonth10":0,"xday11":0,"xmonth11":0,"xday12":0,"xmonth12":0,"xd1":0,"xw1":0,"xd2":0,"xw2":0,"xd3":0,"xw3":0,"xd4":0,"xw4":0,"xd5":0,"xw5":0,"xd6":0,"xw6":0,"suspend":false,"random":false,"randon1":false,"randoff1":false,"randon2":false,"randoff2":false,"repeat":false,"atstart":false,"odd":false,"even":false,"x":420,"y":120,"wires":[[],["98469948.7c1678"],[]]},{"id":"1bc9b047.0d587","type":"timerswitch","z":"b45877fe.988608","name":"Shedule Test","ontopic":"","offtopic":"","onpayload":"1","offpayload":"0","disabled":false,"schedules":[{"on_h":"13","on_m":"32","on_s":"00","off_h":"13","off_m":"33","off_s":"00","valid":true}],"x":110,"y":300,"wires":[["9dbdbfb3.ebc03"]]},{"id":"3edca94b.95ef56","type":"ui_text","z":"b45877fe.988608","tab":"6f9ef10f.a6c63","name":"Temp","group":"","order":1,"format":"{{msg.payload}}","x":110,"y":600,"wires":[]},{"id":"62b055cb.dcb6cc","type":"inject","z":"b45877fe.988608","name":"Off","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"off","payloadType":"str","x":170,"y":120,"wires":[["9a66e16f.df6c5"]]},{"id":"83de4ddc.9dd7","type":"inject","z":"b45877fe.988608","name":"On","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Pomp On","payload":"on","payloadType":"str","x":170,"y":80,"wires":[["9a66e16f.df6c5"]]},{"id":"cd60387e.d70268","type":"inject","z":"b45877fe.988608","name":"Burst","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Burst 5 min","payload":"timer 5","payloadType":"str","x":170,"y":200,"wires":[["9a66e16f.df6c5"]]},{"id":"32c9b19a.ef5c2e","type":"inject","z":"b45877fe.988608","name":"Auto","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"auto","payloadType":"str","x":170,"y":160,"wires":[["9a66e16f.df6c5"]]},{"id":"bcb7c136.b3bf8","type":"debug","z":"b45877fe.988608","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":490,"y":540,"wires":[]},{"id":"a4d19f8e.a873c","type":"join","z":"b45877fe.988608","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":430,"y":420,"wires":[["1455f5e3.3004fa"]]},{"id":"1455f5e3.3004fa","type":"function","z":"b45877fe.988608","name":"","func":"if (msg.payload.idtimer1 === 1 && msg.payload.sensor > 15) {\n    msg.payload =\"1\";\n}\nelse if (msg.payload.idtimer1 === 0) {\n    msg.payload = \"0\";\n}\nelse  {\n    return null;\n}\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":600,"y":420,"wires":[["98469948.7c1678"]]},{"id":"80e23c34.2f5bd","type":"inject","z":"b45877fe.988608","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"idtimer1","payload":"1","payloadType":"num","x":140,"y":400,"wires":[["a4d19f8e.a873c"]]},{"id":"65982f10.395f3","type":"function","z":"b45877fe.988608","name":"Add topic name","func":"var o = msg.payload\nmsg.payload = o\nmsg.topic = \"sensor\"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":300,"y":540,"wires":[["a4d19f8e.a873c","bcb7c136.b3bf8"]]},{"id":"9dbdbfb3.ebc03","type":"function","z":"b45877fe.988608","name":"Add topic name","func":"msg.topic = \"idtimer1\"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":300,"y":300,"wires":[["a4d19f8e.a873c"]]},{"id":"fd6f0bf5.9f8488","type":"inject","z":"b45877fe.988608","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"idtimer1","payload":"0","payloadType":"num","x":140,"y":460,"wires":[["a4d19f8e.a873c"]]},{"id":"6f9ef10f.a6c63","type":"ui_tab","name":"Home","icon":"dashboard","order":"1"}]

Welcome to the forum @Rob

Whenever you have something not working as expected the first thing to do is to work out exactly what is going on. Add debug nodes to the output of the bigtimer node and the function node feeding the gpio and see whether they are showing what you expect. If they are not then work back through the flow till you find the culprit.
Give the debug nodes names so it is easier to see what is going on.

You should think about using change node to set msg.topic instead of the function nodes

the whay you have your change node setup, it is looking for two msgs with unique topics to join, Both messages in your flow send the same thing in msg.topic. Change one of the topics and you will see it work.

First, thx for the reply....secondly, I don't see it...sry

I check the change node, but do you want me thinking about changing all 3 fucntions by the change node? Or only the ony coming from the timer?
(as I don't understand how to get a topic on my sensors output using the change node)

Sorry about the comment about the change nodes (and the delay in responding, My daughter arrrived with the grandkids) - I thought both function nodes were both just setting msg.topic.

If you test with the two injects, it will fail because both msgs have the same topic. To see this, add a debug on each of the injects and on the join node so you can see what is being processed.

What version of NR and node.js are you running? (you can get this from the startup log.

Hi Zeofmud, don't worry about the delay (I'm for my job in Norway for another 3 weeks...so I've got time) and give my regards to the grandkids! Tell them grandfather helped again somebody to solve his issue!!!

At the end it seems the timerswitch is injecting a string...the inject buttons a number. So I used your idea with the change node to change the payload output from the timer! (if string 1 found, replace it to number 1 and if string 0 found replace it with number 1)
---> and my output is coming high and low following the shedule!

THX for the hint!!!!

1 Like

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