Class: ESPHome::Entities::Text

Inherits:
ESPHome::Entity show all
Includes:
HasState
Defined in:
lib/esphome/entities/text.rb

Instance Attribute Summary collapse

Attributes inherited from ESPHome::Entity

#device, #disabled_by_default, #entity_category, #icon, #key, #name, #object_id_

Instance Method Summary collapse

Methods inherited from ESPHome::Entity

#inspect

Constructor Details

#initialize(_device, list_entities_response) ⇒ Text

Returns a new instance of Text.



10
11
12
13
14
15
16
# File 'lib/esphome/entities/text.rb', line 10

def initialize(_device, list_entities_response)
  super

  @length_range = Range.new(list_entities_response.min_length, list_entities_response.max_length)
  @pattern = list_entities_response.pattern.empty? ? nil : list_entities_response.pattern
  @mode = list_entities_response.mode[10..].downcase.to_sym
end

Instance Attribute Details

#length_rangeObject (readonly)

Returns the value of attribute length_range.



8
9
10
# File 'lib/esphome/entities/text.rb', line 8

def length_range
  @length_range
end

#modeObject (readonly)

Returns the value of attribute mode.



8
9
10
# File 'lib/esphome/entities/text.rb', line 8

def mode
  @mode
end

#patternObject (readonly)

Returns the value of attribute pattern.



8
9
10
# File 'lib/esphome/entities/text.rb', line 8

def pattern
  @pattern
end

Instance Method Details

#command(state) ⇒ Object



18
19
20
# File 'lib/esphome/entities/text.rb', line 18

def command(state)
  device.send(Api::TextCommandRequest.new(key:, state:))
end