Delay timer based on other message

Hi there,

I have a complicated (?) problem with a timer. The situation is as follows:
I use the bigtimer node for a regular job. It sends the message "start". A second node sends the message "0" if my cell phone is not in the wifi, and the message "1" if it's present.
Now, I want the scheduled job to wait until the message "0" of the second node is received.

This is my flow (I replaced the cell phone presence check with two simple input nodes):

[{"id":"24f234dd.7d3a2c","type":"bigtimer","z":"298248ba.274988","outtopic":"","outpayload1":"start","outpayload2":"","name":"Full cleaning","comment":"Scheduled full cleaning","lat":0,"lon":0,"starttime":"930","endtime":"945","starttime2":"0","endtime2":0,"startoff":0,"endoff":0,"startoff2":0,"endoff2":0,"offs":0,"outtext1":"","outtext2":"","timeout":1440,"sun":false,"mon":true,"tue":false,"wed":true,"thu":false,"fri":true,"sat":false,"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,"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":267,"y":440,"wires":[["36001bef.415374"],[],[]]},{"id":"3dacfc82.c2ec64","type":"join-wait","z":"298248ba.274988","name":"","paths":"[\"path_1\", \"path_2\"]","pathsToExpire":"","ignoreUnmatched":false,"pathTopic":"paths","pathTopicType":"msg","correlationTopic":"","correlationTopicType":"msg","timeout":"3","timeoutUnits":"60000","exactOrder":"true","firstMsg":"true","mapPayload":"false","disableComplete":false,"x":717,"y":380,"wires":[["ae203bec.0f54d8"],[]]},{"id":"ae203bec.0f54d8","type":"debug","z":"298248ba.274988","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":910,"y":320,"wires":[]},{"id":"6f1be94f.64b178","type":"change","z":"298248ba.274988","name":"","rules":[{"t":"set","p":"paths","pt":"msg","to":"path_2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":477,"y":380,"wires":[["3dacfc82.c2ec64"]]},{"id":"36001bef.415374","type":"change","z":"298248ba.274988","name":"","rules":[{"t":"set","p":"paths","pt":"msg","to":"path_1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":477,"y":480,"wires":[["3dacfc82.c2ec64"]]},{"id":"503bda12.efcc84","type":"switch","z":"298248ba.274988","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":247,"y":338,"wires":[[],["6f1be94f.64b178"]]},{"id":"585ebaab.052234","type":"inject","z":"298248ba.274988","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"manual on","payloadType":"str","x":97,"y":460,"wires":[["24f234dd.7d3a2c"]]},{"id":"cbbcdce5.304b3","type":"inject","z":"298248ba.274988","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"str","x":107,"y":280,"wires":[["503bda12.efcc84"]]},{"id":"eb4ab13a.65e8e","type":"inject","z":"298248ba.274988","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"str","x":107,"y":360,"wires":[["503bda12.efcc84"]]}]

It works well if I restart the flow and the message "start" comes first and the "0" second. This is due to the "Exact order" option.
Howerver, it does not work if the sequence is "0" - "start" - "0".

If I disable the "Exact order" option, also the sequence "0" - "1" - "start" would start the job immediately and does not wait until the cell phone is not present (i.e. status message is "0").

In order to avoid confusion: I don't want to stop/start the timer. The message should only be delayed until the second conditon becomes true.

Hope my problem is clear and someone has a good advice.

I have imported your flow and am confused as to check what you want. You have an inject node 0 and an inject node 1 then a manual node inputting to the timer. In what sequence does a "normal" sequence of events take? In other words what is the order you press the inject nodes and what is your expected output at the debug node?
What function does the switch node perform in your flow?

Normally, there is one input node to the switch node. It sends a "1" every minute when my phone is in the wifi, and a "0" if not. I replaced it with two for better manual debugging.
This is what I would like to have for different sequences:
a) "1"-"start"-"1": nothing should happen
b) "1"-"start"-"1"-"0" : forward the "start" message to the final node
c) "0"-"start"-"0": forward "start" message (this does not work at the moment)
d) "0"-"1"-"start"-"1": do nothing (but wait for a final "0" and then forward the message)
e) "0"-"1"-"start"-"0": forward the message

While writing this, it came to my mind to join the messages and then use the function node to evaluate the condition. Do you think this could help?

your schedule starts at 15:30 and ends at 15:45 - if the cell phone is in wifi you do not want the schedule to run, or if your cell phone is not in wifi you want the schedule to start.
Whether or not you get a 1 or a 0 seems to me to be somewhat misleading. What you really are looking for is a 0 and a start message. Whether or not you get a 1 doesn't really trigger anything.
It doesn't seem to me that whether you get a 0 first or a start first you are looking for both of them to trigger. If you get a 0 then the start message or start then 0 you should forward or am I missing something?
Also, is the 15 minute time out significant or do you just need a start signal?

is this getting close?

[{"id":"5ac90d9.df600f4","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"cbbcdce5.304b3","type":"inject","z":"5ac90d9.df600f4","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"str","x":130,"y":60,"wires":[["f32e4806.b710d"]]},{"id":"eb4ab13a.65e8e","type":"inject","z":"5ac90d9.df600f4","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"str","x":130,"y":120,"wires":[["f32e4806.b710d"]]},{"id":"f32e4806.b710d","type":"function","z":"5ac90d9.df600f4","name":"logic","func":"\nif (msg.payload == '0'){\n    flow.set('go',true);\n    node.status({fill:\"green\",shape:\"dot\",text:msg.payload});\n    return msg;\n}\n\nif (msg.payload == '1'){\n    flow.set('go',false);\n    node.status({fill:\"red\",shape:\"dot\",text:msg.payload});\n    return null;\n}\n\nreturn null;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":430,"y":100,"wires":[["50a3a125.487f4"]]},{"id":"50a3a125.487f4","type":"function","z":"5ac90d9.df600f4","name":"check","func":"let z = flow.get('go');\nlet y = flow.get('start');\n\nif (z === false || y === false){\n    node.status({fill:\"red\",shape:\"dot\",text:'no output'}); \n    return null;\n}\n\nif (y === true && z === true){\n    node.status({fill:\"green\",shape:\"dot\",text:msg.payload});\n    flow.set('go',false);\n    flow.set('start',false);\n    return msg;\n}\n\nreturn null;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":630,"y":180,"wires":[["b96b5cc8.a92a58"]]},{"id":"b96b5cc8.a92a58","type":"debug","z":"5ac90d9.df600f4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":830,"y":180,"wires":[]},{"id":"127b94ff.53b0db","type":"cronplus","z":"5ac90d9.df600f4","name":"start at 15:30","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"schedule1","topic":"schedule1","payloadType":"str","payload":"start","expressionType":"cron","expression":"0 30 15 * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":220,"y":180,"wires":[["a27be75a.d1e2a"]]},{"id":"a27be75a.d1e2a","type":"function","z":"5ac90d9.df600f4","name":"start","func":"let y = flow.get('start');\n\nif (typeof start == 'undefined'){\n    flow.set('start',false);\n}\n\nif (msg.payload == 'start'){\n    flow.set('start',true);\n}\n\nnode.status({fill:\"red\",shape:\"dot\",text:y}); \n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":430,"y":180,"wires":[["50a3a125.487f4"]]}]

Hi gerry,
yes! Seems to be excatly what I wanted to achieve. I only had to add a second cronjob as a timeout.