Hi there
I’m looking (if it’s possible) a rules wich will calculate the time of daylight of the day and tells me how many minutes more or less from yesterday and tomorrow.
Has anyone this kind of rules?
I’m not sure to be able to this kind of rules.
Thanks for your reply. I’m not used to see rules like this. Always something new:)
But I don’t understand all of it.
What for is Mode and deltaDuree?
And is there a possibility to get the rise and set for tomorrow?
Mode as nothing to do with your initial question. I just posted my rule as is. Sun_Rise and Sun_Set comes from Astro binding directly. I would not recommend using Astro action as it is a v1 OH package that is likely to disappear in the future.
Please be aware that this is not rules DSL but jython. You will have to install additional stuff to use this “new rules”.
You can use the Astro Binding (V2) to get the information, at least for yesterday (save the data before midnight to the item) and today. I’m not aware of an option to use astro actions with v2 binding, but maybe the author of the binding has some tips.
Thanks all of you and your replys.
I did it like this. Shurly not the best possibility but it works
I used Astro Binding to get daylength. To calculate difference between yesterday/today and today/tomorrow I used a Python script.
This gave me the hint: Astro binding - Enhancement for tomorrow's sunrise and sunset
I didn’t use Astro Binding for today since it didn’t give me same time of sunrise and sunset.
//****************************************************************
rule "Astro_DayLength"
when
System started or
Time cron "0 5 * * * ? *" // Every hour at 5 past
then
{
var sunrise = new DateTime(Astro_Sunrise_Time.state.toString)
var sunset = new DateTime(Astro_Sunset_Time.state.toString)
var duree=Math.abs(new Duration(sunrise, sunset).getStandardMinutes())
var hrs = (duree / 60) % 60
var min = (duree - (hrs*60))
Astro_Daylength.postUpdate(String::format("%02dh%02d", hrs, min))
}
end
//****************************************************************
rule "tomorrow's less_more daylength"
when
System started or
Time cron "0 5 * * * ? *" // Every hour at 5 past
then
var String minString = executeCommandLine("python /etc/openhab2/scripts/suntomorrow.py", 5000)
logInfo("Tomorrow's more/less minutes: ", minString)
Astro_Daylength_T.postUpdate(minString)
end
//****************************************************************
rule "yesterday's less_more daylength"
when
System started or
Time cron "0 5 * * * ? *" // Every hour at 5 past
then
var String min1String = executeCommandLine("python /etc/openhab2/scripts/sunyesterday.py", 5000)
logInfo("Yesterday's more/less minutes: ", min1String)
Astro_Daylength_Y.postUpdate(min1String)
end