i have created this flow a while back & it works just excellent. no issues.
current flow:
1- it takes the signal from a motion sensor
2- turns on the light & the exhaust fan
3- it takes a delay time from an input bolean (can be changed from frontend)
4- it waites for the delay time to end then it turns of the lights & fan (lights & fan have separate delay time)
the issue:
- whenever i take a shower, the fan will wait till its timer then turn off, which leaves the bathroom so humid.
-so i thought why not make it smarter and purchased a humidity sensor.
what i want to add:
i have added a temprature & humidity sensor in the bathroom.
i believe (until someone comes with a better idea) that the humidity sensor in someway can affect how long the fan will stay on. let’s say that it keeps running until a certain level of humidity is reached?
i am not a coder and the mentioned code was really my first code.
can somone guide me?
[{"id":"67df4e7c.1f7bd","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"b04eb42c.078578","type":"server-state-changed","z":"67df4e7c.1f7bd","name":"motion sensor 2","server":"","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.0x158d0006bea890_motion","entityidfiltertype":"exact","outputinitially":false,"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":"milliseconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":140,"y":140,"wires":[["84c119aa.1f91f8","b101be11.fa82c","3f29546c.35f7fc","281b8eda.3cebe2","4632fbf7.29db64"],[]]},{"id":"13cecb48.f417e5","type":"api-call-service","z":"67df4e7c.1f7bd","name":"turn on lights","server":"","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.ty5227015170039f8ff1ce, switch.ty5227015170039f8ff1ce_3","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"on","valueType":"str"}],"queue":"none","x":950,"y":160,"wires":[[]]},{"id":"b8dbc7d.8e74538","type":"api-call-service","z":"67df4e7c.1f7bd","name":"turn on fan","server":"","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.ty5227015170039f8ff1ce_2","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"on","valueType":"str"}],"queue":"none","x":950,"y":220,"wires":[[]]},{"id":"9c0c45db.797418","type":"server-state-changed","z":"67df4e7c.1f7bd","name":"motion sensor 2","server":"","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.10011fa244_1d1a01400366ae4a00","entityidfiltertype":"exact","outputinitially":false,"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":"milliseconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":140,"y":100,"wires":[["84c119aa.1f91f8","b101be11.fa82c","3f29546c.35f7fc","281b8eda.3cebe2","4632fbf7.29db64"],[]]},{"id":"37f782e1.2f580e","type":"comment","z":"67df4e7c.1f7bd","name":"Bathroom 1","info":"","x":130,"y":40,"wires":[]},{"id":"b101be11.fa82c","type":"api-current-state","z":"67df4e7c.1f7bd","name":"fan state","server":"","version":2,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"switch.ty5227015170039f8ff1ce_2","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":620,"y":220,"wires":[["b8dbc7d.8e74538"],["b8dbc7d.8e74538"]]},{"id":"84c119aa.1f91f8","type":"api-current-state","z":"67df4e7c.1f7bd","name":"light state","server":"","version":2,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"switch.ty5227015170039f8ff1ce","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":620,"y":160,"wires":[["13cecb48.f417e5"],["13cecb48.f417e5"]]},{"id":"3f29546c.35f7fc","type":"api-current-state","z":"67df4e7c.1f7bd","name":"","server":"","version":2,"outputs":1,"halt_if":"","halt_if_type":"num","halt_if_compare":"is","entity_id":"input_number.bathroom_timer","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":330,"y":300,"wires":[["bec18f62.870e5"]]},{"id":"4632fbf7.29db64","type":"api-current-state","z":"67df4e7c.1f7bd","name":"","server":"","version":2,"outputs":1,"halt_if":"","halt_if_type":"num","halt_if_compare":"is","entity_id":"input_number.master_bathroom_fan_timer","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":370,"y":420,"wires":[["9df4986e.6423f8"]]},{"id":"281b8eda.3cebe2","type":"api-current-state","z":"67df4e7c.1f7bd","name":"","server":"","version":2,"outputs":1,"halt_if":"","halt_if_type":"num","halt_if_compare":"is","entity_id":"input_number.bathroom_timer","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":330,"y":360,"wires":[["3869e153.16ae4e"]]},{"id":"bec18f62.870e5","type":"function","z":"67df4e7c.1f7bd","name":"","func":"msg.payload = 60000*msg.payload\nmsg.delay = msg.payload\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":300,"wires":[["a0fa5af9.a50578"]]},{"id":"3869e153.16ae4e","type":"function","z":"67df4e7c.1f7bd","name":"","func":"msg.payload = msg.payload*60000\nmsg.delay = msg.payload\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":360,"wires":[["68d1da7b.7659e4"]]},{"id":"9df4986e.6423f8","type":"function","z":"67df4e7c.1f7bd","name":"","func":"msg.payload = msg.payload*60000\nmsg.delay = msg.payload\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":420,"wires":[["c4125b6a.de3d08"]]},{"id":"f8aa549f.306dc8","type":"trigger","z":"67df4e7c.1f7bd","name":"","op1":"","op2":"true","op1type":"nul","op2type":"str","duration":"2","extend":true,"overrideDelay":true,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1080,"y":300,"wires":[["31417275.2d950e"]]},{"id":"9e5c6b17.5b4938","type":"trigger","z":"67df4e7c.1f7bd","name":"","op1":"","op2":"true","op1type":"nul","op2type":"str","duration":"2","extend":true,"overrideDelay":true,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1080,"y":360,"wires":[["31417275.2d950e"]]},{"id":"953277b8.0044d8","type":"trigger","z":"67df4e7c.1f7bd","name":"","op1":"","op2":"true","op1type":"nul","op2type":"str","duration":"2","extend":true,"overrideDelay":true,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1080,"y":420,"wires":[["cbca54df.a63bf8"]]},{"id":"31417275.2d950e","type":"api-call-service","z":"67df4e7c.1f7bd","name":"turn off lights","server":"","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.ty5227015170039f8ff1ce, switch.ty5227015170039f8ff1ce_3","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"off","valueType":"str"}],"queue":"none","x":1350,"y":320,"wires":[[]]},{"id":"cbca54df.a63bf8","type":"api-call-service","z":"67df4e7c.1f7bd","name":"turn off fan","server":"","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.ty5227015170039f8ff1ce_2","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"off","valueType":"str"}],"queue":"none","x":1350,"y":420,"wires":[[]]},{"id":"a0fa5af9.a50578","type":"change","z":"67df4e7c.1f7bd","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"delay","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":860,"y":300,"wires":[["f8aa549f.306dc8"]]},{"id":"68d1da7b.7659e4","type":"change","z":"67df4e7c.1f7bd","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"delay","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":860,"y":360,"wires":[["9e5c6b17.5b4938"]]},{"id":"c4125b6a.de3d08","type":"change","z":"67df4e7c.1f7bd","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"delay","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":860,"y":420,"wires":[["953277b8.0044d8"]]},{"id":"d2c4ae61.901e7","type":"api-call-service","z":"67df4e7c.1f7bd","name":"turn on lights","server":"","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.ty8633086640f520eb19dd, switch.ty8633086640f520eb19dd_2","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"on","valueType":"str"}],"queue":"none","x":950,"y":620,"wires":[[]]},{"id":"fe89f301.57708","type":"api-call-service","z":"67df4e7c.1f7bd","name":"turn on fan","server":"","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.ty8633086640f520eb19dd_3","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"on","valueType":"str"}],"queue":"none","x":950,"y":680,"wires":[[]]},{"id":"d3d3e7ff.698518","type":"server-state-changed","z":"67df4e7c.1f7bd","name":"motion sensor 2","server":"","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.0x158d0006d40c37_motion","entityidfiltertype":"exact","outputinitially":false,"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":"","valueType":"entityState"}],"x":200,"y":620,"wires":[["60d53844.7e2938","cbcd126.c6e16f","1a4e5aed.34bce5","d403a264.f9b57","fc2b570d.63e678"],[]]},{"id":"4d86b6c2.6be288","type":"comment","z":"67df4e7c.1f7bd","name":"Bathroom 2","info":"","x":130,"y":560,"wires":[]},{"id":"cbcd126.c6e16f","type":"api-current-state","z":"67df4e7c.1f7bd","name":"fan state","server":"","version":2,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"switch.ty8633086640f520eb19dd_3","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":620,"y":680,"wires":[[],["fe89f301.57708"]]},{"id":"60d53844.7e2938","type":"api-current-state","z":"67df4e7c.1f7bd","name":"light state","server":"","version":2,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"switch.ty8633086640f520eb19dd","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":620,"y":620,"wires":[[],["d2c4ae61.901e7"]]},{"id":"1a4e5aed.34bce5","type":"api-current-state","z":"67df4e7c.1f7bd","name":"","server":"","version":2,"outputs":1,"halt_if":"","halt_if_type":"num","halt_if_compare":"is","entity_id":"input_number.bathroom_1_lights_timer","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":360,"y":760,"wires":[["817b1353.26692"]]},{"id":"fc2b570d.63e678","type":"api-current-state","z":"67df4e7c.1f7bd","name":"","server":"","version":2,"outputs":1,"halt_if":"","halt_if_type":"num","halt_if_compare":"is","entity_id":"input_number.bathroom_1_fan_timer","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":350,"y":880,"wires":[["e03e65a4.47e598"]]},{"id":"d403a264.f9b57","type":"api-current-state","z":"67df4e7c.1f7bd","name":"","server":"","version":2,"outputs":1,"halt_if":"","halt_if_type":"num","halt_if_compare":"is","entity_id":"input_number.bathroom_1_lights_timer","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":360,"y":820,"wires":[["b3517dcc.a07b4"]]},{"id":"817b1353.26692","type":"function","z":"67df4e7c.1f7bd","name":"","func":"msg.payload = 60000*msg.payload\nmsg.delay = msg.payload\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":760,"wires":[["c8efec6.c00451"]]},{"id":"b3517dcc.a07b4","type":"function","z":"67df4e7c.1f7bd","name":"","func":"msg.payload = msg.payload*60000\nmsg.delay = msg.payload\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":820,"wires":[["85b71847.9e2088"]]},{"id":"e03e65a4.47e598","type":"function","z":"67df4e7c.1f7bd","name":"","func":"msg.payload = msg.payload*60000\nmsg.delay = msg.payload\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":880,"wires":[["c6172c9e.97061"]]},{"id":"35c730ce.1a3b2","type":"trigger","z":"67df4e7c.1f7bd","name":"","op1":"","op2":"true","op1type":"nul","op2type":"str","duration":"2","extend":true,"overrideDelay":true,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1080,"y":760,"wires":[["f3d6f67b.d00478"]]},{"id":"93646c8d.a741b","type":"trigger","z":"67df4e7c.1f7bd","name":"","op1":"","op2":"true","op1type":"nul","op2type":"str","duration":"2","extend":true,"overrideDelay":true,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1080,"y":820,"wires":[["f3d6f67b.d00478"]]},{"id":"4de61dd7.3c3fa4","type":"trigger","z":"67df4e7c.1f7bd","name":"","op1":"","op2":"true","op1type":"nul","op2type":"str","duration":"2","extend":true,"overrideDelay":true,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1080,"y":880,"wires":[["25b4adbe.d58032"]]},{"id":"c8efec6.c00451","type":"change","z":"67df4e7c.1f7bd","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"delay","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":860,"y":760,"wires":[["35c730ce.1a3b2"]]},{"id":"85b71847.9e2088","type":"change","z":"67df4e7c.1f7bd","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"delay","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":860,"y":820,"wires":[["93646c8d.a741b"]]},{"id":"c6172c9e.97061","type":"change","z":"67df4e7c.1f7bd","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"delay","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":860,"y":880,"wires":[["4de61dd7.3c3fa4"]]},{"id":"f3d6f67b.d00478","type":"api-call-service","z":"67df4e7c.1f7bd","name":"turn off lights","server":"","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.ty8633086640f520eb19dd, switch.ty8633086640f520eb19dd_2","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"on","valueType":"str"}],"queue":"none","x":1310,"y":780,"wires":[[]]},{"id":"25b4adbe.d58032","type":"api-call-service","z":"67df4e7c.1f7bd","name":"turn off fan","server":"","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.ty8633086640f520eb19dd_3","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"on","valueType":"str"}],"queue":"none","x":1310,"y":840,"wires":[[]]},{"id":"b23147ab.01be88","type":"server-state-changed","z":"67df4e7c.1f7bd","name":"motion sensor 2","server":"","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.0x158d0006d485b2_motion","entityidfiltertype":"exact","outputinitially":false,"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":"milliseconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":140,"y":180,"wires":[["84c119aa.1f91f8","b101be11.fa82c","3f29546c.35f7fc","281b8eda.3cebe2","4632fbf7.29db64"],[]]}]