<?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[Sunrize sunset forward]]></title><description><![CDATA[<p dir="auto">Hi,<br />
First, thank you for <a href="http://mycontroler.org" rel="nofollow ugc">mycontroler.org</a>. It is a great controler for mySensors.<br />
I'd like to send the sunrize and sunset time to one of my node which display some data on a LED matrix chain i have. The sending and receiving data is working great via forward payload rules. I already receive data from my other sensors. So this part is ok.<br />
I just don't know how to get the sunrize and sunset information which are already on the dashboard. I assume that it can be done with a script, but i have no idea how to get the data.<br />
Could anyone point me to a direction for my research ?<br />
Thanks</p>
]]></description><link>http://forum.mycontroller.org/topic/86/sunrize-sunset-forward</link><generator>RSS for Node</generator><lastBuildDate>Fri, 15 May 2026 02:25:20 GMT</lastBuildDate><atom:link href="http://forum.mycontroller.org/topic/86.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 08 Dec 2016 23:44:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Sunrize sunset forward on Tue, 10 Jan 2017 14:22:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/adulovic" aria-label="Profile: adulovic">@<bdi>adulovic</bdi></a><br />
Hi,<br />
As jkandasa said, you should probably download the last SNAPSHOT version again. Your error message seems to be because you don't have the SNAPSHOT with his modification.<br />
As for the step-by-step i can try to explain the way i did it:</p>
<ul>
<li>First, i'm using a Raspberry Pi Zero for the controller with an up-to-date Raspbian distro.</li>
<li>I have the last 0.0.3.Final-SNAPSHOT of <a href="http://MyController.org" rel="nofollow ugc">MyController.org</a>(at least the one from 24 days ago with jkandasa's modification).</li>
<li>I'm using the 2.0.0 version of MySensors (soon to be updated to the last version).</li>
<li>On <a href="http://MyControler.org" rel="nofollow ugc">MyControler.org</a> i created 2 UID tags (sunrize and sunset) which point to 2 dummy sensors (child of a MySensors node).</li>
<li>Then i have the java script which send the sunrize and sunset value to this UID tags:</li>
</ul>
<pre><code class="language-javascript">var myImports = new JavaImporter(java.io, java.lang, java.util);

with(myImports) {
  //Get Sunrise/Sunset details
  var locSettings = mcApi.utils().getServerLocationSettings();

  //Get sensor variables for sunrise and sunset
  var sensorSunRise = mcApi.uidTag().getByUid("sunrize").getSensorVariable();
  var sensorSunSet = mcApi.uidTag().getByUid("sunset").getSensorVariable();

  //Update timezone offset values (by default gives GMT timestamp values)
  //sensorSunRise.value = locSettings.sunriseTime + locSettings.timezoneOffset;
  //sensorSunSet.value = locSettings.sunsetTime + locSettings.timezoneOffset;

  var dtr = new Date(locSettings.sunriseTime);
  sensorSunRise.value = dtr.getHours() + ':' + dtr.getMinutes();

  var dts = new Date(locSettings.sunsetTime);
  sensorSunSet.value = dts.getHours() + ':' + dts.getMinutes();

  //Send/Update thise sensorvariable with updated value
  mcApi.sensor().sendPayload(sensorSunRise);
  mcApi.sensor().sendPayload(sensorSunSet);
}
</code></pre>
<ul>
<li>On <a href="http://MyControler.org" rel="nofollow ugc">MyControler.org</a> i created an Operation to execute the java script</li>
<li>and a Timer to start the Operation before Sunrize every day.</li>
</ul>
<p dir="auto">For your java script you just need to add an if statement comparing the sunrize and sunset values with the current time, and you should be good.</p>
]]></description><link>http://forum.mycontroller.org/post/530</link><guid isPermaLink="true">http://forum.mycontroller.org/post/530</guid><dc:creator><![CDATA[loic13]]></dc:creator><pubDate>Tue, 10 Jan 2017 14:22:39 GMT</pubDate></item><item><title><![CDATA[Reply to Sunrize sunset forward on Mon, 09 Jan 2017 18:36:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/adulovic" aria-label="Profile: adulovic">@<bdi>adulovic</bdi></a></p>
<blockquote>
<p dir="auto">I tried following the instructions on this post in order to create rules that would allow the payload forwarding only between sunset and sunrise time, but am stuck at the javascript portion, as it gives me an error when I try to run the script: "errorMessage": "TypeError: mcApi.utils().getServerLocationSettings is not a function in &lt;eval&gt; at line number 6".</p>
</blockquote>
<p dir="auto">SNAPSHOT version changes very often, can you give a try on latest one?</p>
]]></description><link>http://forum.mycontroller.org/post/522</link><guid isPermaLink="true">http://forum.mycontroller.org/post/522</guid><dc:creator><![CDATA[jkandasa]]></dc:creator><pubDate>Mon, 09 Jan 2017 18:36:32 GMT</pubDate></item><item><title><![CDATA[Reply to Sunrize sunset forward on Fri, 06 Jan 2017 19:03:47 GMT]]></title><description><![CDATA[<p dir="auto">Hi,<br />
I am attempting to use a relay and a PIR switch to turn on the lights when someone approaches the door.<br />
So far, I got it working fine, and I'm using a simple 'Forward Payload' but I now I am looking for a way to have it trigger only at night.<br />
Ideally, this should be done through the controller, and not on the script level. Being lazy, I have created a reusable snippet for all of my relays, and use it for a number of different applications.</p>
<p dir="auto">I tried following the instructions on this post in order to create rules that would allow the payload forwarding only between sunset and sunrise time, but am stuck at the javascript portion, as it gives me an error when I try to run the script: "errorMessage": "TypeError: mcApi.utils().getServerLocationSettings is not a function in &lt;eval&gt; at line number 6".</p>
<p dir="auto">I could probably accomplish my goal in some other way, by using a photovoltaic cell, or modifying the script for this particular relay to request the time from the controller, but I'd really like to be able to create and use a rule on the controller itself.</p>
<p dir="auto">Perhaps a revision of your step-by-step instruction on how to accomplish this is in order, as I am sure there are plenty people interested in using the sunrise/sunset times for enabling/disabling triggered actions.</p>
<p dir="auto">PS. am using MySensors 2.1.0 and MyController 0.0.3.Final-SNAPSHOT</p>
]]></description><link>http://forum.mycontroller.org/post/506</link><guid isPermaLink="true">http://forum.mycontroller.org/post/506</guid><dc:creator><![CDATA[adulovic]]></dc:creator><pubDate>Fri, 06 Jan 2017 19:03:47 GMT</pubDate></item><item><title><![CDATA[Reply to Sunrize sunset forward on Sat, 17 Dec 2016 14:03:03 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> Thank you very much.<br />
Everything is working.<br />
<img src="/uploads/files/1481983137057-img_20161217_084224-s.jpg" alt="1_1481983136361_IMG_20161217_084224-s.jpg" class=" img-fluid img-markdown" /> <img src="/uploads/files/1481983137512-img_20161217_084055-s.jpg" alt="0_1481983136323_IMG_20161217_084055-s.jpg" class=" img-fluid img-markdown" /></p>
]]></description><link>http://forum.mycontroller.org/post/416</link><guid isPermaLink="true">http://forum.mycontroller.org/post/416</guid><dc:creator><![CDATA[loic13]]></dc:creator><pubDate>Sat, 17 Dec 2016 14:03:03 GMT</pubDate></item><item><title><![CDATA[Reply to Sunrize sunset forward on Fri, 16 Dec 2016 05:46:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/loic13" aria-label="Profile: loic13">@<bdi>loic13</bdi></a> You can send sunrise, sunset time as <code>custom variable</code> to your node, or any other type as you want.</p>
<p dir="auto">As a first step create a sensor with variables, In this example I am using sensor type as <code>Custom</code> and <code>SensorVariable</code> types as <code>Variable 1</code> for sunrise and <code>Variable 2</code> for sunset.<br />
<img src="/uploads/files/1481865091260-upload-7da6ffae-f597-4c11-a2e3-8fc609c0d119" alt="0_1481865090142_upload-7da6ffae-f597-4c11-a2e3-8fc609c0d119" class=" img-fluid img-markdown" /></p>
<h5>Add these sensorVariables to <code>UidTag</code></h5>
<p dir="auto"><img src="/uploads/files/1481865169013-upload-02950fef-8c83-4060-a856-b93792b0c0d5" alt="0_1481865168235_upload-02950fef-8c83-4060-a856-b93792b0c0d5" class=" img-fluid img-markdown" /></p>
<h5>JavaScript: (Type: Operation)</h5>
<pre><code>var myImports = new JavaImporter(java.io, java.lang, java.util);

with(myImports) {
  //Get Sunrise/Sunset details
  var locSettings = mcApi.utils().getServerLocationSettings();
 
 //Get sensor variables for sunrise and sunset
  var sensorSunRise = mcApi.uidTag().getByUid("sunrise").getResource();
  var sensorSunSet = mcApi.uidTag().getByUid("sunset").getResource();
  
  //Update timezone offset values (by default gives GMT timestamp values)
  var sunrise = locSettings.sunriseTime + locSettings.timezoneOffset;
  var sunset = locSettings.sunsetTime + locSettings.timezoneOffset;

 //Convert milliseconds to seconds and load it in sensor variable value
  sensorSunRise.value = sunrise / 1000;
  sensorSunSet.value = sunset / 1000; 

  //Send/Update thise sensorvariable with updated value
  mcApi.sensor().sendPayload(sensorSunRise); 
  mcApi.sensor().sendPayload(sensorSunSet);
}
</code></pre>
<p dir="auto"><strong>Note:</strong> I have introduced <code>timezoneOffset</code> on most recent build. You have to download snapshot build to execute above script. Thank you!</p>
<p dir="auto">You can add this script on Timer, and you specify update this to your node on every day midnight.</p>
]]></description><link>http://forum.mycontroller.org/post/412</link><guid isPermaLink="true">http://forum.mycontroller.org/post/412</guid><dc:creator><![CDATA[jkandasa]]></dc:creator><pubDate>Fri, 16 Dec 2016 05:46:42 GMT</pubDate></item><item><title><![CDATA[Reply to Sunrize sunset forward on Thu, 15 Dec 2016 23:28:56 GMT]]></title><description><![CDATA[<p dir="auto">I, Thank you very much, that's perfect.<br />
I'm sorry to ask again, i don't know javascript. How can i access the sunrizeTime and sunsetTime value on my script ?<br />
I manage to send a string using the sendPayload() function but what is the correct way to access sunrizeTime value?:<br />
mcApi.sensor().sendPayload(???????);<br />
Thank you.</p>
]]></description><link>http://forum.mycontroller.org/post/410</link><guid isPermaLink="true">http://forum.mycontroller.org/post/410</guid><dc:creator><![CDATA[loic13]]></dc:creator><pubDate>Thu, 15 Dec 2016 23:28:56 GMT</pubDate></item><item><title><![CDATA[Reply to Sunrize sunset forward on Wed, 14 Dec 2016 03:29:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/loic13" aria-label="Profile: loic13">@<bdi>loic13</bdi></a> This feature introduced on <a href="https://github.com/mycontroller-org/mycontroller/issues/322" rel="nofollow ugc">https://github.com/mycontroller-org/mycontroller/issues/322</a></p>
<h4>Example:</h4>
<h4><code>JavaScript</code></h4>
<pre><code>var myImports = new JavaImporter(java.io, java.lang, java.util);

with(myImports) {  
  var location = mcApi.utils().getServerLocationSettings();
}
</code></pre>
<h5>Result:</h5>
<pre><code>{
  "myImports": {},
  "location": {
    "name": "Namakkal",
    "latitude": "11.2333",
    "longitude": "78.1667",
    "sunriseTime": 1481677080000,
    "sunsetTime": 1481718360000
  }
}
</code></pre>
]]></description><link>http://forum.mycontroller.org/post/402</link><guid isPermaLink="true">http://forum.mycontroller.org/post/402</guid><dc:creator><![CDATA[jkandasa]]></dc:creator><pubDate>Wed, 14 Dec 2016 03:29:33 GMT</pubDate></item><item><title><![CDATA[Reply to Sunrize sunset forward on Sun, 11 Dec 2016 23:34:36 GMT]]></title><description><![CDATA[<p dir="auto">Thank you jkandasa.</p>
]]></description><link>http://forum.mycontroller.org/post/394</link><guid isPermaLink="true">http://forum.mycontroller.org/post/394</guid><dc:creator><![CDATA[loic13]]></dc:creator><pubDate>Sun, 11 Dec 2016 23:34:36 GMT</pubDate></item><item><title><![CDATA[Reply to Sunrize sunset forward on Sun, 11 Dec 2016 14:07:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/loic13" aria-label="Profile: loic13">@<bdi>loic13</bdi></a> For now there is no way to get sunrise and sunset time on script. I have created a ticket to track this one. I will add support soon for this.</p>
<p dir="auto"><a href="https://github.com/mycontroller-org/mycontroller/issues/322" rel="nofollow ugc">https://github.com/mycontroller-org/mycontroller/issues/322</a></p>
]]></description><link>http://forum.mycontroller.org/post/393</link><guid isPermaLink="true">http://forum.mycontroller.org/post/393</guid><dc:creator><![CDATA[jkandasa]]></dc:creator><pubDate>Sun, 11 Dec 2016 14:07:21 GMT</pubDate></item><item><title><![CDATA[Reply to Sunrize sunset forward on Fri, 09 Dec 2016 00:03:02 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/loic13" aria-label="Profile: loic13">@<bdi>loic13</bdi></a><br />
I found this:<br />
static String	SKEY_SUNRISE_TIME<br />
static String	SKEY_SUNSET_TIME<br />
How can i retrieve the values and forward it (forward payload?) ?<br />
Thanks</p>
]]></description><link>http://forum.mycontroller.org/post/390</link><guid isPermaLink="true">http://forum.mycontroller.org/post/390</guid><dc:creator><![CDATA[loic13]]></dc:creator><pubDate>Fri, 09 Dec 2016 00:03:02 GMT</pubDate></item></channel></rss>