{"id":405,"date":"2017-06-02T19:43:11","date_gmt":"2017-06-02T19:43:11","guid":{"rendered":"https:\/\/test.warrensoft.co.uk\/wp-test\/home-hub\/?p=405"},"modified":"2018-12-08T07:32:17","modified_gmt":"2018-12-08T07:32:17","slug":"conditions-rules-and-actions","status":"publish","type":"post","link":"https:\/\/test.warrensoft.co.uk\/wp-test\/2017\/06\/02\/conditions-rules-and-actions\/","title":{"rendered":"Conditions, Rules and Actions"},"content":{"rendered":"<p>We need to produce discrete digital events from the analogue data generated by our sensors, in order to switch our actuators. The <em>Condition<\/em>\u00a0does this job in the hub. An example will help to illustrate.<\/p>\n<p>One of the motivations for building the home hub was to control a bathroom extractor fan; part of a condensation reduction initiative. OK I could have bought a fan with an integrated sensor, but where&#8217;s the fun in that! \u00a0I was measuring the relative humidity, so it was a simple task to check when this exceeded a threshold in order to switch the fan on, and check for going below another threshold to switch off. This Set\/Reset pattern provides hysteresis, ensuring we don&#8217;t perform unnecessary switching, and is the essence of Conditions.<\/p>\n<p>I had a number of other requirements I was hoping to satisfy in the design.<\/p>\n<ul>\n<li>A simple UI &#8211; allowing non-admins to edit conditions and thresholds<\/li>\n<li>Time clock facilities &#8211; treating the time of day like a sensor reading, allows the hub to replace a traditional central-heating programmer<\/li>\n<li>Complex Expressions &#8211; a system that could cope with multiple variables in set\/reset expressions<\/li>\n<\/ul>\n<p>The implementation has fulfilled all of these requirements.<\/p>\n<p>Returning to the bathroom fan problem, I started with the following simple expressions:<\/p>\n<p>SET: S3 &gt; 99 \u00a0 RESET: S3 &lt; 75 \u00a0 \u00a0( where S3 is bathroom R.H. )<\/p>\n<p>until the complaints from occupants arrived, &#8216;Can you switch that fan off &#8211; it&#8217;s freezing in here&#8217;. So I added temperature to the expressions:<\/p>\n<p>SET: S3 &gt; 99 \u00a0and S4 &gt; 17<\/p>\n<p>RESET: S3 &lt; 75 or S4 &lt; 16 \u00a0 \u00a0( S4 is bathroom Temperature )<\/p>\n<p>This improved the situation, but then I noticed that the fan would sometimes run for long periods. The assumption was that the replacement air was also high in moisture, so <em>Actuator Timers<\/em> were introduced. Here are the final expressions:<\/p>\n<p>SET: S3 &gt; 99 \u00a0and S4 &gt; 17 and t1 &gt; 5 \u00a0 \u00a0 \u00a0( t1 is Fan Off-Timer )<\/p>\n<p>RESET: S3 &lt; 75 or S4 &lt; 16 or T1 &gt; 15 \u00a0 \u00a0( T1 is Fan On-timer )<\/p>\n<p>The use of timers ensures the fan only runs for 15 minutes, and then pauses for 5.<\/p>\n<p>In the next post we will install the software to handle Conditions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We need to produce discrete digital events from the analogue data generated by our sensors, in order to switch our actuators. The Condition\u00a0does this job in the hub. An example will help to illustrate. One of the motivations for building the home hub was to control a bathroom extractor fan; part of a condensation reduction &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/test.warrensoft.co.uk\/wp-test\/2017\/06\/02\/conditions-rules-and-actions\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Conditions, Rules and Actions&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-405","post","type-post","status-publish","format-standard","hentry","category-hub-software"],"_links":{"self":[{"href":"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-json\/wp\/v2\/posts\/405","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-json\/wp\/v2\/comments?post=405"}],"version-history":[{"count":3,"href":"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-json\/wp\/v2\/posts\/405\/revisions"}],"predecessor-version":[{"id":428,"href":"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-json\/wp\/v2\/posts\/405\/revisions\/428"}],"wp:attachment":[{"href":"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-json\/wp\/v2\/media?parent=405"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-json\/wp\/v2\/categories?post=405"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-json\/wp\/v2\/tags?post=405"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}