Class: OpenHAB::Core::Events::AbstractEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/openhab/core/events/abstract_event.rb

Overview

Add attachments event data.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attachmentObject

Returns:

  • (Object)


11
12
13
# File 'lib/openhab/core/events/abstract_event.rb', line 11

def attachment
  @attachment
end

#inputsHash

Returns:

  • (Hash)


14
15
16
# File 'lib/openhab/core/events/abstract_event.rb', line 14

def inputs
  @inputs
end

#sourceString (readonly)

Returns The component that sent the event.

Returns:

  • (String)

    The component that sent the event.



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

Instance Method Details

#inspectString

Returns:

  • (String)


56
57
58
59
60
# File 'lib/openhab/core/events/abstract_event.rb', line 56

def inspect
  s = "#<OpenHAB::Core::Events::#{self.class.simple_name} topic=#{topic} payload=#{payload.inspect}"
  s += " source=#{source.inspect}" if source
  "#{s}>"
end

#payloadHash?

Returns the event payload as a Hash.

Returns:

  • (Hash, nil)

    The payload object parsed by JSON. The keys are symbolized. nil when the payload is empty.



45
46
47
48
49
50
51
52
53
# File 'lib/openhab/core/events/abstract_event.rb', line 45

def payload
  require "json"
  # Disable "instance vars on non-persistent Java type"
  original_verbose = $VERBOSE
  $VERBOSE = nil
  @payload ||= JSON.parse(get_payload, symbolize_names: true) unless get_payload.empty?
ensure
  $VERBOSE = original_verbose
end