Class: OpenHAB::Core::Events::ItemStateChangedEvent

Inherits:
ItemEvent show all
Includes:
ItemState
Defined in:
lib/openhab/core/events/item_state_changed_event.rb

Overview

AbstractEvent sent when an item's state has changed.

Instance Attribute Summary collapse

Attributes included from ItemState

#state

Attributes inherited from ItemEvent

#group, #item

Attributes inherited from AbstractEvent

#attachment, #inputs, #source

Instance Method Summary collapse

Methods included from ItemState

#closed?, #down?, #null?, #off?, #on?, #open?, #paused?, #playing?, #state?, #undef?, #up?

Methods inherited from AbstractEvent

#payload

Instance Attribute Details

#wasState? (readonly)

Returns the prior state of the item if it was not UNDEF or NULL, nil otherwise.

Returns:

  • (State, nil)

    the prior state of the item if it was not UNDEF or NULL, nil otherwise.



69
70
71
# File 'lib/openhab/core/events/item_state_changed_event.rb', line 69

def was
  old_item_state if was?
end

Instance Method Details

#inspectString

Returns:

  • (String)


74
75
76
77
78
79
# File 'lib/openhab/core/events/item_state_changed_event.rb', line 74

def inspect
  s = "#<OpenHAB::Core::Events::ItemStateChangedEvent item=#{item_name} " \
      "state=#{item_state.inspect} was=#{old_item_state.inspect}"
  s += " source=#{source.inspect}" if source
  "#{s}>"
end

#was?true, false

Check if state was defined (not UNDEF or NULL)

Returns:

  • (true, false)


61
62
63
# File 'lib/openhab/core/events/item_state_changed_event.rb', line 61

def was?
  !old_item_state.is_a?(UnDefType)
end

#was_closed?true, false

Check if #was is (implicitly convertible to) CLOSED

Returns:

  • (true, false)


# File 'lib/openhab/core/events/item_state_changed_event.rb', line 44

#was_down?true, false

Check if #was is (implicitly convertible to) DOWN

Returns:

  • (true, false)


# File 'lib/openhab/core/events/item_state_changed_event.rb', line 36

#was_null?true, false

Check if #was is NULL

Returns:

  • (true, false)


# File 'lib/openhab/core/events/item_state_changed_event.rb', line 20

#was_off?true, false

Check if #was is (implicitly convertible to) OFF

Returns:

  • (true, false)


# File 'lib/openhab/core/events/item_state_changed_event.rb', line 28

#was_on?true, false

Check if #was is (implicitly convertible to) ON

Returns:

  • (true, false)


# File 'lib/openhab/core/events/item_state_changed_event.rb', line 24

#was_open?true, false

Check if #was is (implicitly convertible to) OPEN

Returns:

  • (true, false)


# File 'lib/openhab/core/events/item_state_changed_event.rb', line 40

#was_paused?true, false

Check if #was is PAUSE

Returns:

  • (true, false)


# File 'lib/openhab/core/events/item_state_changed_event.rb', line 52

#was_playing?true, false

Check if #was is PLAY

Returns:

  • (true, false)


# File 'lib/openhab/core/events/item_state_changed_event.rb', line 48

#was_undef?true, false

Check if #was is UNDEF

Returns:

  • (true, false)


# File 'lib/openhab/core/events/item_state_changed_event.rb', line 16

#was_up?true, false

Check if #was is (implicitly convertible to) UP

Returns:

  • (true, false)


# File 'lib/openhab/core/events/item_state_changed_event.rb', line 32