Class: ESPHome::Entities::Date

Inherits:
ESPHome::Entity show all
Includes:
HasState
Defined in:
lib/esphome/entities/date.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



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

def command(state)
  device.send(Api::DateCommandRequest.new(key:, year: state.year, month: state.month, day: state.day))
end

#update(state_response) ⇒ Object



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

def update(state_response)
  @state = if state_response.missing_state
             nil
           else
             ::Date.new(state_response.year,
                        state_response.month,
                        state_response.day)
           end
end