Since a recent upgrade my timer has stopped working. I went from 3.0.4.M? to 3.4.0.M4 to 3.4.0.M5 (I was getting a different error with M4)
Now I get the following error in a rule using a script using ECMAScript-2021
TypeError: waketimer.reschedule is not a function
Looking at the docuemntation (JavaScript Scripting - Automation | openHAB) it looks like timer.reschedule is still a function (and it was working). Any pointers to what I’ve missed? Code below.
Thanks,
Matthew
// Script to increase light level slowly over time
var Wakeup_StartLevel = 0; //Start at this level - Useful if too dim at min level
var Wakeup_EndLevel = 100; //End at this level - Useful if too bright at max level
var Wake_Over = 180; //How long for the transition (seconds 1800s = 30 mins)
var Delay = Wake_Over / ( Wakeup_EndLevel - Wakeup_StartLevel );
var Level = Wakeup_StartLevel;
console.log("WakeUpLight - Rule Starting");
console.log("Wake Light",items.getItem("Wake_Up_Lights_Master_Bed").state);
var waketimer = setTimeout(() => {
if ( (Level < Wakeup_EndLevel) && (items.getItem("Wake_Up_Lights_Master_Bed").state=="ON") ) {
console.log("WakupLight - Setting level to: "+Level);
items.getItem("MasterBedMainLightsSamotechHKDIMA_DIMMABLE_LIGHTLevelControl").sendCommand(Level);
Level++;
waketimer.reschedule(time.ZonedDateTime.now().plusSeconds(Delay));
} else {
clearTimeout()
console.log("WakupLight - Woke");
var offtimer = setTimeout(() => { items.getItem("MasterBedMainLightsSamotechHKDIMA_DIMMABLE_LIGHTLevelControl").sendCommand("OFF"); }, 900000); // Turn off after 15 mins (900k milliseconds)
}
}, 1000);