Class: ESPHome::Action
- Inherits:
-
Object
- Object
- ESPHome::Action
- Defined in:
- lib/esphome/action.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#data_template ⇒ Object
readonly
Returns the value of attribute data_template.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(service, data = {}, data_template = {}, variables = {}) ⇒ Action
constructor
A new instance of Action.
- #inspect ⇒ Object
Constructor Details
#initialize(service, data = {}, data_template = {}, variables = {}) ⇒ Action
Returns a new instance of Action.
27 28 29 30 31 32 |
# File 'lib/esphome/action.rb', line 27 def initialize(service, data = {}, data_template = {}, variables = {}) @service = service @data = data @data_template = data_template @variables = variables end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
25 26 27 |
# File 'lib/esphome/action.rb', line 25 def data @data end |
#data_template ⇒ Object (readonly)
Returns the value of attribute data_template.
25 26 27 |
# File 'lib/esphome/action.rb', line 25 def data_template @data_template end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
25 26 27 |
# File 'lib/esphome/action.rb', line 25 def service @service end |
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
25 26 27 |
# File 'lib/esphome/action.rb', line 25 def variables @variables end |
Class Method Details
.from_protobuf(message) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/esphome/action.rb', line 6 def from_protobuf() data = .data.to_h { |kv| [kv.key, kv.value] } data_template = .data_template.to_h { |kv| [kv.key, kv.value] } variables = .variables.to_h { |kv| [kv.key, kv.value] } if .is_event if .service == TagScanned::SERVICE && data.keys == ["tag_id"] && data_template.empty? && variables.empty? TagScanned.new(data["tag_id"]) else Event.new(.service, data, data_template, variables) end else Action.new(.service, data, data_template, variables) end end |
Instance Method Details
#inspect ⇒ Object
34 35 36 37 38 39 |
# File 'lib/esphome/action.rb', line 34 def inspect "#<#{self.class.name} service=#{service} " \ "data=#{data.inspect} " \ "data_template=#{data_template.inspect} " \ "variables=#{variables.inspect}>" end |