{"id":1876,"date":"2015-02-16T00:00:48","date_gmt":"2015-02-16T08:00:48","guid":{"rendered":"http:\/\/192.168.3.4\/?p=1876"},"modified":"2018-01-09T06:49:49","modified_gmt":"2018-01-09T14:49:49","slug":"snmp-heater","status":"publish","type":"post","link":"https:\/\/www.cloudacm.com\/?p=1876","title":{"rendered":"SNMP Heater"},"content":{"rendered":"<p><strong>Introduction &#8211; a practical need<\/strong><\/p>\n<p>I want to automate the task of changing when my house heater turns on or off.\u00a0 You&#8217;re probably thinking, use a thermostat.\u00a0 That works with conventional forced air heating.\u00a0 We use radiant floor heating that is from the hot water supply for the home.\u00a0 There is a wider hysteresis.\u00a0 It&#8217;s more likely the warmth effects will last longer after the conventional thermostat triggers off.\u00a0 This is also the case when it needs to heat the room.<\/p>\n<p>So I decided to use a sensing network that consists of a SNMP device and several temperature sensors.\u00a0 I am able to poll the readings from the device and execute commands.\u00a0 The heater is controlled by a flow pump.\u00a0 The power supply to the flow pump is controlled by a relay that has a web interface.\u00a0 I can change the relay state by sending web commands.<\/p>\n<p>This is more of a novelty than a topic I want to formally cover this quarter.\u00a0 However, I think it is worth making note of since it can lend insight.\u00a0 Years ago I had done this using Windows and Task Scheduler.\u00a0 It was messy and very confusing.<\/p>\n<p><strong>Details &#8211; how it was possible<\/strong><\/p>\n<p>Now I do this using Linix and this shell script.<\/p>\n<pre>\r\n<code>\r\n#!\/bin\/bash\r\n# this runs every 30 minutes \r\n\r\n# get the reading from the sensor and overwrite it to a file\r\nsnmpget -v 1 -c public 192.168.0.200 .1.3.6.1.4.1.17373.2.4.1.5.2 &gt; FrontGable.txt\r\n# gives back iso.3.6.1.4.1.17373.2.4.1.5.2 = INTEGER: 6\r\n\r\n# write file contents to a variable\r\nFGRead=$(&lt;FrontGable.txt)\r\n\r\n# parse out everything after the colon character :\r\nFGValue=${FGRead#*:}\r\n\r\n# turn over temp relay on or off based on reading of greater than 13\r\nif [ $FGValue -gt 13 ]\r\nthen\r\n  # turns on the overtemp relay\r\n  wget http:\/\/192.168.0.100\/state.xml?relayState=1\r\nelse\r\n  # turns off the overtemp relay\r\n  wget http:\/\/192.168.0.100\/state.xml?relayState=0\r\nfi\r\n\r\n# house cleaning \r\nrm -f FrontGable.txt\r\nrm -f state.xml?relayState=0\r\nrm -f state.xml?relayState=1\r\n<\/code>\r\n<\/pre>\n<p>I setup the CRON job in Webmin.\u00a0 It does the trick.\u00a0 When the temperature outside gets above 54\u00b0 Fahrenheit, the heat is shut off.\u00a0 I have other conditions outside of this that control the heat as well.\u00a0 But I wanted to make mention here.\u00a0 The parse command is something I found interesting.\u00a0 I can see this being put to use in later work.<\/p>\n<p><strong>Summary &#8211; what just happened<\/strong><\/p>\n<p>There were a few elements that made this work. \u00a0First was the Linux box that ran all the commands centrally. \u00a0Next was the\u00a0SNMP device that gave temperature values when it was polled. \u00a0Then were the web enabled relays the changed state based on page requests. \u00a0Based on the outside temperature value, the relay is turned on or off. \u00a0That&#8217;s it.<\/p>\n<p>I found a way to parse values out of a string in shell. \u00a0I also used conditional if\/else statements to run commands based on the variable. \u00a0Enjoy.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction &#8211; a practical need I want to automate the task of changing when my house heater turns on or off.\u00a0 You&#8217;re probably thinking, use a thermostat.\u00a0 That works with conventional forced air heating.\u00a0 We use radiant floor heating that is from the hot water supply for the home.\u00a0 There is a wider hysteresis.\u00a0 It&#8217;s more likely the warmth effects will last longer after the conventional thermostat triggers off.\u00a0 This is also the case when it needs to heat the&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.cloudacm.com\/?p=1876\"> Read More<span class=\"screen-reader-text\">  Read More<\/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":[10,3],"tags":[],"class_list":["post-1876","post","type-post","status-publish","format-standard","hentry","category-data-mining","category-rd"],"_links":{"self":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts\/1876","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1876"}],"version-history":[{"count":7,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts\/1876\/revisions"}],"predecessor-version":[{"id":1880,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts\/1876\/revisions\/1880"}],"wp:attachment":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1876"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1876"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1876"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}