What to use instead in rule? - "The method getCalendar() from the type DateTimeType is deprecated"

I have a few rules in which I check if my rollershutters are closed or if it is after sunset.
Since today I run with openHAB 2.4 and try to solve all the warnings as I have a few rules which do not get fired anymore (since the upgrade) and I a don’t know yet why.

Here is such an example rule:

rule "Motion Podest"
 when
 	Item Bewegung_EG_Treppe_Podest received command 
 then
    //logInfo("Motion Rule", " Es wurde Bewegung hier erkannt  ")
    
 	if(receivedCommand==ON) {
 		// motion detected
 		// if  
 		// -> Rollladen_Flure.state==100 (means rollershutter is down)
 		// or 
 		// -> after sunset
 		// then 
                // turn on light 
 		if ((Rollladen_Flure.state==100) || (now.isAfter((Sunset_Time.state as DateTimeType).calendar.timeInMillis)) ) {
 			sendCommand(Licht_OG_Flur_LED_Podest, ON)
 		}
	} else if(receivedCommand==OFF) {
		// for now do nothing here ...
	}
 end

This now gives me this warning when saving the file:
“The method getCalendar() from the type DateTimeType is deprecated”
… plus this rule does not get fired anymore
I did check the item itself and can see that it “turns ON” in openHAB when there is motion.
But first I would like to get rid of the deprecated warning as there must be a better way to do this.
I hope that once I have fixed those warnings the file does not produce this warning anymore “Validation issues found in configuration model ‘motion_sensor.rules’, using it anyway” which also irritates me as it does not clearly say what went wrong and if those rules will be ignored or still used.
Thanks for helping.

The solution is to search before you post.

@Bruce_Osborne - how you know I did not search? I have like 20 tabs open in my browser and did not just read the post you forwarded but also others posts.
I might be to dumb to follow that post & somehow have the feeling it did not really answer the question. This is why I was posting my question.
This other thread ended in October 2018.
Instead of pointing me to that thread which I already read before it would have been more helpful to
a) give me a hint how to solve the “after sunset” problem more intelligent
or
b) rewrite my problematic “getCalendar” statement with what the solution might be.

I appreciate any help.
I’ll re-read that mentioned post again and see if that really is a elegant solution.

[Sorry if that post sounds a little harsh … I am just a little frustrated as every time I do an update of OH … I have to fix things as something essential always brakes. I really like OH … still it is hard to do updates.]

We do not know you searched do we can assume, like many other here, you did not.

Well then it might sometimes be better to not reply to an post you feel in not necessary than to frustrate people.
As said before i appreciate the hard work of the community and I fully understand that not all is working flawlessly but still it should be allowed to ask a question or ask for help when there seems to be no solution.

So next time I will add links to the post that I have read and feel they did not help to solve my problem.

Ronny, it is absolutely fine to ask questions and yes, it can be frustrating when an update breaks something

1 Like

This was helpful for me: