<?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[Temperature MIN&#x2F;MAX&#x2F;AVG]]></title><description><![CDATA[<p dir="auto">Hello,<br />
How can I get  MIN/MAX/AVG informations about temperature variable ?<br />
I see in ScriptAPI about metrics, method : getSensorVariableMetricsDouble<br />
it's the right way ?</p>
<p dir="auto">When I try this on my sensor variable :<br />
var list = mcApi.metric().getSensorVariableMetricsDouble(1,0,1479823903);<br />
list is empty <img src="http://forum.mycontroller.org/assets/plugins/nodebb-plugin-emoji/emoji/android/1f61e.png?v=2ce0f5c73bf" class="not-responsive emoji emoji-android emoji--disappointed" style="height:23px;width:auto;vertical-align:middle" title=":-(" alt="😞" /></p>
<p dir="auto">Can you help me ?<br />
Thanks</p>
]]></description><link>http://forum.mycontroller.org/topic/79/temperature-min-max-avg</link><generator>RSS for Node</generator><lastBuildDate>Wed, 11 Nov 2026 22:40:18 GMT</lastBuildDate><atom:link href="http://forum.mycontroller.org/topic/79.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 22 Nov 2016 15:29:18 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Temperature MIN&#x2F;MAX&#x2F;AVG on Wed, 23 Nov 2016 09:26:40 GMT]]></title><description><![CDATA[<p dir="auto">Wonderful !!!<br />
Option 1 works for me like a charm !</p>
<p dir="auto">Many thanks, MyController is the best <img src="http://forum.mycontroller.org/assets/plugins/nodebb-plugin-emoji/emoji/android/1f609.png?v=2ce0f5c73bf" class="not-responsive emoji emoji-android emoji--wink" style="height:23px;width:auto;vertical-align:middle" title=";)" alt="😉" /></p>
]]></description><link>http://forum.mycontroller.org/post/356</link><guid isPermaLink="true">http://forum.mycontroller.org/post/356</guid><dc:creator><![CDATA[Tetnobic]]></dc:creator><pubDate>Wed, 23 Nov 2016 09:26:40 GMT</pubDate></item><item><title><![CDATA[Reply to Temperature MIN&#x2F;MAX&#x2F;AVG on Tue, 07 Feb 2017 11:57:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tetnobic" aria-label="Profile: Tetnobic">@<bdi>Tetnobic</bdi></a> You can get it on two ways,</p>
<h5>Option 1:</h5>
<p dir="auto">Assign uidTag for your temperature variable, and use it on the script. In this method it will return single object. You will not get list.</p>
<pre><code>var myImports = new JavaImporter(java.io, java.lang, java.util, java.text);

with(myImports) {
var sVar = mcApi.uidTag().getByUid("temp-outside").getResource(); // Get sensor variable object with UidTag api
var minMaxData = mcApi.metric().getSensorVariableMetricDouble(sVar, 0,1479833863195); //(sensor-variable-object, from-timestamp, to-timestamp)
}
</code></pre>
<p dir="auto">on <code>minMaxData</code> object will be as follows,</p>
<pre><code>"minMaxData": {
    "minimum": 0,
    "average": 73.51,
    "maximum": 115.4,
    "current": 34.9,
    "previous": 34.9,
    "variable": {....}
}
</code></pre>
<h5>Option 2:</h5>
<p dir="auto">You can call list of metrics range with timestamp and bucket-duration. BucketDuration is nothing but interval between metric values.</p>
<pre><code>var myImports = new JavaImporter(java.io, java.lang, java.util, java.text);

with(myImports) {
var sVar = mcApi.uidTag().getByUid("temp-outside").getResource(); // Get sensor variable object with UidTag api
var listOfData = mcApi.metric().getMetricData(sVar.id, "Sensor variable", 1479733863195, 1479833863195, "6h", true); //(sensor-variable-id, from-timestamp, to-timestamp, bucket-duration, boolean-get-generic), here the bucket duration is 6 hours
}
</code></pre>
<p dir="auto">Output as follows,</p>
<pre><code>  "listOfData": [
    {
      "start": 1479755463195,
      "end": 1479777063195,
      "empty": false,
      "min": 40.5,
      "max": 43.3,
      "avg": 42.672998137802615,
      "samples": 537
    },
    {
      "start": 1479777063195,
      "end": 1479798663195,
      "empty": false,
      "min": 37.7,
      "max": 42.6,
      "avg": 40.97185185185186,
      "samples": 540
    },
    {
      "start": 1479798663195,
      "end": 1479820263195,
      "empty": false,
      "min": 34.9,
      "max": 38.4,
      "avg": 37.71923076923077,
      "samples": 546
    },
    {
      "start": 1479820263195,
      "end": 1479841863195,
      "empty": false,
      "min": 34.9,
      "max": 35.6,
      "avg": 34.96143617021263,
      "samples": 376
    }
  ]
</code></pre>
<p dir="auto">hope this example will help you.</p>
]]></description><link>http://forum.mycontroller.org/post/355</link><guid isPermaLink="true">http://forum.mycontroller.org/post/355</guid><dc:creator><![CDATA[jkandasa]]></dc:creator><pubDate>Tue, 07 Feb 2017 11:57:58 GMT</pubDate></item></channel></rss>