openHAB 4.0 wishlist

It’s probably a longshot for the wishlist, especially for 4.0 (probably needs to go on a future version) but have been thinking more about ‘simple’ global timers for (and aligned to) items.
Anyway, here’s the basic idea

  • Extend the Item class to include a method to set/manipulate a timer associated with the item
  • The timer would be managed by something within the OpenHAB core, outside the rule
  • There can be ONE and only one timer associated with each item
  • This same timer could then be queried/manipulated from any rule/language
  • These item timers could almost be simple enough to present in the UI, as an action in the rules section
  • The existing timers would still remain available in the context of a scripts for more complex use-cases (triggering functions etc), so this should be a non-breaking change (I think!!).

As a quick example of what I am thinking as a starting point for the conversation(excuse the pigeon-code, I am no Java dev!!), see the following:

  • Item.timer
    • Item.timer.setTimer(time,itemCommand)
      • Potentially 3 formats for time:
        • now+x
        • schedule+x (if timer already scheduled, add x to the current schedule time, if not scheduled, treat as now+x). I had considered a ‘-x’ option, but I can see too many situations where it could try set it in the past
        • absolute datetime value
      • Any existing scheduled timer would be cancelled and replaced with above
    • Item.timer.setTimerDiff(time,command if different)
      • Same behaviour as previous, but with send command if different function
    • Item.timer.reschedule(time)
      • Potentially 3 formats for time (see Item.timet.setTimer for details)
      • Returns nextCommand if timer is already active, otherwise FALSE (?)
    • Item.timer.isActive()
      • Returns absolute datetime value if scheduled, otherwise FALSE (?)
    • Item.timer.nextCommand()
      • Returns the next command to be run, if the timer is active, otherwise FALSE (?)
    • Item.timer.cancel()
      • Cancels the existing scheduled timer
      • Returns absolute datetime value if it was scheduled, otherwise FALSE (?)

Also, taking in to account some of the other wishes on here, maybe it could also include a restart persist flag for the setTimer methods, e.g. Item.timer.setTimer(time,itemCommand,persist{NO|YES|FORCE}) with the flags meaning:

  • NO (Default if flag omitted) - timer will not persist during reboot
  • YES - Timer will be recreated to execute at previously scheduled time IF scheduledtime >= ‘OH timer engine’ restart time, otherwise will be ignored
  • FORCE - Timer will be recreated to execute at previously scheduled time IF scheduledtime >= ‘OH timer engine’ restart time, otherwise will be executed immediately upon ‘OH timer engine’ restart.

I would be happy to be corrected, if there was already an easy way to already do this in OH, but unless my search terms have missed the mark, I can’t find anything in the documentation or community pages. Big wish? Yes. But it is a wishlist after all :slight_smile:

2 Likes