Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add #time_only? and #offset to TimerEvent #333

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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