Class: Easee::State
- Inherits:
-
Object
- Object
- Easee::State
- Defined in:
- lib/easee/state.rb
Constant Summary collapse
- OP_MODE_UNKNOWN =
:unknown
- CHARGER_OP_MODES =
{ 0 => :offline, 1 => :disconnected, 2 => :awaiting_start, 3 => :charging, 4 => :completed, 5 => :error, 6 => :ready_to_charge, }.freeze
Instance Method Summary collapse
- #charging? ⇒ Boolean
- #disconnected? ⇒ Boolean
-
#initialize(data) ⇒ State
constructor
A new instance of State.
- #meter_reading ⇒ Object
- #online? ⇒ Boolean
Constructor Details
#initialize(data) ⇒ State
Returns a new instance of State.
15 16 17 |
# File 'lib/easee/state.rb', line 15 def initialize(data) @data = data.symbolize_keys end |
Instance Method Details
#charging? ⇒ Boolean
19 |
# File 'lib/easee/state.rb', line 19 def charging? = charger_op_mode == :charging |
#disconnected? ⇒ Boolean
20 |
# File 'lib/easee/state.rb', line 20 def disconnected? = charger_op_mode == :disconnected |
#meter_reading ⇒ Object
23 24 25 26 27 28 |
# File 'lib/easee/state.rb', line 23 def meter_reading MeterReading.new( reading_kwh: @data.fetch(:lifetimeEnergy), timestamp: Time.zone.parse(@data.fetch(:latestPulse)), ) end |
#online? ⇒ Boolean
21 |
# File 'lib/easee/state.rb', line 21 def online? = @data.fetch(:isOnline) |