Bathroom Humidity fan

On the system that shall not be named (joking). I created a bathroom humidity app that looked at humidity increase of one sensor to turn on a bathroom fan during a shower. I recreated it in Node red.

I know there are other ways of solving this, but I figured I should share.

Code

[{“id”:“a3d0bc9b113dabf1”,“type”:“change”,“z”:“8ef216b4818a03fb”,“name”:“Save and find hum diff”,“rules”:[{“t”:“set”,“p”:“humidity[1]”,“pt”:“flow”,“to”:“humidity[0]”,“tot”:“flow”},{“t”:“set”,“p”:“humidity[0]”,“pt”:“flow”,“to”:“payload”,“tot”:“msg”},{“t”:“delete”,“p”:“payload”,“pt”:“msg”},{“t”:“set”,“p”:“humidity”,“pt”:“msg”,“to”:“humidity”,“tot”:“flow”},{“t”:“set”,“p”:“payload”,“pt”:“msg”,“to”:“msg.humidity[0]-msg.humidity[1]”,“tot”:“jsonata”}],“action”:“”,“property”:“”,“from”:“”,“to”:“”,“reg”:false,“x”:680,“y”:280,“wires”:[[“4fdf5729348cfa69”,“43fc4be40c0483ec”]]},{“id”:“4fdf5729348cfa69”,“type”:“switch”,“z”:“8ef216b4818a03fb”,“name”:“Humidity > 0”,“property”:“payload”,“propertyType”:“msg”,“rules”:[{“t”:“gt”,“v”:“0”,“vt”:“num”},{“t”:“lte”,“v”:“0”,“vt”:“num”}],“checkall”:“true”,“repair”:false,“outputs”:2,“x”:870,“y”:280,“wires”:[[“a7d6a78e980ea28e”,“285882dc460eaddb”],[“bd9fb15b59da77c8”]]},{“id”:“282ad6c1a1336d9f”,“type”:“switch”,“z”:“8ef216b4818a03fb”,“name”:“Check for fan Threshold”,“property”:“payload”,“propertyType”:“msg”,“rules”:[{“t”:“gt”,“v”:“3”,“vt”:“num”}],“checkall”:“true”,“repair”:false,“outputs”:1,“x”:810,“y”:160,“wires”:[[“b0d4f1d2c89a3052”,“b0ce8679a3fba070”]]},{“id”:“879e49d7973130dd”,“type”:“change”,“z”:“8ef216b4818a03fb”,“name”:“Initialize start”,“rules”:[{“t”:“set”,“p”:“StartHumidity”,“pt”:“flow”,“to”:“humidity[1]”,“tot”:“flow”},{“t”:“set”,“p”:“ShutdownStarted”,“pt”:“flow”,“to”:“false”,“tot”:“bool”},{“t”:“set”,“p”:“FanAutoStart”,“pt”:“flow”,“to”:“true”,“tot”:“bool”}],“action”:“”,“property”:“”,“from”:“”,“to”:“”,“reg”:false,“x”:1390,“y”:120,“wires”:[[“2a98ac1b40d47cc6”]]},{“id”:“2d01f9713922cb34”,“type”:“change”,“z”:“8ef216b4818a03fb”,“name”:“Set Threshold”,“rules”:[{“t”:“delete”,“p”:“payload”,“pt”:“msg”},{“t”:“set”,“p”:“MaxHumidity”,“pt”:“flow”,“to”:“humidity[0]”,“tot”:“flow”},{“t”:“set”,“p”:“MaxHumidity”,“pt”:“msg”,“to”:“MaxHumidity”,“tot”:“flow”},{“t”:“set”,“p”:“StartHumidity”,“pt”:“msg”,“to”:“StartHumidity”,“tot”:“flow”},{“t”:“set”,“p”:“payload”,“pt”:“msg”,“to”:“0.25*(msg.MaxHumidity-msg.StartHumidity)+msg.StartHumidity”,“tot”:“jsonata”},{“t”:“set”,“p”:“OffThreshold”,“pt”:“flow”,“to”:“payload”,“tot”:“msg”}],“action”:“”,“property”:“”,“from”:“”,“to”:“”,“reg”:false,“x”:1640,“y”:220,“wires”:[[“20550b2f23307b1e”]]},{“id”:“1363223d3a89c9ab”,“type”:“switch”,“z”:“8ef216b4818a03fb”,“name”:“below threshold”,“property”:“OffThreshold”,“propertyType”:“flow”,“rules”:[{“t”:“gte”,“v”:“humidity[0]”,“vt”:“flow”},{“t”:“lt”,“v”:“humidity[0]”,“vt”:“flow”}],“checkall”:“true”,“repair”:false,“outputs”:2,“x”:560,“y”:380,“wires”:[[“6ada895f449e86cd”],[“c55afc65c990c12f”]]},{“id”:“b06b71288442c0f6”,“type”:“change”,“z”:“8ef216b4818a03fb”,“name”:“”,“rules”:[{“t”:“set”,“p”:“ShutdownStarted”,“pt”:“flow”,“to”:“true”,“tot”:“bool”}],“action”:“”,“property”:“”,“from”:“”,“to”:“”,“reg”:false,“x”:1030,“y”:380,“wires”:[[“61956715cc2e4f9c”]]},{“id”:“6ada895f449e86cd”,“type”:“switch”,“z”:“8ef216b4818a03fb”,“name”:“ShutdownStarted?”,“property”:“ShutdownStarted”,“propertyType”:“flow”,“rules”:[{“t”:“true”},{“t”:“false”}],“checkall”:“true”,“repair”:false,“outputs”:2,“x”:790,“y”:380,“wires”:[[],[“b06b71288442c0f6”]]},{“id”:“61956715cc2e4f9c”,“type”:“stoptimer-varidelay”,“z”:“8ef216b4818a03fb”,“duration”:“25”,“durationType”:“num”,“units”:“Minute”,“payloadtype”:“num”,“payloadval”:“0”,“name”:“”,“reporting”:“last_minute_seconds”,“persist”:true,“ignoretimerpass”:false,“x”:1020,“y”:500,“wires”:[[“99582e26941011d8”],[],[]]},{“id”:“b631fbb21d16ee08”,“type”:“switch”,“z”:“8ef216b4818a03fb”,“name”:“Max Humidity increase?”,“property”:“humidity[0]”,“propertyType”:“flow”,“rules”:[{“t”:“gt”,“v”:“MaxHumidity”,“vt”:“flow”},{“t”:“lte”,“v”:“MaxHumidity”,“vt”:“flow”}],“checkall”:“true”,“repair”:false,“outputs”:2,“x”:1390,“y”:260,“wires”:[[“5fab948b5a4871b2”,“2d01f9713922cb34”],[“1363223d3a89c9ab”]]},{“id”:“5fab948b5a4871b2”,“type”:“change”,“z”:“8ef216b4818a03fb”,“name”:“STOP”,“rules”:[{“t”:“set”,“p”:“payload”,“pt”:“msg”,“to”:“STOP”,“tot”:“str”}],“action”:“”,“property”:“”,“from”:“”,“to”:“”,“reg”:false,“x”:870,“y”:500,“wires”:[[“61956715cc2e4f9c”]]},{“id”:“37b5cc0c3fb1317d”,“type”:“stoptimer-varidelay”,“z”:“8ef216b4818a03fb”,“duration”:“2”,“durationType”:“num”,“units”:“Hour”,“payloadtype”:“num”,“payloadval”:“0”,“name”:“”,“reporting”:“last_minute_seconds”,“persist”:true,“ignoretimerpass”:false,“x”:1130,“y”:720,“wires”:[[“99582e26941011d8”],[],[]]},{“id”:“9f732e835e5a99db”,“type”:“change”,“z”:“8ef216b4818a03fb”,“name”:“STOP”,“rules”:[{“t”:“set”,“p”:“payload”,“pt”:“msg”,“to”:“STOP”,“tot”:“str”}],“action”:“”,“property”:“”,“from”:“”,“to”:“”,“reg”:false,“x”:530,“y”:620,“wires”:[[“37b5cc0c3fb1317d”,“2778726d0ba1bd6c”]]},{“id”:“2778726d0ba1bd6c”,“type”:“stoptimer-varidelay”,“z”:“8ef216b4818a03fb”,“duration”:“10”,“durationType”:“num”,“units”:“Minute”,“payloadtype”:“num”,“payloadval”:“0”,“name”:“”,“reporting”:“last_minute_seconds”,“persist”:true,“ignoretimerpass”:false,“x”:840,“y”:620,“wires”:[[“99582e26941011d8”],[],[]]},{“id”:“b0d4f1d2c89a3052”,“type”:“change”,“z”:“8ef216b4818a03fb”,“name”:“STOP”,“rules”:[{“t”:“set”,“p”:“payload”,“pt”:“msg”,“to”:“STOP”,“tot”:“str”}],“action”:“”,“property”:“”,“from”:“”,“to”:“”,“reg”:false,“x”:990,“y”:200,“wires”:[[“2778726d0ba1bd6c”]]},{“id”:“7fad7857cea0770b”,“type”:“change”,“z”:“8ef216b4818a03fb”,“name”:“Stop Vars”,“rules”:[{“t”:“set”,“p”:“FanAutoStart”,“pt”:“flow”,“to”:“false”,“tot”:“bool”}],“action”:“”,“property”:“”,“from”:“”,“to”:“”,“reg”:false,“x”:540,“y”:580,“wires”:[[]]},{“id”:“2c1ceb9c7799075c”,“type”:“switch”,“z”:“8ef216b4818a03fb”,“name”:“Fan AutoStarted?”,“property”:“FanAutoStart”,“propertyType”:“flow”,“rules”:[{“t”:“false”}],“checkall”:“true”,“repair”:false,“outputs”:1,“x”:610,“y”:480,“wires”:[[“2778726d0ba1bd6c”]]},{“id”:“a7d6a78e980ea28e”,“type”:“switch”,“z”:“8ef216b4818a03fb”,“name”:“Mode Check”,“property”:“Mode”,“propertyType”:“global”,“rules”:[{“t”:“eq”,“v”:“Day”,“vt”:“str”},{“t”:“eq”,“v”:“Weekend”,“vt”:“str”},{“t”:“eq”,“v”:“Night”,“vt”:“str”},{“t”:“eq”,“v”:“Away”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:4,“x”:570,“y”:200,“wires”:[[“282ad6c1a1336d9f”],[“282ad6c1a1336d9f”],[“282ad6c1a1336d9f”],[]]},{“id”:“20550b2f23307b1e”,“type”:“StatusUltimate”,“z”:“8ef216b4818a03fb”,“name”:“Off Threshold”,“property”:“payload”,“x”:1820,“y”:220,“wires”:[[]]},{“id”:“b0ce8679a3fba070”,“type”:“switch”,“z”:“8ef216b4818a03fb”,“name”:“Fan Auto Started”,“property”:“FanAutoStart”,“propertyType”:“flow”,“rules”:[{“t”:“true”},{“t”:“false”}],“checkall”:“true”,“repair”:false,“outputs”:2,“x”:1190,“y”:140,“wires”:[[],[“37b5cc0c3fb1317d”,“879e49d7973130dd”,“2d01f9713922cb34”]]},{“id”:“285882dc460eaddb”,“type”:“switch”,“z”:“8ef216b4818a03fb”,“name”:“Fan Auto Started”,“property”:“FanAutoStart”,“propertyType”:“flow”,“rules”:[{“t”:“true”},{“t”:“false”}],“checkall”:“true”,“repair”:false,“outputs”:2,“x”:1150,“y”:260,“wires”:[[“b631fbb21d16ee08”],[]]},{“id”:“bd9fb15b59da77c8”,“type”:“switch”,“z”:“8ef216b4818a03fb”,“name”:“Fan Auto Started”,“property”:“FanAutoStart”,“propertyType”:“flow”,“rules”:[{“t”:“true”},{“t”:“false”}],“checkall”:“true”,“repair”:false,“outputs”:2,“x”:250,“y”:420,“wires”:[[“1363223d3a89c9ab”],[]]},{“id”:“e9d217a4e24fae8b”,“type”:“StatusUltimate”,“z”:“8ef216b4818a03fb”,“name”:“Fan Auto Started”,“property”:“payload”,“x”:470,“y”:140,“wires”:[[]]},{“id”:“36e84da8a1bd66b4”,“type”:“change”,“z”:“8ef216b4818a03fb”,“name”:“”,“rules”:[{“t”:“set”,“p”:“payload”,“pt”:“msg”,“to”:“FanAutoStart”,“tot”:“flow”}],“action”:“”,“property”:“”,“from”:“”,“to”:“”,“reg”:false,“x”:260,“y”:140,“wires”:[[“e9d217a4e24fae8b”]]},{“id”:“c55afc65c990c12f”,“type”:“change”,“z”:“8ef216b4818a03fb”,“name”:“”,“rules”:[{“t”:“set”,“p”:“ShutdownStarted”,“pt”:“flow”,“to”:“false”,“tot”:“bool”}],“action”:“”,“property”:“”,“from”:“”,“to”:“”,“reg”:false,“x”:610,“y”:440,“wires”:[[“5fab948b5a4871b2”]]},{“id”:“ae1b4c0ec9bf13f7”,“type”:“zigbee2mqtt-in”,“z”:“8ef216b4818a03fb”,“name”:“”,“server”:“7cb1c3849a98d34b”,“friendly_name”:“OS Bath Motion Humidity”,“device_id”:“0xd0cf5efffeb64c85”,“state”:“humidity”,“outputAtStartup”:false,“x”:130,“y”:280,“wires”:[[]]},{“id”:“977a7250aa5d6490”,“type”:“rbe”,“z”:“8ef216b4818a03fb”,“name”:“”,“func”:“rbe”,“gap”:“”,“start”:“”,“inout”:“out”,“septopics”:true,“property”:“payload”,“topi”:“topic”,“x”:490,“y”:280,“wires”:[[“a3d0bc9b113dabf1”]]},{“id”:“5bbcf51689c06918”,“type”:“change”,“z”:“8ef216b4818a03fb”,“name”:“”,“rules”:[{“t”:“set”,“p”:“topic”,“pt”:“msg”,“to”:“device.friendly_name”,“tot”:“msg”}],“action”:“”,“property”:“”,“from”:“”,“to”:“”,“reg”:false,“x”:350,“y”:280,“wires”:[[“977a7250aa5d6490”]]},{“id”:“43fc4be40c0483ec”,“type”:“StatusUltimate”,“z”:“8ef216b4818a03fb”,“name”:“Last Humid diff”,“property”:“payload”,“x”:820,“y”:200,“wires”:[[]]},{“id”:“97842f91b0edeb27”,“type”:“inject”,“z”:“8ef216b4818a03fb”,“name”:“”,“props”:[{“p”:“payload”},{“p”:“topic”,“vt”:“str”}],“repeat”:“”,“crontab”:“”,“once”:false,“onceDelay”:0.1,“topic”:“humid”,“payload”:“95”,“payloadType”:“num”,“x”:200,“y”:340,“wires”:[[“977a7250aa5d6490”]]},{“id”:“2a98ac1b40d47cc6”,“type”:“delay”,“z”:“8ef216b4818a03fb”,“name”:“”,“pauseType”:“delay”,“timeout”:“1”,“timeoutUnits”:“seconds”,“rate”:“1”,“nbRateUnits”:“1”,“rateUnits”:“second”,“randomFirst”:“1”,“randomLast”:“5”,“randomUnits”:“seconds”,“drop”:false,“allowrate”:false,“outputs”:1,“x”:1540,“y”:120,“wires”:[[“89aa3dd7b775d80d”]]},{“id”:“238369dd863e4bda”,“type”:“mqtt out”,“z”:“8ef216b4818a03fb”,“name”:“OS Bath Fan”,“topic”:“zwave/OS_Bath/OS_Bath_Fan/37/0/targetValue/set”,“qos”:“2”,“retain”:“”,“respTopic”:“”,“contentType”:“”,“userProps”:“”,“correl”:“”,“expiry”:“”,“broker”:“3f792c51bc3d4765”,“x”:1390,“y”:540,“wires”:[]},{“id”:“99582e26941011d8”,“type”:“change”,“z”:“8ef216b4818a03fb”,“name”:“Turn Off”,“rules”:[{“t”:“set”,“p”:“payload”,“pt”:“msg”,“to”:“false”,“tot”:“bool”}],“action”:“”,“property”:“”,“from”:“”,“to”:“”,“reg”:false,“x”:1220,“y”:540,“wires”:[[“238369dd863e4bda”]]},{“id”:“fb3838e9384c3e01”,“type”:“mqtt out”,“z”:“8ef216b4818a03fb”,“name”:“OS Bath Fan”,“topic”:“zwave/OS_Bath/OS_Bath_Fan/37/0/targetValue/set”,“qos”:“2”,“retain”:“”,“respTopic”:“”,“contentType”:“”,“userProps”:“”,“correl”:“”,“expiry”:“”,“broker”:“3f792c51bc3d4765”,“x”:1850,“y”:120,“wires”:[]},{“id”:“89aa3dd7b775d80d”,“type”:“change”,“z”:“8ef216b4818a03fb”,“name”:“Turn On”,“rules”:[{“t”:“set”,“p”:“payload”,“pt”:“msg”,“to”:“true”,“tot”:“bool”}],“action”:“”,“property”:“”,“from”:“”,“to”:“”,“reg”:false,“x”:1680,“y”:120,“wires”:[[“fb3838e9384c3e01”]]},{“id”:“afa6f5e306c3bdad”,“type”:“mqtt in”,“z”:“8ef216b4818a03fb”,“name”:“OS Bath Fan”,“topic”:“zwave/OS_Bath/OS_Bath_Fan/37/0/currentValue”,“qos”:“2”,“datatype”:“json”,“broker”:“3f792c51bc3d4765”,“nl”:false,“rap”:true,“rh”:“2”,“inputs”:0,“x”:110,“y”:540,“wires”:[[“dd720d3dbd873d29”]]},{“id”:“dd720d3dbd873d29”,“type”:“switch”,“z”:“8ef216b4818a03fb”,“name”:“On?”,“property”:“payload.value”,“propertyType”:“msg”,“rules”:[{“t”:“true”},{“t”:“false”}],“checkall”:“true”,“repair”:false,“outputs”:2,“x”:290,“y”:540,“wires”:[[“2c1ceb9c7799075c”],[“9f732e835e5a99db”,“7fad7857cea0770b”,“5fab948b5a4871b2”]]},{“id”:“2907cf844007a0c2”,“type”:“zigbee2mqtt-in”,“z”:“8ef216b4818a03fb”,“name”:“”,“server”:“7cb1c3849a98d34b”,“friendly_name”:“OS Spare Temp Sensor (SNZB-02)”,“device_id”:“0x00124b0022d2c8cf”,“state”:“humidity”,“outputAtStartup”:true,“filterChanges”:false,“enableMultiple”:false,“x”:160,“y”:220,“wires”:[[“36e84da8a1bd66b4”,“5bbcf51689c06918”]]},{“id”:“aec13a8372d6b533”,“type”:“comment”,“z”:“8ef216b4818a03fb”,“name”:“Set humidity increase threashold here.”,“info”:“”,“x”:850,“y”:120,“wires”:[]},{“id”:“e37cafc095c7c7a3”,“type”:“comment”,“z”:“8ef216b4818a03fb”,“name”:“Set off threashold here”,“info”:“”,“x”:1660,“y”:180,“wires”:[]},{“id”:“3a39b3f46e1e43c7”,“type”:“comment”,“z”:“8ef216b4818a03fb”,“name”:“manual timer”,“info”:“”,“x”:850,“y”:580,“wires”:[]},{“id”:“c41c1985c1d5cf8c”,“type”:“comment”,“z”:“8ef216b4818a03fb”,“name”:“max run timer”,“info”:“”,“x”:1130,“y”:680,“wires”:[]},{“id”:“f875913f7f39407a”,“type”:“comment”,“z”:“8ef216b4818a03fb”,“name”:“auto off timer”,“info”:“”,“x”:1030,“y”:460,“wires”:[]},{“id”:“7cb1c3849a98d34b”,“type”:“zigbee2mqtt-server”,“name”:“”,“host”:“10.10.2.1”,“mqtt_port”:“1883”,“mqtt_username”:“”,“mqtt_password”:“”,“mqtt_qos”:“0”,“tls”:“”,“usetls”:false,“base_topic”:“zigbee2mqtt”},{“id”:“3f792c51bc3d4765”,“type”:“mqtt-broker”,“name”:“CORE Clean1”,“broker”:“10.10.2.1”,“port”:“1883”,“clientid”:“”,“autoConnect”:true,“usetls”:false,“protocolVersion”:“5”,“keepalive”:“60”,“cleansession”:true,“birthTopic”:“”,“birthQos”:“0”,“birthPayload”:“”,“birthMsg”:{},“closeTopic”:“”,“closeQos”:“0”,“closePayload”:“”,“closeMsg”:{},“willTopic”:“”,“willQos”:“0”,“willPayload”:“”,“willMsg”:{},“userProps”:“”,“sessionExpiry”:“”}]

3 Likes