Class: ESPHome::Entities::DateTime

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

Instance Attribute Summary

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

Instance Method Details

#command(state) ⇒ Object



16
17
18
# File 'lib/esphome/entities/date_time.rb', line 16

def command(state)
  device.send(Api::DateTimeCommandRequest.new(key:, epoch_seconds: state.to_i))
end

#update(state_response) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/esphome/entities/date_time.rb', line 8

def update(state_response)
  @state = if state_response.missing_state
             nil
           else
             ::Time.at(state_response.epoch_seconds)
           end
end