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

#last_state_changeZonedDateTime (readonly)

Returns the time the previous state change occurred.

Returns:

  • (ZonedDateTime)

    the time the previous state change occurred

Since:

  • openHAB 5.0

[View source]

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

#last_state_updateZonedDateTime (readonly)

Returns the time the previous state update occurred.

Returns:

  • (ZonedDateTime)

    the time the previous state update occurred

Since:

  • openHAB 5.0

[View source]

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

#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.

[View source]

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

def was
  old_item_state if was?
end

Instance Method Details

#inspectString

Returns:

  • (String)
[View source]

82
83
84
85
86
87
88
89
90
# File 'lib/openhab/core/events/item_state_changed_event.rb', line 82

def inspect
  s = "#<OpenHAB::Core::Events::ItemStateChangedEvent item=#{item_name} " \
      "state=#{item_state.inspect} was=#{old_item_state.inspect}"
  # @deprecated OH4.3 remove respond_to? checks in the next two lines when dropping OH 4.3
  s += " last_state_update=#{last_state_update}" if respond_to?(:last_state_update) && last_state_update
  s += " last_state_change=#{last_state_change}" if respond_to?(:last_state_change) && last_state_change
  s += " source=#{source.inspect}" if source
  "#{s}>"
end

#was?true, false

Check if state was defined (not UNDEF or NULL)

Returns:

  • (true, false)
[View source]

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

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

#was_closed?true, false

Check if #was is (implicitly convertible to) CLOSED

Returns:

  • (true, false)
[View source]

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

#was_down?true, false

Check if #was is (implicitly convertible to) DOWN

Returns:

  • (true, false)
[View source]

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

#was_null?true, false

Check if #was is NULL

Returns:

  • (true, false)
[View source]

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

#was_off?true, false

Check if #was is (implicitly convertible to) OFF

Returns:

  • (true, false)
[View source]

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

#was_on?true, false

Check if #was is (implicitly convertible to) ON

Returns:

  • (true, false)
[View source]

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

#was_open?true, false

Check if #was is (implicitly convertible to) OPEN

Returns:

  • (true, false)
[View source]

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

#was_paused?true, false

Check if #was is PAUSE

Returns:

  • (true, false)
[View source]

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

#was_playing?true, false

Check if #was is PLAY

Returns:

  • (true, false)
[View source]

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

#was_undef?true, false

Check if #was is UNDEF

Returns:

  • (true, false)
[View source]

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

#was_up?true, false

Check if #was is (implicitly convertible to) UP

Returns:

  • (true, false)
[View source]

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