From e565ba4ed4e034a9daa9ba56f797999933b79f1a Mon Sep 17 00:00:00 2001 From: Jimmy Tanagra Date: Fri, 13 Sep 2024 08:56:06 +1000 Subject: [PATCH] Add `#time_only?` and `#offset` to TimerEvent Signed-off-by: Jimmy Tanagra --- lib/openhab/core/events/timer_event.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/openhab/core/events/timer_event.rb b/lib/openhab/core/events/timer_event.rb index 5d0f48c67e..f976957100 100644 --- a/lib/openhab/core/events/timer_event.rb +++ b/lib/openhab/core/events/timer_event.rb @@ -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.