Hi
I’m trying to make my own Wake-up light using openHab. I’m using the DateTime NextAlarm from my amazon echo and i want to compare it to the current time. When i try to do this i get: "no viable alternative at input ‘Date’. clearly I’m doing something wrong. can someone help me?
So i changed my code and it works better now. I still have a problem. I only want my WakeUpLight to switch when it is OFF. I tried a few things to make this work but OpenHab keeps sending a ON command to my light.
import org.joda.time.*
import org.openhab.core.library.types.*
rule "Alexa Wake Up Light"
when
Time cron "0 * * ? * *"
then
if(Date.state != NULL && Echo_Kamer_Gregory_NextAlarm.state != NULL) {
var DateTime Alarm = new DateTime((Echo_Kamer_Gregory_NextAlarm.state as DateTimeType).calendar.timeInMillis)
var DateTime Current_Time = new DateTime((Date.state as DateTimeType).calendar.timeInMillis)
if(Current_Time > Alarm.minusMinutes(30) && Current_Time < Alarm && WakeUpLight.getStateAs(OnOffType) != ON){
WakeUpLight.sendCommand(ON)
}
}
end