class MideaAirCondition::Command::BaseCommand

Base Command class

Public Class Methods

new(device_type: 0xAC) click to toggle source

Default device type: 0xAC

# File lib/commands/command.rb, line 8
def initialize(device_type: 0xAC)
  @data = [0xaa, 0x23, device_type, 0x00, 0x00, 0x00, 0x00, 0x00]

  @data += [
    0x03, 0x02, 0xff, 0x81, 0x00, 0xff, 0x03, 0xff,
    0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00
  ]

  fill
end

Public Instance Methods

finalize(security) click to toggle source
# File lib/commands/command.rb, line 20
def finalize(security)
  # Add command sequence number
  # Can't be lower than 3
  @data << 0x03
  @data << security.crc8(@data[0x10..(@data.length - 1)])
  @data[0x01] = @data.length

  @data
end

Private Instance Methods

fill() click to toggle source
# File lib/commands/command.rb, line 32
def fill; end