Sha256: b690ec6dcebb5a45a35ced3f529829f498d2be3f61607ec6d0bbf39daf13dc90
Contents?: true
Size: 832 Bytes
Versions: 2
Compression:
Stored size: 832 Bytes
Contents
module Easee class State 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 def initialize(data) @data = data.symbolize_keys end def charging? = charger_op_mode == :charging def disconnected? = charger_op_mode == :disconnected def online? = @data.fetch(:isOnline) def meter_reading MeterReading.new( reading_kwh: @data.fetch(:lifetimeEnergy), timestamp: Time.zone.parse(@data.fetch(:latestPulse)), ) end private def charger_op_mode numeric_op_mode = @data.fetch(:chargerOpMode) CHARGER_OP_MODES.fetch(numeric_op_mode) { OP_MODE_UNKNOWN } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
stekker_easee-1.0.2 | lib/easee/state.rb |
stekker_easee-1.0.1 | lib/easee/state.rb |