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
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).
# 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
HSBType now has planckian helper methods to make working with white CCT lights easier. For more details, see HSBType#planckian? (aliased as #white_cct?), and HSBType#planckian_cct (aliased as #white_cct).
This version supports running on openHAB 5.0-SNAPSHOT by working around a current JRuby bug reported here. The issue exists on Java21. The library continues to be compatible with and tested against openHAB 3.4.5, and all 4.x latest releases.
Support creating a trigger profile for the UI by @jimtng in #373
It is now possible (and easy!) to create a profile in JRuby for every possible scenario: State and Trigger profiles, which can be used both in UI and file-based items/links.
NOTE: This version dropped support for openHAB 3.4.x and openHAB 4.0.x. Changes in the gem versioning are not required for existing openHAB 3/4.0 installations. The gem dependencies will automatically resolve and only upgrade the helper library up to the latest supported version 5.35.1
openHAB 4.1.x, 4.2.x, 4.3.x, and 5.0 are fully supported going forward.
This is an exciting release because we’re able to drop the old Ruby 2.6 compatibility used in openHAB 3.4.x and move the codebase up to Ruby 3.1 syntax and libraries. A lot of legacy openHAB 3.4 and 4.0 specific code have also been removed.
This fixes a critical gem dependency issue that’s caused by 5.36.0 as reported here
If you experienced an error after upgrading to 5.36.0, please delete your .gems directory, usually located in CONF/automation/ruby/.gems and restart jrubyscripting addon or openhab itself. If you were still on earlier version, you don’t need to delete your gems directory.
Please re-install any custom gems if you had previously installed them manually. Gems installed through the inline bundler will automatically reinstall when your inline bundler re-executes.