Logic controlling ventilation

So I need to build a logic controlling my ventilation system. I got three sensors which give me values for co2, moist bathroom1 and moist bathroom2. If one of them get over a certain value they have to trigger the boost function. That is the easy part I think. But the tricky part? is when they all three falls under a certain value at the same time, they have to trigger "home mode". As I have a limit for messages sending to the system, I only want the message to be sent when all three of them reach the correct values, and not to be triggered again before one of the values has been over and then drops again.

So ...
if co2 > 1000 && moist1 > 49 && moist2 > 49
then set home mode.

Have a look at the node-red-contrib-boolean-logic-ultimate (node) - Node-RED

these enable you to take a number of inputs and only output when all of them are in a certain state - you do not say where you are sourcing the messages or how they are received in NR - You can also put this inline with a trigger node that will only pass on messages is the output of the boolean node changes

Craig

It is possible using just core nodes and a context variable, perhaps a bit complicated.

[{"id":"9372feccca70ce91","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"7d8489a9bb3fb1d9","type":"group","z":"9372feccca70ce91","name":"All 3 low? Block repeated msgs","style":{"label":true},"nodes":["502a41b7c6557cf5","9a74eada3cba043e","8aca6b903a018e5f","7d81b493f07e6d57","c1ec7c1ac537695f","7a41ad4ecff98e4c"],"x":714,"y":199,"w":292,"h":282},{"id":"788fde8a42751e04","type":"group","z":"9372feccca70ce91","name":"Ay one too high, boost","style":{"label":true},"nodes":["43a5d710b1d3ba53","cdc014b3a00b2424","e73e81ec375c3fb4"],"x":714,"y":19,"w":232,"h":162},{"id":"a17e31e73a7f6ecc","type":"inject","z":"9372feccca70ce91","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"co2","payload":"900","payloadType":"num","x":90,"y":160,"wires":[["d918c091f46d039c"]]},{"id":"67137d3d351df9d2","type":"inject","z":"9372feccca70ce91","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"co2","payload":"2000","payloadType":"num","x":100,"y":120,"wires":[["d918c091f46d039c"]]},{"id":"ba918071bec31272","type":"inject","z":"9372feccca70ce91","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"bath1","payload":"40","payloadType":"num","x":100,"y":280,"wires":[["88f76358b8078cfc"]]},{"id":"71d1d7543f1d903b","type":"inject","z":"9372feccca70ce91","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"bath1","payload":"80","payloadType":"num","x":100,"y":240,"wires":[["88f76358b8078cfc"]]},{"id":"4c9a55250d152a96","type":"inject","z":"9372feccca70ce91","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"bath2","payload":"40","payloadType":"num","x":100,"y":400,"wires":[["ef78edf534d39a0d"]]},{"id":"ed51b51f704e3a4f","type":"inject","z":"9372feccca70ce91","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"bath2","payload":"80","payloadType":"num","x":100,"y":360,"wires":[["ef78edf534d39a0d"]]},{"id":"d918c091f46d039c","type":"switch","z":"9372feccca70ce91","name":"co2 high/low?","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"1500","vt":"num"},{"t":"lt","v":"1000","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":280,"y":140,"wires":[["0a9328c22b3cfecb"],["6dfd665ded7d0f72"],["c9066ec3e1b1a868"]]},{"id":"0a9328c22b3cfecb","type":"change","z":"9372feccca70ce91","name":"Set flow.status.co2 boost","rules":[{"t":"set","p":"status.co2","pt":"flow","to":"boost","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":100,"wires":[["43a5d710b1d3ba53"]]},{"id":"6dfd665ded7d0f72","type":"change","z":"9372feccca70ce91","name":"Set flow.status.co2 home","rules":[{"t":"set","p":"status.co2","pt":"flow","to":"home","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":140,"wires":[["502a41b7c6557cf5"]]},{"id":"c9066ec3e1b1a868","type":"change","z":"9372feccca70ce91","name":"Set flow.status.co2 neither","rules":[{"t":"set","p":"status.co2","pt":"flow","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":180,"wires":[["502a41b7c6557cf5"]]},{"id":"43a5d710b1d3ba53","type":"debug","z":"9372feccca70ce91","g":"788fde8a42751e04","name":"CO2 BOOST","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":60,"wires":[]},{"id":"88f76358b8078cfc","type":"switch","z":"9372feccca70ce91","name":"bath1 high/low?","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"75","vt":"num"},{"t":"lt","v":"49","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":280,"y":260,"wires":[["01dbc4cfb167617b"],["0be728507f3603a2"],["3222019e0e9d5b5f"]]},{"id":"01dbc4cfb167617b","type":"change","z":"9372feccca70ce91","name":"Set flow.status.bath1 boost","rules":[{"t":"set","p":"status.bath1","pt":"flow","to":"boost","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":220,"wires":[["cdc014b3a00b2424"]]},{"id":"0be728507f3603a2","type":"change","z":"9372feccca70ce91","name":"Set flow.status.bath1 home","rules":[{"t":"set","p":"status.bath1","pt":"flow","to":"home","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":260,"wires":[["502a41b7c6557cf5"]]},{"id":"3222019e0e9d5b5f","type":"change","z":"9372feccca70ce91","name":"Set flow.status.bath1 neither","rules":[{"t":"set","p":"status.bath1","pt":"flow","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":300,"wires":[["502a41b7c6557cf5"]]},{"id":"cdc014b3a00b2424","type":"debug","z":"9372feccca70ce91","g":"788fde8a42751e04","name":"BATH1 BOOST","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":820,"y":100,"wires":[]},{"id":"ef78edf534d39a0d","type":"switch","z":"9372feccca70ce91","name":"bath2 high/low?","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"75","vt":"num"},{"t":"lt","v":"49","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":280,"y":380,"wires":[["2f0596be985b7b6b"],["32c916cdacb25f50"],["f222505006bafce9"]]},{"id":"2f0596be985b7b6b","type":"change","z":"9372feccca70ce91","name":"Set flow.status.bath2 boost","rules":[{"t":"set","p":"status.bath2","pt":"flow","to":"boost","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":340,"wires":[["e73e81ec375c3fb4"]]},{"id":"32c916cdacb25f50","type":"change","z":"9372feccca70ce91","name":"Set flow.status.bath2 home","rules":[{"t":"set","p":"status.bath2","pt":"flow","to":"home","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":380,"wires":[["502a41b7c6557cf5"]]},{"id":"f222505006bafce9","type":"change","z":"9372feccca70ce91","name":"Set flow.status.bath2 neither","rules":[{"t":"set","p":"status.bath2","pt":"flow","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":420,"wires":[["502a41b7c6557cf5"]]},{"id":"e73e81ec375c3fb4","type":"debug","z":"9372feccca70ce91","g":"788fde8a42751e04","name":"BATH1 BOOST","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":820,"y":140,"wires":[]},{"id":"502a41b7c6557cf5","type":"switch","z":"9372feccca70ce91","g":"7d8489a9bb3fb1d9","name":"flow.status.co2 == home?","property":"status.co2","propertyType":"flow","rules":[{"t":"eq","v":"home","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":850,"y":240,"wires":[["9a74eada3cba043e"]]},{"id":"9a74eada3cba043e","type":"switch","z":"9372feccca70ce91","g":"7d8489a9bb3fb1d9","name":"flow.status.bath1 == home?","property":"status.bath1","propertyType":"flow","rules":[{"t":"eq","v":"home","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":860,"y":280,"wires":[["8aca6b903a018e5f"]]},{"id":"8aca6b903a018e5f","type":"switch","z":"9372feccca70ce91","g":"7d8489a9bb3fb1d9","name":"flow.status.bath2 == home?","property":"status.bath2","propertyType":"flow","rules":[{"t":"eq","v":"home","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":860,"y":320,"wires":[["c1ec7c1ac537695f"]]},{"id":"7d81b493f07e6d57","type":"debug","z":"9372feccca70ce91","g":"7d8489a9bb3fb1d9","name":"HOME","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":790,"y":440,"wires":[]},{"id":"c1ec7c1ac537695f","type":"change","z":"9372feccca70ce91","g":"7d8489a9bb3fb1d9","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"status","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":360,"wires":[["7a41ad4ecff98e4c"]]},{"id":"7a41ad4ecff98e4c","type":"rbe","z":"9372feccca70ce91","g":"7d8489a9bb3fb1d9","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":790,"y":400,"wires":[["7d81b493f07e6d57"]]}]

I have had a look on the ultimate boolean logic node. But I was more thinking in a solution closer to the one jbudd have suggested here. I have already started building it, so I am going to test this one.

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