import java.lang.Math
rule "Calculate Sun Height"
when
Time cron "0 0/5 * * * ?"
then
var current_time = Date.state as DateTimeType
var Number tageszahl
var Number deklin
var Number zeitdiff
var Number x
var Number K
var Number height
// QUELLE: http://www.jgiesen.de/SME/tk/index.htm
K = 0.01745;
if (current_time.calendar != null) {
//early_enough = (current_hour < 18) && (current_hour >7)
}
tageszahl = (current_time.calendar.get(java::util::Calendar::MONTH) - 1) + current_time.calendar.get(java::util::Calendar::DAY_OF_MONTH) + 0.5
deklin = -23.45 * Math.cos( K * 360 * (tageszahl + 10) / 365)
zeitdiff = current_time.calendar.get(java::util::Calendar::HOUR) + current_time.calendar.get(java::util::Calendar::MINUTE) / 60 - ( 15.0 - longitude)/15.0 - 12
x = sin(K * latitude) * sin(K * deklin) + cos(K * latitude) * cos(K * deklin) * cos(K * 15.0 * zeitdiff)
height = x / K + 0.25 * x*x*x / K
sendCommand(Sun, OFF)
end
--
You received this message because you are subscribed to the Google Groups "openhab" group.
To view this discussion on the web visit https://groups.google.com/d/msg/openhab/-/y6gICkmQneQJ.
To post to this group, send email to ope...@googlegroups.com.
To unsubscribe from this group, send email to openhab+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/openhab?hl=en.
Hi Ralf,please replace "." by "::" whithin your when clause, e.g. Math::cos(number).Cheers,Thomas E.-E.
Cool, you are writing already writing pretty complex rules :-)
> I need to test how this works. If you see the need for
> change/improvement, please let me know.
Just one very minor suggestions:
At the end of your "Set Sun Height and Dawn States" rule, you could
use "postUpdate()" instead of "sendCommand()" as you are not really
telling the sun to go down, but you rather only observe its state (or
are you some kind of god, then apologies ;-)).
As we have the "autoupdate" feature, your current code works as well,
as after receiving the command, the item will automatically send an
update event.
Regards,
Kai
> Am 24.04.2012 um 09:34 schrieb Thomas Eichstädt-Engelen:
>
>> Hi Ralf,
>>
>> please replace "." by "::" whithin your when clause, e.g.
>> Math::cos(number).
>>
>> Cheers,
>>
>> Thomas E.-E.
>
> --
> r...@lf-klueber.de
>
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "openhab" group.
Just one very minor suggestions:
At the end of your "Set Sun Height and Dawn States" rule, you could use "postUpdate()" instead of "sendCommand()" as you are not really telling the sun to go down, but you rather only observe its state (or are you some kind of god, then apologies ;-)).
As we have the "autoupdate" feature, your current code works as well, as after receiving the command, the item will automatically send an update event.
--
You received this message because you are subscribed to the Google Groups "openhab" group.
To view this discussion on the web visit https://groups.google.com/d/msg/openhab/-/UrhuRlfSNBIJ.
You seem to have a hell of a lot of rules…
Is this " a lot"? What about your others configurations?
--
You received this message because you are subscribed to the Google Groups "openhab" group.
To view this discussion on the web visit https://groups.google.com/d/msg/openhab/-/7o4R3z1bjOoJ.
Am Donnerstag, 20. September 2012 um 09:49 schrieb Thomas Eichstädt-Engelen:
probably the location is different?
- sent from a mobile device -
Hi,i have integrated the rules, but i am wondering about the times for sunrise.Astro triggers at 4:27Nautical at 5:07Civil at 5:47and Solar at 6:27but the sunrise from wetteronline.de and google says 7:16.i wondering why none of the openhab values are the same as the time from the websites
Am Freitag, 14. September 2012 07:42:37 UTC+2 schrieb (unbekannt):
joeR - you are right with negative values, yet dawn and dusk are interchanged. Dawn is the twilight before sunrise, dusk is the twilight after sunset.Sun_Dawn_Solar.postUpdate( if (sonnenhoehe > 0) ON else OFF )Sun_Dawn_Civil.postUpdate( if (sonnenhoehe > -6) ON else OFF )Sun_Dawn_Nautical.postUpdate( if (sonnenhoehe > -12) ON else OFF )Sun_Dawn_Astronomical.postUpdate( if (sonnenhoehe > -18) ON else OFF )
Sun_Dusk_Solar.postUpdate( if (sonnenhoehe < 0) ON else OFF )Sun_Dusk_Civil.postUpdate( if (sonnenhoehe < -6) ON else OFF )Sun_Dusk_Nautical.postUpdate( if (sonnenhoehe < -12) ON else OFF )Sun_Dusk_Astronomical.postUpdate( if (sonnenhoehe < -18) ON else OFF )
On Tuesday, September 4, 2012 8:42:25 AM UTC+2, joeR wrote:
<Untitled>
--
You received this message because you are subscribed to the Google Groups "openhab" group.
To view this discussion on the web visit https://groups.google.com/d/msg/openhab/-/7o4R3z1bjOoJ.
To post to this group, send email to ope...@googlegroups.com.
To unsubscribe from this group, send email to openhab+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/openhab?hl=en.
I think your change solved the problem.
The "old" version calculated for lat, 52.51, lon. 13.55, time 22:10 a sun height of -32° while the your version calculates -27°.
The site http://www.detlefhahn.de/segeln/astro/zeitgleichung.php also returns -27°. As this site has approximately the same sunrise/sunset times as http://www.suncalc.net I assume these as the correct values.
--
You received this message because you are subscribed to the Google Groups "openhab" group.
To view this discussion on the web visit https://groups.google.com/d/msg/openhab/-/Q-nbHBQgDJkJ.
--
You received this message because you are subscribed to the Google Groups "openhab" group.
To view this discussion on the web visit https://groups.google.com/d/msg/openhab/-/q8UEHZ69LcsJ.
--
You received this message because you are subscribed to the Google Groups "openhab" group.
To view this discussion on the web visit https://groups.google.com/d/msg/openhab/-/B4lE33WXHyAJ.