Erratic JSscripting Rule Behavior

This looks wrong


It should be

10 °C

Notice the space between the number and the start of the unit and the different character being used for degrees. I suspect your condition is not working because it’s not recognizing that value as a quantity.

You need to add logging to your script to log out the states of important Items to see what the triggering Item is and the condition Item is when the rule runs.

Also, if your rule gets triggered while an interval is already running it will just blindly create a new interval and you’ll end up with two intervals running at the same time. That can explain the weird timing that creeps in over time.

First, let me say this is one of the use cases that caused me to write Threshold Alert and Open Reminder [;]. You can configure that to handle all the timing stuff and your code would only need to focus on the alerts.

If you decide to implement this yourself, what you need to do is check to see if an interval is already running and only if it’s not create the interval. To do that, you’ll need to store NoticeInterval in the cache.

// Why not base the alert on the state of the window? what benefit does WON provide? How is it ever turned OFF?
items.WON.postUpdate('ON'); // commands should be reserved for cases where you are asking something to do something, this is a status flag
cache.private.get('NoticeInterval', () => setInterval( () =>{
  if(items.WON.state == 'ON') {
    if(items.ChetPresence.state == 'ON') {
      items.Echo_Living_Room_TTS.sendCommand("Entschuldigung Sie bitte. Das Badfenster ist noch auf, kann jemand es zumachen, bitte?");
      items.Echo_Office_TTS.sendCommand("The Bathroom Window is still open. Can someone close it please.")
    else if(items.KatPresence.state == 'ON') {
  else {
    cache.private.put('NoticeInterval', null);
}), 1000*60*10);

The interval will only be created if one isn’t already running. If one is already running the rule doesn’t do anything.

If I were to implement this I’d use Looping Timer from openHAB Rules Tools Announcements. It provides a little more flexibility (e.g. you can change the amount of time between iterations of the loop). But it’s still going to require saving the Timer to the cache and only creating one when one doesn’t already exist.