Class: OpenHAB::Core::Events::TimerEvent
- Inherits:
-
AbstractEvent
- Object
- AbstractEvent
- OpenHAB::Core::Events::TimerEvent
- Defined in:
- lib/openhab/core/events/timer_event.rb
Overview
Adds methods to core openHAB TimerEvent to make it more natural in Ruby
This event can be triggered by a ‘DateTimeTrigger`, `cron`, or `TimeOfDay` trigger.
Instance Attribute Summary collapse
-
#cron_expression ⇒ String?
readonly
The cron expression that triggered this event.
-
#item ⇒ Item?
readonly
The DateTime item that triggered this event.
-
#offset ⇒ Duration?
readonly
The offset from the configured time for this DateTime trigger event.
-
#time ⇒ LocalTime?
readonly
The configured time for this TimeOfDay trigger event.
-
#time_only? ⇒ Boolean
readonly
‘true` when this event was triggered by a DateTimeItem with `timeOnly` set.
Attributes inherited from AbstractEvent
Method Summary
Methods inherited from AbstractEvent
Instance Attribute Details
#cron_expression ⇒ String? (readonly)
Returns The cron expression that triggered this event. ‘nil` when this event wasn’t triggered by a cron trigger.
24 25 26 |
# File 'lib/openhab/core/events/timer_event.rb', line 24 def cron_expression payload&.[](:cronExpression) end |
#item ⇒ Item? (readonly)
Returns The DateTime item that triggered this event. ‘nil` when this event wasn’t triggered by a DateTimeItem trigger.
33 34 35 |
# File 'lib/openhab/core/events/timer_event.rb', line 33 def item payload&.[](:itemName)&.then { |item_name| EntityLookup.lookup_item(item_name) } end |
#offset ⇒ Duration? (readonly)
Returns The offset from the configured time for this DateTime trigger event. ‘nil` when this event wasn’t triggered by a DateTime trigger.
56 57 58 |
# File 'lib/openhab/core/events/timer_event.rb', line 56 def offset payload&.[](:offset)&.seconds end |
#time ⇒ LocalTime? (readonly)
Returns The configured time for this TimeOfDay trigger event. ‘nil` when this event wasn’t triggered by a TimeOfDay trigger.
65 66 67 |
# File 'lib/openhab/core/events/timer_event.rb', line 65 def time payload&.[](:time)&.then { |time| LocalTime.parse(time) } end |
#time_only? ⇒ Boolean (readonly)
Returns ‘true` when this event was triggered by a DateTimeItem with `timeOnly` set. `false` when this event wasn’t triggered by a DateTimeItem or the ‘timeOnly` flag is not set.
46 47 48 |
# File 'lib/openhab/core/events/timer_event.rb', line 46 def time_only? !!payload&.[](:timeOnly) end |