class MideaAirCondition::Device

Device representation (now only for status parsing)

Attributes

data[R]

Public Class Methods

new(data) click to toggle source
# File lib/device.rb, line 8
def initialize(data)
  @data = data
  @pointer = 0x33
end

Public Instance Methods

eco() click to toggle source
# File lib/device.rb, line 48
def eco
  !((@data[@pointer + 8] & 0x10) >> 4).zero?
end
fan_speed() click to toggle source
# File lib/device.rb, line 36
def fan_speed
  @data[@pointer + 2] & 0x7f
end
indoor_temperature() click to toggle source
# File lib/device.rb, line 40
def indoor_temperature
  (@data[@pointer + 10] - 50) / 2
end
mode() click to toggle source
# File lib/device.rb, line 21
def mode
  (@data[@pointer + 1] & 0xe0) >> 5
end
mode_human() click to toggle source
# File lib/device.rb, line 25
def mode_human
  mode_value = 'unknown'
  mode_value = 'auto' if mode == 1
  mode_value = 'cool' if mode == 2
  mode_value = 'dry' if mode == 3
  mode_value = 'heat' if mode == 4
  mode_value = 'fan' if mode == 5

  mode_value
end
off_timer() click to toggle source
# File lib/device.rb, line 61
def off_timer
  value = @data[@pointer + 4]
  {
    status:  !((value & 0x80) >> 7).zero?,
    hour:    ((value & 0x7c) >> 2),
    minutes: ((value & 0x3) | ((value & 0xf0)))
  }
end
off_timer_human() click to toggle source
# File lib/device.rb, line 74
def off_timer_human
  "#{off_timer[:hours]}:#{off_timer[:mins]}"
end
on_timer() click to toggle source
# File lib/device.rb, line 52
def on_timer
  value = @data[@pointer + 3]
  {
    status:  !((value & 0x80) >> 7).zero?,
    hour:    ((value & 0x7c) >> 2),
    minutes: ((value & 0x3) | ((value & 0xf0)))
  }
end
on_timer_human() click to toggle source
# File lib/device.rb, line 70
def on_timer_human
  "#{on_timer[:hours]}:#{on_timer[:mins]}"
end
outdoor_temperature() click to toggle source
# File lib/device.rb, line 44
def outdoor_temperature
  (@data[@pointer + 11] - 50) / 2
end
power_status() click to toggle source
# File lib/device.rb, line 13
def power_status
  !(@data[@pointer] & 0x01).zero?
end
temperature() click to toggle source
# File lib/device.rb, line 17
def temperature
  (@data[@pointer + 1] & 0xf) + 16
end