Class: ESPHome::Entities::Time
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
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/esphome/entities/time.rb', line 26
def command(state)
if defined?(ActiveSupport::Duration)
parts = state.parts
device.send(Api::TimeCommandRequest.new(key:,
hour: parts[:hours] || 0,
minute: parts[:minutes] || 0,
second: parts[:seconds] || 0))
else
device.send(Api::TimeCommandRequest.new(key:, hour: state[0], minute: state[1], second: state[2]))
end
end
|
20
21
22
23
24
|
# File 'lib/esphome/entities/time.rb', line 20
def formatted_state
return format("%02d:%02d:%02d", *state) if state.is_a?(Array)
super
end
|
#update(state_response) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/esphome/entities/time.rb', line 8
def update(state_response)
@state = if state_response.missing_state
nil
elsif defined?(ActiveSupport::Duration)
state_response.hour.hours +
state_response.minute.minutes +
state_response.second.seconds
else
[state_response.hour, state_response.minute, state_response.second]
end
end
|