Skip to content

Commit

Permalink
Add #time_only? and #offset to TimerEvent (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimtng authored Sep 16, 2024
1 parent f805bbd commit a92b8fa
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/openhab/core/events/timer_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,29 @@ def item
payload&.[](:itemName)&.then { |item_name| EntityLookup.lookup_item(item_name) }
end

#
# @!attribute [r] time_only?
# @return [Boolean]
# `true` when this event was triggered by a {Core::Items::DateTimeItem DateTimeItem} with `timeOnly` set.
# `false` when this event wasn't triggered by a DateTimeItem or the `timeOnly` flag is not set.
# @see DSL::Rules::BuilderDSL::every #every trigger
# @see DSL::Rules::BuilderDSL::at #at trigger
# @since openHAB 4.3
#
def time_only?
!!payload&.[](:timeOnly)
end

#
# @!attribute [r] offset
# @return [Duration, nil] The offset from the configured time for this DateTime trigger event.
# `nil` when this event wasn't triggered by a DateTime trigger.
# @since openHAB 4.3
#
def offset
payload&.[](:offset)&.seconds
end

#
# @!attribute [r] time
# @return [LocalTime, nil] The configured time for this TimeOfDay trigger event.
Expand Down

0 comments on commit a92b8fa

Please sign in to comment.