def query_inverter_info(serial_num)
      packet = Jfy::Packet.new(Jfy::Codes::QUERY_INVERTER_INFO, [], :dst => serial_num)
      packet = write(packet)

      fail(BadPacket, 'invalid inverter info response') unless packet.command == Jfy::Codes::QUERY_INVERTER_INFO_RESP

      data = packet.data

      phase_types = {
        0x31 => 1,
        0x33 => 3,
      }
      phases = phase_types[data[0]] || fail("Unknown phase mode #{data[0]}")

      rating          = data[1, 6].pack('c*').to_i
      version         = data[7, 5].pack('c*')
      model           = data[12, 16].pack('c*').strip
      manufacturer    = data[28, 16].pack('c*').strip
      serial          = data[44, 16].pack('c*').strip
      nominal_voltage = data[60, 4].pack('c*').to_i / 10.0

      metrics = {
        :phases          => phases,
        :rating          => rating,
        :version         => version,
        :model           => model,
        :manufacturer    => manufacturer,
        :serial          => serial,
        :nominal_voltage => nominal_voltage,
      }

      metrics
    end
def query_inverter_info(serial_num)
      packet = Jfy::Packet.new(Jfy::Codes::QUERY_INVERTER_INFO, [], :dst => serial_num)
      packet = write(packet)

      fail(BadPacket, 'invalid inverter info response') unless packet.command == Jfy::Codes::QUERY_INVERTER_INFO_RESP

      data = packet.data

      phase_types = {
        0x31 => 1,
        0x33 => 3,
      }
      phases = phase_types[data[0]] || fail("Unknown phase mode #{data[0]}")

      rating          = data[1, 6].pack('c*').to_i
      version         = data[7, 5].pack('c*')
      model           = data[12, 16].pack('c*').strip
      manufacturer    = data[28, 16].pack('c*').strip
      serial          = data[44, 16].pack('c*').strip
      nominal_voltage = data[60, 4].pack('c*').to_i / 10.0

      metrics = {
        :phases          => phases,
        :rating          => rating,
        :version         => version,
        :model           => model,
        :manufacturer    => manufacturer,
        :serial          => serial,
        :nominal_voltage => nominal_voltage,
      }

      metrics
    end
rubocop:enable Metrics/AbcSize, Metrics/MethodLength
 rubocop:disable Metrics/AbcSize, Metrics/MethodLength