<?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[Examples of advanced control rules]]></title><description><![CDATA[<p dir="auto">Hi, I am delving into a challenge of controlling the humidity in a room, the algorithm for that is quite complicated, meaning:</p>
<ol>
<li>Wait 15 minutes, and measure humidity, when its stable, start the fan</li>
<li>Run fan for max 10 minutes and measure humidity while doing it, if falling humidity (until a threshold) keep running</li>
<li>Repeat 1-2 until there is no falling humidity.</li>
<li>Keep monitoring humidty every few minutes, and when over threshold, start with 1.</li>
</ol>
<p dir="auto">Can you guide me to documentation for scripting this stuff....</p>
]]></description><link>http://forum.mycontroller.org/topic/118/examples-of-advanced-control-rules</link><generator>RSS for Node</generator><lastBuildDate>Wed, 16 Sep 2026 06:51:32 GMT</lastBuildDate><atom:link href="http://forum.mycontroller.org/topic/118.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 07 Feb 2017 18:02:06 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Examples of advanced control rules on Fri, 19 May 2017 14:02:27 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/goranrad" aria-label="Profile: goranrad">@<bdi>goranrad</bdi></a> JavaScript,</p>
<pre><code class="language-javascript">var myImports = new JavaImporter(java.lang, java.util);

with(myImports) {
  var humidity_threshold = 78.4;
  var on_time = 10; // seconds
  humidity = mcApi.uidTag().getByUid("uid-humidity").getResource();
  humidifier = mcApi.uidTag().getByUid("uid-humidifier").getResource();

  if(parseFloat(humidity.value) &lt; humidity_threshold){
    humidifier.value = "1";
    mcApi.sensor().sendPayload(humidifier); // sensd state
    Thread.sleep(on_time * 1000);
    humidifier.value = "0";
    mcApi.sensor().sendPayload(humidifier); // sensd state
  }
}

</code></pre>
]]></description><link>http://forum.mycontroller.org/post/953</link><guid isPermaLink="true">http://forum.mycontroller.org/post/953</guid><dc:creator><![CDATA[jkandasa]]></dc:creator><pubDate>Fri, 19 May 2017 14:02:27 GMT</pubDate></item><item><title><![CDATA[Reply to Examples of advanced control rules on Wed, 17 May 2017 21:13:44 GMT]]></title><description><![CDATA[<p dir="auto">Hi J,<br />
I did the update and the python script worked like a charm.<br />
If you have time pleas post the JavaScript  version.</p>
<p dir="auto">Thank you!</p>
]]></description><link>http://forum.mycontroller.org/post/952</link><guid isPermaLink="true">http://forum.mycontroller.org/post/952</guid><dc:creator><![CDATA[goranrad]]></dc:creator><pubDate>Wed, 17 May 2017 21:13:44 GMT</pubDate></item><item><title><![CDATA[Reply to Examples of advanced control rules on Wed, 17 May 2017 16:43:25 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/goranrad" aria-label="Profile: goranrad">@<bdi>goranrad</bdi></a> You should use latest SNAPSHOT version from here: <a href="http://forum.mycontroller.org/topic/58/download-snapshot-build">http://forum.mycontroller.org/topic/58/download-snapshot-build</a> and these resources should have value.</p>
<p dir="auto">I will convert this script to JavaScript by tomorrow and post here.</p>
]]></description><link>http://forum.mycontroller.org/post/951</link><guid isPermaLink="true">http://forum.mycontroller.org/post/951</guid><dc:creator><![CDATA[jkandasa]]></dc:creator><pubDate>Wed, 17 May 2017 16:43:25 GMT</pubDate></item><item><title><![CDATA[Reply to Examples of advanced control rules on Wed, 17 May 2017 14:40:06 GMT]]></title><description><![CDATA[<p dir="auto">Hi, I have python installed and have created UDI tags,<br />
<img src="/uploads/files/1495031704842-python.png" alt="0_1495031706178_python.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">and the UDIs are there<br />
<img src="/uploads/files/1495031738504-udi.png" alt="0_1495031740468_udi.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Reason I use Python is because its the language I'm most comfortable with. But i'll do as you say if you pleas can convert the code to JavaScript to get me started.</p>
<p dir="auto">Much appreciated.<br />
/goran</p>
]]></description><link>http://forum.mycontroller.org/post/950</link><guid isPermaLink="true">http://forum.mycontroller.org/post/950</guid><dc:creator><![CDATA[goranrad]]></dc:creator><pubDate>Wed, 17 May 2017 14:40:06 GMT</pubDate></item><item><title><![CDATA[Reply to Examples of advanced control rules on Wed, 17 May 2017 12:45:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/goranrad" aria-label="Profile: goranrad">@<bdi>goranrad</bdi></a><br />
The error looks like, you do not create UID-Tag as follows,</p>
<p dir="auto"><img src="/uploads/files/1495025134002-upload-be870e3c-7d60-4786-a4cc-ef5b5b651505" alt="0_1495025133044_upload-be870e3c-7d60-4786-a4cc-ef5b5b651505" class=" img-fluid img-markdown" /></p>
<p dir="auto">Do you have installed python script engine? By default, MyController does not have python script engine as it is eating more resource. I would recommend going with <code>JavaScript</code>(built-in, lightweight).</p>
<p dir="auto">Refer <a href="http://forum.mycontroller.org/topic/44/question-example-script-like-operation-send-mail/2">this link</a> to install python script engine support.</p>
<p dir="auto">If you want, I can convert this script to <code>JavaScript</code></p>
]]></description><link>http://forum.mycontroller.org/post/949</link><guid isPermaLink="true">http://forum.mycontroller.org/post/949</guid><dc:creator><![CDATA[jkandasa]]></dc:creator><pubDate>Wed, 17 May 2017 12:45:38 GMT</pubDate></item><item><title><![CDATA[Reply to Examples of advanced control rules on Tue, 16 May 2017 18:59:14 GMT]]></title><description><![CDATA[<p dir="auto">Hi again,</p>
<p dir="auto">Sorry to disturb but I get the following error when i try to manually run the script.</p>
<p dir="auto">{<br />
"errorMessage": "AttributeError: 'org.mycontroller.standalone.db.tables.UidTag' object has no attribute 'getResource' in &lt;script&gt; at line number 3"<br />
}</p>
<p dir="auto">Sure I don't have to import mcAPI to python or something?</p>
<p dir="auto">I have created the UDItags</p>
<p dir="auto">Regards<br />
Goran</p>
]]></description><link>http://forum.mycontroller.org/post/948</link><guid isPermaLink="true">http://forum.mycontroller.org/post/948</guid><dc:creator><![CDATA[goranrad]]></dc:creator><pubDate>Tue, 16 May 2017 18:59:14 GMT</pubDate></item><item><title><![CDATA[Reply to Examples of advanced control rules on Tue, 16 May 2017 18:12:48 GMT]]></title><description><![CDATA[<p dir="auto">Thank you !</p>
]]></description><link>http://forum.mycontroller.org/post/947</link><guid isPermaLink="true">http://forum.mycontroller.org/post/947</guid><dc:creator><![CDATA[goranrad]]></dc:creator><pubDate>Tue, 16 May 2017 18:12:48 GMT</pubDate></item><item><title><![CDATA[Reply to Examples of advanced control rules on Tue, 16 May 2017 03:04:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/goranrad" aria-label="Profile: goranrad">@<bdi>goranrad</bdi></a> For this kind of work <code>execute the script with timer</code> suits perfectly. Use the following script to control your humidity-controller. you can use the following script as an <code>operation</code> type (NOT condition type) and configure a timer to execute this script for every 40 seconds once.</p>
<p dir="auto"><strong>Note:</strong> do not forget to create UID tags for humidity and humidifier. <img src="http://forum.mycontroller.org/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=2ce0f5c73bf" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
<pre><code class="language-python">import time

humidity = mcApi.uidTag().getByUid("uid-humidity").getResource();
humidifier = mcApi.uidTag().getByUid("uid-humidifier").getResource();

humidity_threshold = 78.4
on_time = 10 # seconds

if(float(humidity.value) &lt; humidity_threshold):
  humidifier.value = "1";
  mcApi.sensor().sendPayload(humidifier); # sensd state
  time.sleep(on_time)
  humidifier.value = "0";
  mcApi.sensor().sendPayload(humidifier); # sensd state
</code></pre>
<p dir="auto"><img src="/uploads/files/1494903774775-humidity-controller.png" alt="0_1494903771553_humidity-controller.png" class=" img-fluid img-markdown" /></p>
]]></description><link>http://forum.mycontroller.org/post/946</link><guid isPermaLink="true">http://forum.mycontroller.org/post/946</guid><dc:creator><![CDATA[jkandasa]]></dc:creator><pubDate>Tue, 16 May 2017 03:04:59 GMT</pubDate></item><item><title><![CDATA[Reply to Examples of advanced control rules on Mon, 15 May 2017 15:37:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/blacksheepinc" aria-label="Profile: blacksheepinc">@<bdi>blacksheepinc</bdi></a> No, I never tried Domoticz. Let me have a look. thank you</p>
]]></description><link>http://forum.mycontroller.org/post/945</link><guid isPermaLink="true">http://forum.mycontroller.org/post/945</guid><dc:creator><![CDATA[jkandasa]]></dc:creator><pubDate>Mon, 15 May 2017 15:37:09 GMT</pubDate></item><item><title><![CDATA[Reply to Examples of advanced control rules on Mon, 15 May 2017 14:00:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jkandasa" aria-label="Profile: jkandasa">@<bdi>jkandasa</bdi></a> I think in these cases blockly would be very useful.<br />
Have you tried Domoticz before? It has blockly, and making the above mentioned algorithems with it are such an easy job.</p>
]]></description><link>http://forum.mycontroller.org/post/942</link><guid isPermaLink="true">http://forum.mycontroller.org/post/942</guid><dc:creator><![CDATA[blacksheepinc]]></dc:creator><pubDate>Mon, 15 May 2017 14:00:19 GMT</pubDate></item><item><title><![CDATA[Reply to Examples of advanced control rules on Mon, 15 May 2017 08:14:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/goranrad" aria-label="Profile: goranrad">@<bdi>goranrad</bdi></a> I will come up with a script shortly.</p>
]]></description><link>http://forum.mycontroller.org/post/940</link><guid isPermaLink="true">http://forum.mycontroller.org/post/940</guid><dc:creator><![CDATA[jkandasa]]></dc:creator><pubDate>Mon, 15 May 2017 08:14:44 GMT</pubDate></item><item><title><![CDATA[Reply to Examples of advanced control rules on Sun, 14 May 2017 09:25:00 GMT]]></title><description><![CDATA[<p dir="auto">Hi, what I want is when the humidity (humidity sensor value) is under a level to have my humidifier (relay) to switch on for 10 sec then switch of for 30 sec until  the humidity have reached  its threshold.</p>
<p dir="auto">Think I have to use two UDItag for humidity sensor and relay state.<br />
Then use one variable with two keys. on time and off time.</p>
<p dir="auto">Humidity control in a greenhouse is difficult that's  why i want to use variables to easily be able to adjust on and off intervals.</p>
<p dir="auto">Kindest regards<br />
Goran</p>
]]></description><link>http://forum.mycontroller.org/post/935</link><guid isPermaLink="true">http://forum.mycontroller.org/post/935</guid><dc:creator><![CDATA[goranrad]]></dc:creator><pubDate>Sun, 14 May 2017 09:25:00 GMT</pubDate></item><item><title><![CDATA[Reply to Examples of advanced control rules on Sun, 14 May 2017 08:53:37 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/goranrad" aria-label="Profile: goranrad">@<bdi>goranrad</bdi></a> can you elaborate more about steps you want in script?</p>
]]></description><link>http://forum.mycontroller.org/post/932</link><guid isPermaLink="true">http://forum.mycontroller.org/post/932</guid><dc:creator><![CDATA[jkandasa]]></dc:creator><pubDate>Sun, 14 May 2017 08:53:37 GMT</pubDate></item><item><title><![CDATA[Reply to Examples of advanced control rules on Sat, 13 May 2017 11:17:45 GMT]]></title><description><![CDATA[<p dir="auto">I'm struggling with humidity in my greenhouse as well. Please help me with a python compare script example that reads a sensor value and a sensor state, then evaluates them and returns true or false. To be used as a compare script for a rule.</p>
<p dir="auto">Regards<br />
Goran</p>
]]></description><link>http://forum.mycontroller.org/post/930</link><guid isPermaLink="true">http://forum.mycontroller.org/post/930</guid><dc:creator><![CDATA[goranrad]]></dc:creator><pubDate>Sat, 13 May 2017 11:17:45 GMT</pubDate></item><item><title><![CDATA[Reply to Examples of advanced control rules on Mon, 13 Feb 2017 16:23:07 GMT]]></title><description><![CDATA[<p dir="auto">I will try that, but was primarily looking for examples of scripts doing more advanced control stuff...</p>
]]></description><link>http://forum.mycontroller.org/post/664</link><guid isPermaLink="true">http://forum.mycontroller.org/post/664</guid><dc:creator><![CDATA[njbuch]]></dc:creator><pubDate>Mon, 13 Feb 2017 16:23:07 GMT</pubDate></item><item><title><![CDATA[Reply to Examples of advanced control rules on Mon, 13 Feb 2017 11:44:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/njbuch" aria-label="Profile: njbuch">@<bdi>njbuch</bdi></a> can you elaborate the requirement bit more? if can give pseudo code I can address it easily.</p>
]]></description><link>http://forum.mycontroller.org/post/662</link><guid isPermaLink="true">http://forum.mycontroller.org/post/662</guid><dc:creator><![CDATA[jkandasa]]></dc:creator><pubDate>Mon, 13 Feb 2017 11:44:53 GMT</pubDate></item></channel></rss>