Module: OpenHAB::Core::Events::ItemState

Included in:
ItemStateChangedEvent, ItemStateEvent, ItemStateUpdatedEvent
Defined in:
lib/openhab/core/events/item_state_event.rb

Overview

Helpers common to ItemStateEvent and ItemStateChangedEvent.

Methods that refer to implicit conversion mean that for example a PercentType of 100% will be true for #on?, etc.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#stateState? (readonly)

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

Returns:

  • (State, nil)

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



68
69
70
# File 'lib/openhab/core/events/item_state_event.rb', line 68

def state
  item_state if state?
end

Instance Method Details

#closed?true, false

Check if #state is (implicitly convertible to) CLOSED

Returns:

  • (true, false)


# File 'lib/openhab/core/events/item_state_event.rb', line 43

#down?true, false

Check if #state is (implicitly convertible to) DOWN

Returns:

  • (true, false)


# File 'lib/openhab/core/events/item_state_event.rb', line 35

#inspectString

Returns:

  • (String)


73
74
75
76
77
# File 'lib/openhab/core/events/item_state_event.rb', line 73

def inspect
  s = "#<OpenHAB::Core::Events::#{self.class.simple_name} item=#{item_name} state=#{item_state.inspect}"
  s += " source=#{source.inspect}" if source
  "#{s}>"
end

#null?true, false

Check if #state is NULL

Returns:

  • (true, false)


# File 'lib/openhab/core/events/item_state_event.rb', line 19

#off?true, false

Check if #state is (implicitly convertible to) OFF

Returns:

  • (true, false)


# File 'lib/openhab/core/events/item_state_event.rb', line 27

#on?true, false

Check if #state is (implicitly convertible to) ON

Returns:

  • (true, false)


# File 'lib/openhab/core/events/item_state_event.rb', line 23

#open?true, false

Check if #state is (implicitly convertible to) OPEN

Returns:

  • (true, false)


# File 'lib/openhab/core/events/item_state_event.rb', line 39

#paused?true, false

Check if #state is PAUSE

Returns:

  • (true, false)


# File 'lib/openhab/core/events/item_state_event.rb', line 51

#playing?true, false

Check if #state is PLAY

Returns:

  • (true, false)


# File 'lib/openhab/core/events/item_state_event.rb', line 47

#state?true, false

Check if #state is defined (not UNDEF or NULL)

Returns:

  • (true, false)


60
61
62
# File 'lib/openhab/core/events/item_state_event.rb', line 60

def state?
  !item_state.is_a?(UnDefType)
end

#undef?true, false

Check if #state is UNDEF

Returns:

  • (true, false)


# File 'lib/openhab/core/events/item_state_event.rb', line 15

#up?true, false

Check if #state is (implicitly convertible to) UP

Returns:

  • (true, false)


# File 'lib/openhab/core/events/item_state_event.rb', line 31