JRuby Scripting Official Helper Library

Version 5.27.0 is out!

What’s new:

Features

  • Support offset in at and every :day, at: triggers in #278 - this is a new openHAB 4.3 feature (merged after 4.3.0.M1)
  • Support space separator between date and time for DateTimeType.parse in #329

Bug Fixes

  • DateTimeType implements Java’s Comparable in openHAB 4.3 in #328
  • Sitemap updates not propagated to listeners in #327

Full Changelog: v5.26.0…v5.27.0

Example:

Run a rule 30 minutes before the time stored in the My_Daily_Alarm item:

# This only works in openhab 4.3 post M1.
rule "DateTimeItem trigger" do
  every :day, at: My_Daily_Alarm, offset: -30.minutes
  run { Audio.play "alarm_prewarning.mp3" }
end

Note: JRuby supports DateTimeItem trigger in two ways:

  • To use only the time part of the item, use the every :day, at: Item like the example above.
  • To use both the date and time in the item, use the at trigger. Example below:
rule "Birthday trigger" do
  at My_Birthday_This_Year, offset: -1.day
  run { Notification.send "Don't forget to buy Jim a birthday present!" }
end
2 Likes

Version 5.29.0 is out!

What’s new:

  • Improvement in DateTimeType.parse
  • Allow the use of items object within sitemap builder
  • Allow literal states for sitemap visibility rules.
    Example:
    sitemaps.build do
      sitemap "default" do
        switch item: AnItem, visibility: OFF # Previously it had to be string "OFF"
        items.tagged("Switch").each { |item| switch item: }
      end
    end
    
  • Make working with Instant easier.
    You can now write Instant.now - 2.hours just like the operations for ZonedDateTime, Time, etc.
  • Add #yesterday?, #today? , and #tomorrow? to date/time related classes (e.g. ZonedDateTime, Time, Date, Instant, DateTimeType).
  • Add #time_only? and #offset to TimerEvent

Bug fixes:

  • Proper clean up of providers, which affects ruby-built items, things, links, etc. in #330
  • Fix timed command expire in #337

Full Changelog : v5.27.0…v5.29.0

Version 5.31.0 is out!

New features:

  • Allow sending source with commands
  • Add CCT helpers for HSBType.

Example:

# Toggle lights when buttons are pressed
received_command LightButton do
  LightBulb.toggle source: "button"
end

# Set a timer if light wasn't turned on with a physical button
# e.g. via voice command
received_command LightBulb do |event|
  if event.on? && event.source != "button"
    after(30.minutes, id: event.item) { event.item.off }
  else
    timers.cancel(event.item)
  end
end

Full Changelog : v5.29.0…v5.31.0