OH3 - Rule from 2.5 dont work - now.getHour() replacement

  • Platform information:
    • Hardware: CPUArchitecture/RAM/storage
    • OS: what OS is used and which version
    • Java Runtime Environment: which java platform is used and what version
    • openHAB version: OH 3

Hi,
coming from OH2.5 the rule dont work. Can some1 help me?

rule “Präsenzmelder Büro Licht an”

when

Item EG_Buero_Praesenz changed from OFF to ON

then

if (Tag_Nacht.state==ON  && (now.getHour() >= 16 && now.getHour() <= 20 )){

  EG_Arbeitszimmer.sendCommand(ON)

}

end

I think i need to replace the now.getHour but how?

Thanks in advance and BR

I do not think that this is the problem as I also have rules running in OH3 which work perfectly with now.getHour(), for example this one which switches on a dimmer light with different dimming levels depending on the time (low light level betwenn 9pm to 7am:

//Regel Licht Eingang ON
rule "EX_EING_D1_ON"
when
	Item EX_EING_D1 received command ON
then
				if (now.getHour() >= 21  || now.getHour() <= 7  )
     		{
			SW_EING_D1.sendCommand(ON)	 
     		DI_EING_D1.sendCommand(15)
     		} 
     		else
     		{
			SW_EING_D1.sendCommand(ON)		 
     		DI_EING_D1.sendCommand(60)
     		}    		  		   		   	
end  

So I assume there must be something else in your rule which causes problems. Could you post the complete rule? And also the error message from the log?

Ok, my thought where that this wont work in OH3. Thanks alot!