Class: ESPHome::Entities::Switch
- Inherits:
-
ESPHome::Entity
show all
- Includes:
- HasAssumedState, HasDeviceClass, HasState
- Defined in:
- lib/esphome/entities/switch.rb
Instance Attribute Summary
#device, #disabled_by_default, #entity_category, #icon, #key, #name, #object_id_
Instance Method Summary
collapse
#inspect
Instance Method Details
#command(state) ⇒ Object
14
15
16
|
# File 'lib/esphome/entities/switch.rb', line 14
def command(state)
device.send(Api::SwitchCommandRequest.new(key:, state:))
end
|
18
|
# File 'lib/esphome/entities/switch.rb', line 18
def formatted_state = state ? "on" : "off"
|
#off ⇒ Object
21
|
# File 'lib/esphome/entities/switch.rb', line 21
def off = command(false)
|
#on ⇒ Object
20
|
# File 'lib/esphome/entities/switch.rb', line 20
def on = command(true)
|
#update(state_response) ⇒ Object
10
11
12
|
# File 'lib/esphome/entities/switch.rb', line 10
def update(state_response)
@state = state_response.state
end
|