Class: Netatmo::Weather::BatteryDevice

Inherits:
Device
  • Object
show all
Defined in:
lib/netatmo/weather/battery_device.rb

Direct Known Subclasses

IndoorModule, OutdoorModule, RainGauge, WindGauge

Instance Attribute Summary collapse

Attributes inherited from Device

#code, #dashboard_data, #data_types, #firmware, #id, #last_message, #last_seen, #last_setup, #module_name, #reachable, #rf_status, #type

Instance Method Summary collapse

Methods inherited from Device

#battery?, #co2?, #data, #health_index?, #humidity?, #name, #noise?, parse, #pressure?, #rain?, #temperature?, #values, #wind?

Constructor Details

#initialize(data) ⇒ BatteryDevice

Returns a new instance of BatteryDevice.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/netatmo/weather/battery_device.rb', line 8

def initialize(data)
  super(data)

  self.battery_vp = data['battery_vp']
  self.battery_percent = data['battery_percent']

  if type.indoor_module?
    self.battery_status = BatteryStatus::IndoorBatteryStatus.new(battery_vp)
  elsif type.outdoor_module? || type.rain_gauge?
    self.battery_status = BatteryStatus::OutdoorBatteryStatus.new(battery_vp)
  elsif type.wind_gauge?
    self.battery_status = BatteryStatus::WindGaugeBatteryStatus.new(battery_vp)
  end
end

Instance Attribute Details

#battery_percentObject

Returns the value of attribute battery_percent.



6
7
8
# File 'lib/netatmo/weather/battery_device.rb', line 6

def battery_percent
  @battery_percent
end

#battery_statusObject

Returns the value of attribute battery_status.



6
7
8
# File 'lib/netatmo/weather/battery_device.rb', line 6

def battery_status
  @battery_status
end

#battery_vpObject

Returns the value of attribute battery_vp.



6
7
8
# File 'lib/netatmo/weather/battery_device.rb', line 6

def battery_vp
  @battery_vp
end