Class: OpenHAB::DSL::Items::TimedCommand::TimedCommandDetails

Inherits:
Struct
  • Object
show all
Defined in:
lib/openhab/dsl/items/timed_command.rb

Overview

Provides information about why the expiration block of a timed command is being called.

Instance Method Summary collapse

Instance Method Details

#cancelled?true, false

Returns:

  • (true, false)


64
65
66
# File 'lib/openhab/dsl/items/timed_command.rb', line 64

def cancelled?
  resolution == :cancelled
end

#expired?true, false

Returns:

  • (true, false)


59
60
61
# File 'lib/openhab/dsl/items/timed_command.rb', line 59

def expired?
  resolution == :expired
end

#reschedule(time = nil) ⇒ void

This method returns an undefined value.

Reschedule the timed command.

If the timed command was cancelled, this will also resume it.

Parameters:

  • time (java.time.temporal.TemporalAmount, #to_zoned_date_time, Proc, nil) (defaults to: nil)

    When to reschedule the timer for. If unspecified, the original time is used.



77
78
79
80
# File 'lib/openhab/dsl/items/timed_command.rb', line 77

def reschedule(time = nil)
  self.resolution = nil
  timer.reschedule(time)
end

#resumevoid

This method returns an undefined value.

Resume a cancelled timed command to its original expiration time.



87
88
89
90
91
92
93
# File 'lib/openhab/dsl/items/timed_command.rb', line 87

def resume
  if expired?
    logger.warn "Cannot resume a timed command that has expired. Use reschedule instead."
  else
    self.resolution = nil
  end
end