Just to provide a few observations and reiteration of what everyone else has said.
You are using OH 2. Those imports are not required and in fact should be removed.
As has been described, that line only gets evaluated when the .rules file loads. As astro_Sonnenuntergang changes, t__Dusk remains the same. Beyond that, putting this into a global variable doesn’t really buy you much at all beyond a few keystrokes. Why not replace
else if(t__Dusk <= now.millis)
with
else if(new DateTime(astro_Sonnenuntergang.state.toString).isBefore(now))
It’s not that much longer or harder to understand and it eliminates the need for the global variable.
Or, if you care about time periods like this in more than one Rule, consider using Design Pattern: Time Of Day. Then all of your Rules that care about the time can look like:
rule "Rollläden herunterfahren"
when
Item vTimeOfDay changed to DUSK or // starts at civil dusk
Item vTimeOfDay changed to EVENING or // starts at 21:00
Item vTimeOfDay change to NIGHT // starts at 21:30
then
switch(vTimeOfDay.state.toString) {
case "EVENING": {
// do something
}
case "NIGHT": {
// do something
}
case "DUSK": {
// do something
}
}
end
Then if you change when you want stuff to happen you only need to adjust it in one Rule instead of a bunch. And there is no need for the global variable. And you can even start to do even more interesting stuff.