Class: Zaptec::State
- Inherits:
-
Object
- Object
- Zaptec::State
- Defined in:
- lib/zaptec/state.rb
Constant Summary collapse
- CONNECTED_REQUESTING =
"Connected_Requesting".freeze
- CONNECTED_CHARGING =
"Connected_Charging".freeze
- DISCONNECTED =
"Disconnected".freeze
- CHARGING_MODES =
[CONNECTED_CHARGING, CONNECTED_REQUESTING].freeze
Instance Method Summary collapse
- #charging? ⇒ Boolean
- #disconnected? ⇒ Boolean
-
#initialize(data) ⇒ State
constructor
A new instance of State.
- #max_phases ⇒ Object
- #meter_reading ⇒ Object
- #online? ⇒ Boolean
- #total_charge_power ⇒ Object
- #total_charge_power_session ⇒ Object
Constructor Details
#initialize(data) ⇒ State
Returns a new instance of State.
8 9 10 |
# File 'lib/zaptec/state.rb', line 8 def initialize(data) @data = data end |
Instance Method Details
#charging? ⇒ Boolean
18 |
# File 'lib/zaptec/state.rb', line 18 def charging? = charger_operation_mode.in?(CHARGING_MODES) |
#disconnected? ⇒ Boolean
20 |
# File 'lib/zaptec/state.rb', line 20 def disconnected? = charger_operation_mode == DISCONNECTED |
#max_phases ⇒ Object
14 |
# File 'lib/zaptec/state.rb', line 14 def max_phases = @data.fetch(:MaxPhases).to_i |
#meter_reading ⇒ Object
24 25 26 |
# File 'lib/zaptec/state.rb', line 24 def meter_reading @meter_reading ||= MeterReading.parse(@data.fetch(:SignedMeterValue)) end |
#online? ⇒ Boolean
22 |
# File 'lib/zaptec/state.rb', line 22 def online? = @data.fetch(:IsOnline).to_i.positive? |
#total_charge_power ⇒ Object
12 |
# File 'lib/zaptec/state.rb', line 12 def total_charge_power = @data.fetch(:TotalChargePower).to_f |
#total_charge_power_session ⇒ Object
16 |
# File 'lib/zaptec/state.rb', line 16 def total_charge_power_session = @data.fetch(:TotalChargePowerSession).to_f |