Organize the fan control in the toilet

Hello everybody! I’m new to node red, please tell me. It is necessary to organize the fan control in the toilet according to the following scheme - the light is turned on-if the light is on for more than 2 minutes after the light is turned off, the fan turns on. If the light is on for less than 2 minutes, nothing happens. I’m trying to assemble a circuit, but it doesn’t work properly. For experiments, I made the following scheme-according to the state of the outlet on, a timer starts - which turns on toggle 1, after turning off the outlet, toggle 2 turns on, there is a logical type true on their outputs, but the output of the element remains false. !
Help me figure out what I’m doing wrong.

[{“id”:“b5bd488d1aa82b2a”,“type”:“debug”,“z”:“c6dd7e9e60871302”,“name”:"",“active”:true,“tosidebar”:false,“console”:false,“tostatus”:true,“complete”:“true”,“targetType”:“full”,“statusVal”:“payload”,“statusType”:“auto”,“x”:90,“y”:1560,“wires”:[]},{“id”:“699d3f58f779368d”,“type”:“trigger”,“z”:“c6dd7e9e60871302”,“name”:"",“op1”:"",“op2”:“true”,“op1type”:“nul”,“op2type”:“bool”,“duration”:“5”,“extend”:false,“overrideDelay”:false,“units”:“s”,“reset”:“msg.reset”,“bytopic”:“all”,“topic”:“topic”,“outputs”:1,“x”:290,“y”:1640,“wires”:[[“e81c27048ed00880”,“ef35e87d654b8026”]]},{“id”:“ef35e87d654b8026”,“type”:“toggle”,“z”:“c6dd7e9e60871302”,“name”:"",“onOffTopic”:"",“onValue”:“true”,“onType”:“bool”,“offValue”:“false”,“offType”:“bool”,“toggleTopic”:"",“toggleValue”:"",“toggleType”:“num”,“passOnOff”:“always”,“x”:470,“y”:1640,“wires”:[[“bab797a1a97a3bd9”,“16b6bc421178a706”]]},{“id”:“bab797a1a97a3bd9”,“type”:“debug”,“z”:“c6dd7e9e60871302”,“name”:"",“active”:true,“tosidebar”:false,“console”:false,“tostatus”:true,“complete”:“true”,“targetType”:“full”,“statusVal”:“payload”,“statusType”:“auto”,“x”:470,“y”:1700,“wires”:[]},{“id”:“f2f02813d2011e36”,“type”:“inject”,“z”:“c6dd7e9e60871302”,“name”:"",“props”:[{“p”:“payload”},{“p”:“topic”,“vt”:“str”}],“repeat”:"",“crontab”:"",“once”:false,“onceDelay”:0.1,“topic”:“d”,“payload”:“true”,“payloadType”:“bool”,“x”:470,“y”:1540,“wires”:[[“ef35e87d654b8026”]]},{“id”:“a64c957874b9cad4”,“type”:“debug”,“z”:“c6dd7e9e60871302”,“name”:"",“active”:true,“tosidebar”:false,“console”:false,“tostatus”:true,“complete”:“true”,“targetType”:“full”,“statusVal”:“payload”,“statusType”:“auto”,“x”:470,“y”:1960,“wires”:[]},{“id”:“e81c27048ed00880”,“type”:“debug”,“z”:“c6dd7e9e60871302”,“name”:"",“active”:true,“tosidebar”:false,“console”:false,“tostatus”:true,“complete”:“true”,“targetType”:“full”,“statusVal”:“payload”,“statusType”:“auto”,“x”:290,“y”:1580,“wires”:[]},{“id”:“55baa0bffb7cb726”,“type”:“server-state-changed”,“z”:“c6dd7e9e60871302”,“name”:“Розетка вкл”,“server”:“a7a72bf0.68e5f8”,“version”:4,“exposeToHomeAssistant”:false,“haConfig”:[{“property”:“name”,“value”:""},{“property”:“icon”,“value”:""}],“entityidfilter”:“switch.smart_power_outlet_1”,“entityidfiltertype”:“exact”,“outputinitially”:true,“state_type”:“str”,“haltifstate”:“on”,“halt_if_type”:“str”,“halt_if_compare”:“is”,“outputs”:2,“output_only_on_state_change”:false,“for”:“0”,“forType”:“num”,“forUnits”:“minutes”,“ignorePrevStateNull”:false,“ignorePrevStateUnknown”:false,“ignorePrevStateUnavailable”:false,“ignoreCurrentStateUnknown”:false,“ignoreCurrentStateUnavailable”:false,“outputProperties”:[{“property”:“payload”,“propertyType”:“msg”,“value”:“true”,“valueType”:“bool”},{“property”:“topic”,“propertyType”:“msg”,“value”:“d1”,“valueType”:“str”}],“x”:70,“y”:1640,“wires”:[[“b5bd488d1aa82b2a”,“699d3f58f779368d”],[]]},{“id”:“06e78c65260a9ec2”,“type”:“toggle”,“z”:“c6dd7e9e60871302”,“name”:"",“onOffTopic”:"",“onValue”:“true”,“onType”:“bool”,“offValue”:“false”,“offType”:“bool”,“toggleTopic”:"",“toggleValue”:"",“toggleType”:“str”,“passOnOff”:“always”,“x”:470,“y”:1820,“wires”:[[“a64c957874b9cad4”,“16b6bc421178a706”,“1f58f5262f93d506”]]},{“id”:“1a10caa8d8ec8e83”,“type”:“inject”,“z”:“c6dd7e9e60871302”,“name”:"",“props”:[{“p”:“payload”},{“p”:“topic”,“vt”:“str”}],“repeat”:"",“crontab”:"",“once”:false,“onceDelay”:0.1,“topic”:“f”,“payload”:“true”,“payloadType”:“bool”,“x”:470,“y”:1880,“wires”:[[“06e78c65260a9ec2”]]},{“id”:“1f58f5262f93d506”,“type”:“trigger”,“z”:“c6dd7e9e60871302”,“name”:“msg.reset”,“op1”:“msg.reset”,“op2”:"",“op1type”:“str”,“op2type”:“nul”,“duration”:“250”,“extend”:false,“overrideDelay”:false,“units”:“ms”,“reset”:"",“bytopic”:“all”,“topic”:“topic”,“outputs”:1,“x”:280,“y”:1700,“wires”:[[“699d3f58f779368d”]]},{“id”:“4b98081bf8ba5e49”,“type”:“debug”,“z”:“c6dd7e9e60871302”,“name”:"",“active”:true,“tosidebar”:true,“console”:true,“tostatus”:true,“complete”:“payload”,“targetType”:“msg”,“statusVal”:“payload”,“statusType”:“auto”,“x”:680,“y”:1780,“wires”:[]},{“id”:“2925551b45958143”,“type”:“inject”,“z”:“c6dd7e9e60871302”,“name”:"",“props”:[{“p”:“payload”},{“p”:“topic”,“vt”:“str”}],“repeat”:"",“crontab”:"",“once”:false,“onceDelay”:0.1,“topic”:“d”,“payload”:“false”,“payloadType”:“bool”,“x”:470,“y”:1580,“wires”:[[“ef35e87d654b8026”]]},{“id”:“65477bf847b2e777”,“type”:“inject”,“z”:“c6dd7e9e60871302”,“name”:"",“props”:[{“p”:“payload”},{“p”:“topic”,“vt”:“str”}],“repeat”:"",“crontab”:"",“once”:false,“onceDelay”:0.1,“topic”:“f”,“payload”:“false”,“payloadType”:“bool”,“x”:470,“y”:1920,“wires”:[[“06e78c65260a9ec2”]]},{“id”:“9c682427985f3080”,“type”:“server-state-changed”,“z”:“c6dd7e9e60871302”,“name”:“Розетка выкл”,“server”:“a7a72bf0.68e5f8”,“version”:4,“exposeToHomeAssistant”:false,“haConfig”:[{“property”:“name”,“value”:""},{“property”:“icon”,“value”:""}],“entityidfilter”:“switch.smart_power_outlet_1”,“entityidfiltertype”:“exact”,“outputinitially”:true,“state_type”:“str”,“haltifstate”:“off”,“halt_if_type”:“str”,“halt_if_compare”:“is”,“outputs”:2,“output_only_on_state_change”:false,“for”:“0”,“forType”:“num”,“forUnits”:“minutes”,“ignorePrevStateNull”:false,“ignorePrevStateUnknown”:false,“ignorePrevStateUnavailable”:false,“ignoreCurrentStateUnknown”:false,“ignoreCurrentStateUnavailable”:false,“outputProperties”:[{“property”:“payload”,“propertyType”:“msg”,“value”:“true”,“valueType”:“bool”},{“property”:“topic”,“propertyType”:“msg”,“value”:“d2”,“valueType”:“str”}],“x”:70,“y”:1700,“wires”:[[“06e78c65260a9ec2”],[]]},{“id”:“16b6bc421178a706”,“type”:“BooleanLogicUltimate”,“z”:“c6dd7e9e60871302”,“name”:"",“filtertrue”:“both”,“persist”:true,“sInitializeWith”:“WaitForPayload”,“triggertopic”:“trigger”,“outputtriggeredby”:“all”,“inputCount”:2,“topic”:“result”,“restrictinputevaluation”:false,“delayEvaluation”:"",“x”:630,“y”:1700,“wires”:[[“4b98081bf8ba5e49”],[],[]]},{“id”:“a7a72bf0.68e5f8”,“type”:“server”,“name”:“Home Assistant”,“version”:2,“addon”:true,“rejectUnauthorizedCerts”:true,“ha_boolean”:“y|yes|true|on|home|open”,“connectionDelay”:true,“cacheJson”:true,“heartbeat”:false,“heartbeatInterval”:30}]!

I can’t import your flow.

[{"id":"dd74f19f.c8f96","type":"server-state-changed","z":"878e74c2.7f39c8","name":"Light on for 2 min?","server":"9405c3fe.d0a6c","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"2","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[],"x":330,"y":700,"wires":[["34246891.c23c48"],[]]},{"id":"34246891.c23c48","type":"ha-wait-until","z":"878e74c2.7f39c8","name":"wait until off","server":"9405c3fe.d0a6c","version":0,"outputs":1,"entityId":"light","entityIdFilterType":"exact","property":"state","comparator":"is","value":"off","valueType":"str","timeout":0,"timeoutType":"num","timeoutUnits":"seconds","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":530,"y":700,"wires":[["294b4890.6b0de8"]]},{"id":"294b4890.6b0de8","type":"api-call-service","z":"878e74c2.7f39c8","name":"fan on","server":"9405c3fe.d0a6c","version":3,"debugenabled":false,"service_domain":"fan","service":"turn_on","entityId":"fan","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":690,"y":700,"wires":[[]]},{"id":"9405c3fe.d0a6c","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

I’ll try again

[{“id”:“dc1ba27ef904f467”,“type”:“debug”,“z”:“73459d5a78c835b5”,“name”:"",“active”:true,“tosidebar”:false,“console”:false,“tostatus”:true,“complete”:“true”,“targetType”:“full”,“statusVal”:“payload”,“statusType”:“auto”,“x”:210,“y”:240,“wires”:[]},{“id”:“dcce1c2a3b596e9d”,“type”:“trigger”,“z”:“73459d5a78c835b5”,“name”:"",“op1”:"",“op2”:“true”,“op1type”:“nul”,“op2type”:“bool”,“duration”:“5”,“extend”:false,“overrideDelay”:false,“units”:“s”,“reset”:“msg.reset”,“bytopic”:“all”,“topic”:“topic”,“outputs”:1,“x”:410,“y”:320,“wires”:[[“c52fec5bbf646331”,“971254e39c9ea314”]]},{“id”:“971254e39c9ea314”,“type”:“toggle”,“z”:“73459d5a78c835b5”,“name”:“toggle 1”,“onOffTopic”:"",“onValue”:“true”,“onType”:“bool”,“offValue”:“false”,“offType”:“bool”,“toggleTopic”:"",“toggleValue”:"",“toggleType”:“num”,“passOnOff”:“always”,“x”:620,“y”:320,“wires”:[[“edc4884d569d6c83”,“b603b67d1f89a1d3”]]},{“id”:“edc4884d569d6c83”,“type”:“debug”,“z”:“73459d5a78c835b5”,“name”:"",“active”:true,“tosidebar”:false,“console”:false,“tostatus”:true,“complete”:“true”,“targetType”:“full”,“statusVal”:“payload”,“statusType”:“auto”,“x”:610,“y”:380,“wires”:[]},{“id”:“62d3671361567b87”,“type”:“inject”,“z”:“73459d5a78c835b5”,“name”:"",“props”:[{“p”:“payload”},{“p”:“topic”,“vt”:“str”}],“repeat”:"",“crontab”:"",“once”:false,“onceDelay”:0.1,“topic”:“d”,“payload”:“true”,“payloadType”:“bool”,“x”:610,“y”:160,“wires”:[[“971254e39c9ea314”]]},{“id”:“1ecdd83c993091a7”,“type”:“debug”,“z”:“73459d5a78c835b5”,“name”:"",“active”:true,“tosidebar”:false,“console”:false,“tostatus”:true,“complete”:“true”,“targetType”:“full”,“statusVal”:“payload”,“statusType”:“auto”,“x”:630,“y”:700,“wires”:[]},{“id”:“c52fec5bbf646331”,“type”:“debug”,“z”:“73459d5a78c835b5”,“name”:"",“active”:true,“tosidebar”:false,“console”:false,“tostatus”:true,“complete”:“true”,“targetType”:“full”,“statusVal”:“payload”,“statusType”:“auto”,“x”:410,“y”:260,“wires”:[]},{“id”:“d154b117e32b9990”,“type”:“server-state-changed”,“z”:“73459d5a78c835b5”,“name”:“on”,“server”:“a7a72bf0.68e5f8”,“version”:4,“exposeToHomeAssistant”:false,“haConfig”:[{“property”:“name”,“value”:""},{“property”:“icon”,“value”:""}],“entityidfilter”:“switch.smart_power_outlet_1”,“entityidfiltertype”:“exact”,“outputinitially”:true,“state_type”:“str”,“haltifstate”:“on”,“halt_if_type”:“str”,“halt_if_compare”:“is”,“outputs”:2,“output_only_on_state_change”:false,“for”:“0”,“forType”:“num”,“forUnits”:“minutes”,“ignorePrevStateNull”:false,“ignorePrevStateUnknown”:false,“ignorePrevStateUnavailable”:false,“ignoreCurrentStateUnknown”:false,“ignoreCurrentStateUnavailable”:false,“outputProperties”:[{“property”:“payload”,“propertyType”:“msg”,“value”:“true”,“valueType”:“bool”},{“property”:“topic”,“propertyType”:“msg”,“value”:“d”,“valueType”:“str”}],“x”:210,“y”:320,“wires”:[[“dc1ba27ef904f467”,“dcce1c2a3b596e9d”],[]]},{“id”:“fcd697b97a783a8e”,“type”:“toggle”,“z”:“73459d5a78c835b5”,“name”:“toggle 2”,“onOffTopic”:"",“onValue”:“true”,“onType”:“bool”,“offValue”:“false”,“offType”:“bool”,“toggleTopic”:"",“toggleValue”:"",“toggleType”:“str”,“passOnOff”:“always”,“x”:620,“y”:500,“wires”:[[“1ecdd83c993091a7”,“b603b67d1f89a1d3”,“2ff83a2218c49017”]]},{“id”:“4b8a956a2fcd3cfb”,“type”:“inject”,“z”:“73459d5a78c835b5”,“name”:"",“props”:[{“p”:“payload”},{“p”:“topic”,“vt”:“str”}],“repeat”:"",“crontab”:"",“once”:false,“onceDelay”:0.1,“topic”:“f”,“payload”:“true”,“payloadType”:“bool”,“x”:630,“y”:580,“wires”:[[“fcd697b97a783a8e”]]},{“id”:“2ff83a2218c49017”,“type”:“trigger”,“z”:“73459d5a78c835b5”,“name”:“msg.reset”,“op1”:“msg.reset”,“op2”:"",“op1type”:“str”,“op2type”:“nul”,“duration”:“250”,“extend”:false,“overrideDelay”:false,“units”:“ms”,“reset”:"",“bytopic”:“all”,“topic”:“topic”,“outputs”:1,“x”:400,“y”:380,“wires”:[[“971254e39c9ea314”]]},{“id”:“f6a525e1b3c64954”,“type”:“debug”,“z”:“73459d5a78c835b5”,“name”:"",“active”:true,“tosidebar”:true,“console”:true,“tostatus”:true,“complete”:“payload”,“targetType”:“msg”,“statusVal”:“payload”,“statusType”:“auto”,“x”:840,“y”:480,“wires”:[]},{“id”:“42f1861ea9685dae”,“type”:“inject”,“z”:“73459d5a78c835b5”,“name”:"",“props”:[{“p”:“payload”},{“p”:“topic”,“vt”:“str”}],“repeat”:"",“crontab”:"",“once”:false,“onceDelay”:0.1,“topic”:“d”,“payload”:“false”,“payloadType”:“bool”,“x”:610,“y”:220,“wires”:[[“971254e39c9ea314”]]},{“id”:“e685cac91fd0ed09”,“type”:“inject”,“z”:“73459d5a78c835b5”,“name”:"",“props”:[{“p”:“payload”},{“p”:“topic”,“vt”:“str”}],“repeat”:"",“crontab”:"",“once”:false,“onceDelay”:0.1,“topic”:“f”,“payload”:“false”,“payloadType”:“bool”,“x”:630,“y”:640,“wires”:[[“fcd697b97a783a8e”]]},{“id”:“5a6af73418fd67d5”,“type”:“server-state-changed”,“z”:“73459d5a78c835b5”,“name”:“off”,“server”:“a7a72bf0.68e5f8”,“version”:4,“exposeToHomeAssistant”:false,“haConfig”:[{“property”:“name”,“value”:""},{“property”:“icon”,“value”:""}],“entityidfilter”:“switch.smart_power_outlet_1”,“entityidfiltertype”:“exact”,“outputinitially”:true,“state_type”:“str”,“haltifstate”:“off”,“halt_if_type”:“str”,“halt_if_compare”:“is”,“outputs”:2,“output_only_on_state_change”:false,“for”:“0”,“forType”:“num”,“forUnits”:“minutes”,“ignorePrevStateNull”:false,“ignorePrevStateUnknown”:false,“ignorePrevStateUnavailable”:false,“ignoreCurrentStateUnknown”:false,“ignoreCurrentStateUnavailable”:false,“outputProperties”:[{“property”:“payload”,“propertyType”:“msg”,“value”:“true”,“valueType”:“bool”},{“property”:“topic”,“propertyType”:“msg”,“value”:“d”,“valueType”:“str”}],“x”:210,“y”:500,“wires”:[[“fcd697b97a783a8e”],[]]},{“id”:“b603b67d1f89a1d3”,“type”:“BooleanLogicUltimate”,“z”:“73459d5a78c835b5”,“name”:"",“filtertrue”:“both”,“persist”:true,“sInitializeWith”:“WaitForPayload”,“triggertopic”:“trigger”,“outputtriggeredby”:“all”,“inputCount”:2,“topic”:“result”,“restrictinputevaluation”:false,“delayEvaluation”:"",“x”:770,“y”:340,“wires”:[[“f6a525e1b3c64954”,“c896cd86379d8535”],[],[]]},{“id”:“c896cd86379d8535”,“type”:“api-call-service”,“z”:“73459d5a78c835b5”,“name”:"",“server”:“a7a72bf0.68e5f8”,“version”:5,“debugenabled”:false,“domain”:“light”,“service”:“turn_on”,“areaId”:[],“deviceId”:[“b7bf357d70ee85d0b6c80123203f4ba3”],“entityId”:[],“data”:"",“dataType”:“jsonata”,“mergeContext”:"",“mustacheAltTags”:false,“outputProperties”:[],“queue”:“none”,“x”:830,“y”:540,“wires”:[[]]},{“id”:“a7a72bf0.68e5f8”,“type”:“server”,“name”:“Home Assistant”,“version”:2,“addon”:true,“rejectUnauthorizedCerts”:true,“ha_boolean”:“y|yes|true|on|home|open”,“connectionDelay”:true,“cacheJson”:true,“heartbeat”:false,“heartbeatInterval”:30}]

The events: state node already have the option to first react after a set time and ignore it if the state returns to the one before.

Nope, same problem. Try limiting your flow whithin three reversed commas like this one ```. Three in the beginning, three in the end. Besides that, have you imported my flow? everything you need is there

Hello, thank you very much, your scheme works! What I need, I’ve been trying to solve this problem for several days and didn’t know what could be done so simply!

Hi, thanks for the help, you’re right, I did it according to the obaldius scheme and everything worked! I will study further.

Well, Obaldius solved it for you.
I was about to explain my last post when I saw Obaldius had made a complete solution as I wrote that, so I left it at that. :wink:

Yes, it turns out so. I tried to do according to this scheme. Thank you, I will continue to study, node red is an interesting thing