{"id":346,"date":"2017-05-27T16:32:50","date_gmt":"2017-05-27T16:32:50","guid":{"rendered":"https:\/\/test.warrensoft.co.uk\/wp-test\/home-hub\/?p=346"},"modified":"2018-12-08T07:32:18","modified_gmt":"2018-12-08T07:32:18","slug":"sampling-and-comparison-graphs","status":"publish","type":"post","link":"https:\/\/test.warrensoft.co.uk\/wp-test\/2017\/05\/27\/sampling-and-comparison-graphs\/","title":{"rendered":"Sampling and Comparison Graphs"},"content":{"rendered":"<p>A graph of our sensor values changing over time is the most effective way to understand what is happening in the home environment. We need 2 new controller files: <a href=\"http:\/\/www.warrensoft.co.uk\/home-hub\/code\/controller\/sampler.py\" target=\"_blank\" rel=\"noopener noreferrer\">sampler.py<\/a> and <a href=\"http:\/\/www.warrensoft.co.uk\/home-hub\/code\/controller\/sampler_helpers.py\" target=\"_blank\" rel=\"noopener noreferrer\">sampler_helpers.py<\/a><\/p>\n<pre>wget -nH -x --cut-dirs=3 -P \/usr\/local\/bin\/code\/controller\/ -i \/usr\/local\/bin\/code\/controller\/manifest2.txt http:\/\/www.warrensoft.co.uk\/home-hub\/manifests\/controller\/manifest2.txt<\/pre>\n<p>Edit existing main_sched.py and uncomment the sampler import on line 27 and the call to process_samples on line 194. Restart the controller.<\/p>\n<p>Edit your sensors and set the Sample Type to <em>Raw<\/em>. Raw is the only sample mode currently implemented, which just records the current value, but future options might include smoothing or prediction.<\/p>\n<p>Fetch the files for the website&#8230;<\/p>\n<pre>wget -nH --cut-dirs=4 --reject \"index.html*\" -P \/var\/www\/html\/ -i \/var\/www\/html\/manifest4.txt http:\/\/www.warrensoft.co.uk\/home-hub\/manifests\/website\/manifest4.txt<\/pre>\n<p><a href=\"http:\/\/www.warrensoft.co.uk\/home-hub\/code\/website\/html\/comparisonGraphs.php\" target=\"_blank\" rel=\"noopener noreferrer\">comparisonGraphs<\/a> groups sensors by measurand, and draws a graph for each group.<\/p>\n<p><a href=\"http:\/\/www.warrensoft.co.uk\/home-hub\/code\/website\/html\/getComparisonChartData.php\" target=\"_blank\" rel=\"noopener noreferrer\">getComparisonChartData<\/a> is responsible for supplying the data in the form of a \u00a0<a href=\"http:\/\/home-hub\/getComparisonChartData.php?meas=1&amp;timebasehrs=1\" target=\"_blank\" rel=\"noopener noreferrer\">json table<\/a><\/p>\n<p>Checkout the documentation and examples at\u00a0<a href=\"https:\/\/developers.google.com\/chart\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/developers.google.com\/chart\/<\/a> for more information.<\/p>\n<p>If everything is working you should now be seeing some graphs when you select Comparison Graphs on \u00a0the website!<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-366\" src=\"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-content\/uploads\/2017\/05\/ComparisonGraphExample-300x282.png\" alt=\"\" width=\"300\" height=\"282\" srcset=\"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-content\/uploads\/2017\/05\/ComparisonGraphExample-300x282.png 300w, https:\/\/test.warrensoft.co.uk\/wp-test\/wp-content\/uploads\/2017\/05\/ComparisonGraphExample.png 692w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>A few features to note with graphs:<\/p>\n<p style=\"padding-left: 30px;\">1. \u00a0You can hover over a trace to pop-up a box showing the value at that time<\/p>\n<p style=\"padding-left: 30px;\">2. You can click the time-base axis and cycle through various time-spans. \u00a0 The default is 24 hours, and the longest is 96 hours<\/p>\n<p style=\"padding-left: 30px;\">3. Graphs auto-refresh.<\/p>\n<p>To prevent the database from growing too big there is a main_sched task that truncates samples. This will become available when we implement the monitor module later.<\/p>\n<p>In the next post we will add an actuator so we can control some plant.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A graph of our sensor values changing over time is the most effective way to understand what is happening in the home environment. We need 2 new controller files: sampler.py and sampler_helpers.py wget -nH -x &#8211;cut-dirs=3 -P \/usr\/local\/bin\/code\/controller\/ -i \/usr\/local\/bin\/code\/controller\/manifest2.txt http:\/\/www.warrensoft.co.uk\/home-hub\/manifests\/controller\/manifest2.txt Edit existing main_sched.py and uncomment the sampler import on line 27 and the call &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/test.warrensoft.co.uk\/wp-test\/2017\/05\/27\/sampling-and-comparison-graphs\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Sampling and Comparison Graphs&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-346","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\/346","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=346"}],"version-history":[{"count":21,"href":"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-json\/wp\/v2\/posts\/346\/revisions"}],"predecessor-version":[{"id":695,"href":"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-json\/wp\/v2\/posts\/346\/revisions\/695"}],"wp:attachment":[{"href":"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-json\/wp\/v2\/media?parent=346"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-json\/wp\/v2\/categories?post=346"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-json\/wp\/v2\/tags?post=346"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}