<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to implement a filter algorithm]]></title><description><![CDATA[<p dir="auto">how can i implement a filtering algorithm to give me the median value from a set of sensor readings. i need this for some digital sensors which sometime give false readings - basically want to put all readings of say the last one minute in an array, sort it and then pick the median (middle value).</p>
<p dir="auto">is there an easy way to do this, any pointers will be appreciated...</p>
]]></description><link>https://forum.mango-os.com/topic/1398/how-to-implement-a-filter-algorithm</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Apr 2026 15:12:48 GMT</lastBuildDate><atom:link href="https://forum.mango-os.com/topic/1398.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 19 Sep 2013 20:03:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to implement a filter algorithm on Thu, 19 Sep 2013 21:38:17 GMT]]></title><description><![CDATA[<p dir="auto">Most of the available data is documented in the help question mark on the page. I went to the source code for the 'firstValue' attribute, which is not listed in the help document. The public repo can be seen at <a href="http://www.github.com/infiniteautomation" rel="nofollow ugc">www.github.com/infiniteautomation</a></p>
]]></description><link>https://forum.mango-os.com/post/7948</link><guid isPermaLink="true">https://forum.mango-os.com/post/7948</guid><dc:creator><![CDATA[phildunlap]]></dc:creator><pubDate>Thu, 19 Sep 2013 21:38:17 GMT</pubDate></item><item><title><![CDATA[Reply to How to implement a filter algorithm on Thu, 19 Sep 2013 21:20:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/phildunlap" aria-label="Profile: phildunlap">@<bdi>phildunlap</bdi></a> said:</p>
<blockquote>
<p dir="auto">values.push(sens.prev(MINUTE, 1).firstValue)</p>
<p dir="auto">...<br />
values.push(sens.prev(MINUTE, n).firstValue)</p>
</blockquote>
<p dir="auto">thanks, this seems exactly what i need.</p>
<p dir="auto">one other request, where do i find documentation on what you have described above e.g. prev(MINUTE,1).firstvalue - what other functions etc are there which could be used ?</p>
]]></description><link>https://forum.mango-os.com/post/7947</link><guid isPermaLink="true">https://forum.mango-os.com/post/7947</guid><dc:creator><![CDATA[sundeepgoel]]></dc:creator><pubDate>Thu, 19 Sep 2013 21:20:57 GMT</pubDate></item><item><title><![CDATA[Reply to How to implement a filter algorithm on Thu, 19 Sep 2013 21:16:41 GMT]]></title><description><![CDATA[<p dir="auto">Oh, I apologize, I misunderstood your question.</p>
<p dir="auto">So 'sens' will be our point that we want the history of.</p>
<p dir="auto">values.push(sens.prev(MINUTE, 1).firstValue)<br />
values.push(sens.prev(MINUTE, 2).firstValue)<br />
values.push(sens.prev(MINUTE, 3).firstValue)<br />
...<br />
values.push(sens.prev(MINUTE, n).firstValue)</p>
]]></description><link>https://forum.mango-os.com/post/7946</link><guid isPermaLink="true">https://forum.mango-os.com/post/7946</guid><dc:creator><![CDATA[phildunlap]]></dc:creator><pubDate>Thu, 19 Sep 2013 21:16:41 GMT</pubDate></item><item><title><![CDATA[Reply to How to implement a filter algorithm on Thu, 19 Sep 2013 20:55:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/phildunlap" aria-label="Profile: phildunlap">@<bdi>phildunlap</bdi></a> said:</p>
<blockquote>
<p dir="auto">The best way to do this is with a meta point. Write the code necessary to get all your points into an array, here's some code I stole:</p>
<pre><code>
values.push(sens1.value)
...
values.push(sensN.value)


</code></pre>
<p dir="auto">Hope that helps.</p>
</blockquote>
<p dir="auto">Thanks for the quick response, a clarification please :-</p>
<pre><code>
sens1.value 
.... 
sensN.value 

</code></pre>
<p dir="auto">wont this be value of n different points, i need to get the last n values of the <em>same point</em> into the array, how can i do that ?</p>
]]></description><link>https://forum.mango-os.com/post/7945</link><guid isPermaLink="true">https://forum.mango-os.com/post/7945</guid><dc:creator><![CDATA[sundeepgoel]]></dc:creator><pubDate>Thu, 19 Sep 2013 20:55:11 GMT</pubDate></item><item><title><![CDATA[Reply to How to implement a filter algorithm on Thu, 19 Sep 2013 20:19:00 GMT]]></title><description><![CDATA[<p dir="auto">The best way to do this is with a meta point. Write the code necessary to get all your points into an array, here's some code I stole:</p>
<pre><code>var myArr = new Array();
values.push(sens1.value)
...
values.push(sensN.value)
 
values.sort( function(a,b) {return a - b;} ); //works for our numeric values
 
var half = Math.floor(values.length/2);
 
if(values.length % 2)
   return values[half];
else
   return (values[half-1] + values[half]) / 2.0;
</code></pre>
<p dir="auto">Hope that helps.</p>
]]></description><link>https://forum.mango-os.com/post/7940</link><guid isPermaLink="true">https://forum.mango-os.com/post/7940</guid><dc:creator><![CDATA[phildunlap]]></dc:creator><pubDate>Thu, 19 Sep 2013 20:19:00 GMT</pubDate></item></channel></rss>